我刚刚重新安装了VS2012,当尝试编译一个简单的“ hello world”时,它找不到最基本的功能,我尝试通过c的链接选项或编译器选项从GCC中寻找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"

最佳答案

到处都有几次询问,但是问题是您没有选择“ Console”应用程序类型,而是选择了win32 gui。您还需要注意正确的链接器选择。

关于c++ - VS2012无法解决printf,,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/18417791/

10-11 15:39