VS2012无法解析printf,

VS2012 fails to resolve printf,

本文关键字:printf VS2012      更新时间:2023-10-16

我刚刚重新安装了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 "Debugtest.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:_projectscodectestDebugtest.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 "Debugtest.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:_projectscodeCtestDebugtest.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:_projectscodeCtestDebugtest.exe" /MANIFEST /NXCOMPAT /PDB:"C:_projectscodeCtestDebugtest.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:_projectscodeCtestDebugtest.pgd" /SUBSYSTEM:WINDOWS /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /ManifestFile:"Debugtest.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"Debugvc110.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"Debugtest.pch" 

这里已经问了好几次了,但问题是您没有选择"Console"应用程序类型,而是选择了win32 gui。您也需要小心选择正确的链接器。