1

我刚刚重新安装了 VS2012,当尝试编译一个简单的“hello world”时,它找不到最基本的功能,我尝试通过链接选项或编译器选项为 c++ 寻找 nostd 或来自 GCC 的一些类似选项,但失败了这样做

谁能提示我我错过了什么?这显然是我似乎无法解决的配置问题

只是为了澄清一点,当我从命令行“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" 
4

1 回答 1

0

这里已经问了好几次了,但问题是你没有选择“控制台”应用程序类型,而是win32 gui。您还需要注意正确的链接器选择。

于 2013-08-24T11:10:28.273 回答