开发者

VERY simple C program won't compile with VC 64

Here is a very simple C program:

#include <stdio.h>

int main (int argc, char *argv[]) {

    printf("sizeof(short) = %d\n",(int)sizeof(short));
    printf("sizeof(int) = %d\n",(int)sizeof(int));
    printf("sizeof(long) = %d\n",(int)sizeof(long));
    printf("sizeof(long long) = %d\n",(int)sizeof(long long));
    printf("sizeof(float) = %d\n",(int)sizeof(float));
    printf("sizeof(double) = %d\n",(int)sizeof(double));

    return 0;
}

While it compiles fine on Win32 (command line: cl main.c), it does not using the Win64 compiler ("c:\Program Files(x86)\Microsoft Visual开发者_如何学C Studio 9.0\VC\bin\amd64\cl.exe" main.c). Specifically, it sais "error LNK2019: unresolved external symbol printf referenced in function main". As far as I understand this, it can not link to printf, right?

Obviously, I have Microsoft Visual C++ Compiler 2008 (Standard enu) x86 and x64 installed and am using the 64-bit flavor of Windows (7).

What is the problem here?

UPDATE:

OK, now I ran vcvarsall.bat amd64. It sais "The specified configuration type is missing. The tools for this configuration might not be installed.". As mentioned, the compiler clearly is installed??


If you look at vcvarsall.bat it will print the specified configuration missing statement if certain batch files are missing.

For the amd64 option this file must exist:

C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin\amd64\vcvarsamd64.bat


There's something wrong with your setup. It compiles & link fine for me.

D:>cl test.cpp Microsoft (R) C/C++ Optimizing Compiler Version 15.00.30729.01 for x64 Copyright (C) Microsoft Corporation. All rights reserved.

test.cpp Microsoft (R) Incremental Linker Version 9.00.30729.01 Copyright (C) Microsoft Corporation. All rights reserved.

/out:test.exe test.obj

D:>

Did you run vcvarsall.bat with the right options to set up the environment variables before you try running cl.exe? Something along the line of

"C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" x86_amd64


Are you on a 32bit or 64bit system? I'm guessing from the path that the 64bit standard libraries aren't available, at least not in that directory.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜