VS2012无法解析printf,

时间:2013-08-24 10:55:18

标签: c++ visual-studio-2012

我刚刚重新安装VS2012,在尝试编译一个简单的“hello world”时,它找不到最基本的功能,我试过通过链接选项或c ++的编译器选项寻找nostd或类似的选项来自海湾合作委员会但未能这样做

任何人都可以暗示我错过了什么吗?这显然是我似乎无法解决的配置问题

只是为了清楚的事情,当我从命令行“cl test.cpp -o test.exe”使用cl时它起作用,这意味着它是一些我缺少的配置问题

任何人都可以帮帮忙吗?

1>------ Build started: Project: test, Configuration: Debug Win32 ------
1>Build started 8/24/2013 1:52:58 PM.
1>InitializeBuildStatus:
1>  Touching "Debug\test.unsuccessfulbuild".
1>ClCompile:
1>  test.cpp
1>LINK : warning LNK4044: unrecognized option '/map(filename)'; ignored
1>test.obj : error LNK2019: unresolved external symbol __imp__printf referenced in function _main
1>test.obj : error LNK2019: unresolved external symbol __RTC_CheckEsp referenced in function _main
1>test.obj : error LNK2001: unresolved external symbol __RTC_InitBase
1>test.obj : error LNK2001: unresolved external symbol __RTC_Shutdown
1>LINK : error LNK2001: unresolved external symbol _mainCRTStartup
1>C:\_projects\code\c\test\Debug\test.exe : fatal error LNK1120: 5 unresolved externals
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:00.47
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

添加子系统和入口点后,这是同样的错误

1>------ Build started: Project: test, Configuration: Debug Win32 ------
1>Build started 8/24/2013 2:37:29 PM.
1>InitializeBuildStatus:
1>  Touching "Debug\test.unsuccessfulbuild".
1>ClCompile:
1>  All outputs are up-to-date.
1>LINK : warning LNK4044: unrecognized option '/map(filename)'; ignored
1>LINK : warning LNK4075: ignoring '/INCREMENTAL' due to '/RELEASE' specification
1>main.obj : warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/OPT:LBR' specification
1>main.obj : error LNK2019: unresolved external symbol __imp__printf referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol __RTC_CheckEsp referenced in function _main
1>main.obj : error LNK2001: unresolved external symbol __RTC_InitBase
1>main.obj : error LNK2001: unresolved external symbol __RTC_Shutdown
1>C:\_projects\code\C\test\Debug\test.exe : fatal error LNK1120: 4 unresolved externals
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:00.17
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

请注意,这是一个控制台项目

链接器选项:

/OUT:"C:\_projects\code\C\test\Debug\test.exe" /MANIFEST /NXCOMPAT /PDB:"C:\_projects\code\C\test\Debug\test.pdb" /DYNAMICBASE "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "odbc32.lib" "odbccp32.lib" /DEBUG /MACHINE:X86 /ENTRY:"_tmain" /INCREMENTAL /PGD:"C:\_projects\code\C\test\Debug\test.pgd" /SUBSYSTEM:WINDOWS /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /ManifestFile:"Debug\test.exe.intermediate.manifest" /ERRORREPORT:PROMPT /NOLOGO /TLBID:1

c / c ++选项:

/Yu"stdafx.h" /MP /GS /analyze- /W3 /Zc:wchar_t /ZI /Gm /Od /sdl /Fd"Debug\vc110.pdb" /fp:precise /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /fp:except- /errorReport:prompt /WX- /Zc:forScope /RTC1 /GR- /Gd /Oy- /MDd /Fa"Debug\" /nologo /Fo"Debug\" /Fp"Debug\test.pch" 

1 个答案:

答案 0 :(得分:0)

这里已经多次询问过,但问题是你没有选择“Console”应用程序类型,而是win32 gui。您也需要注意正确的链接器选择。