且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将VS2006 C ++代码迁移到VS2010(MFC)。错误LNK2001:未解析的外部符号___argv

更新时间:2023-09-17 11:20:10

为什么忽略默认的LIBC库?



使用 / MT 选项时, libcmt。需要lib (resp。 libcmtd.lib 用于调试版本)。这些库包含启动使用的标准C库函数(可能还有全局 __ argc __ argv 变量)代码位于MSVCRT库中。



也没有必要将MSVCRT和其他标准Windows库指定为附加依赖项,因为它们在使用这些库中的函数时会自动链接(MSVCRT始终如此)。
Why do you ignore the default LIBC libraries?

When using the /MT option, libcmt.lib is required (resp. libcmtd.lib for debug builds). Those libraries contain the standard C library functions (and probably the global __argc and __argv variables) which are used by the startup code located in the MSVCRT library.

There is also no need to specify MSVCRT and other standard Windows libraries as additional dependancies because they are automatically linked when using functions from those libraries (which is always true for the MSVCRT).