a very simple C program in Visual Studio 2005

http://stackoverflow.com/questions/2548361/very-simple-c-program-wont-compile-with-vc-64

http://forums.nvidia.com/index.php?showtopic=65111&pid=398501&mode=threaded&show=&st=&

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 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??

 

 

(1)文件->新建->项目->Visual C++->Win32控制台应用程序
名称中输入项目的名称
确定->下一步->空项目->完成
(2)解决方案资源管理器 中 源文件 右击
添加->新建项->代码->C++文件(.cpp)
名称中输入 某某文件名.c 不要.cpp
添加
(3)项目->项目名 属性->C/C++->高级->编译为
选择 编译为C代码(/TC)
确定
posted @   emanlee  阅读(446)  评论(0编辑  收藏  举报
编辑推荐:
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 一个奇形怪状的面试题:Bean中的CHM要不要加volatile?
· [.NET]调用本地 Deepseek 模型
阅读排行:
· Blazor Hybrid适配到HarmonyOS系统
· Obsidian + DeepSeek:免费 AI 助力你的知识管理,让你的笔记飞起来!
· 解决跨域问题的这6种方案,真香!
· 一套基于 Material Design 规范实现的 Blazor 和 Razor 通用组件库
· 分享4款.NET开源、免费、实用的商城系统
历史上的今天:
2008-04-26 ASP.NET 网站路径
2008-04-26 下载FLV视频
点击右上角即可分享
微信分享提示