环境:Windows XP。Visual Studios 2010。语言 - C++。
我遇到了以下链接错误并且已经没有如何解决这个问题的想法。我有一个项目(CnD 设备),它链接到我的团队控制的 2 个项目(消息和碳)。我试图在 3 个项目之间搜索项目属性
enter tcp_driver.obj : error LNK2019: unresolved external symbol "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl toString(int)" (?toString@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@Z) referenced in function "protected: bool __thiscall Tcp_Driver::readMessage(void)" (?readMessage@Tcp_Driver@@IAE_NXZ)
我相信这个问题是因为我没有链接到标准 C++ 库中的字符串。我一遍又一遍地扫描我的属性列表。以下是我认为对这个问题至关重要的一些属性。
CnD 设备属性信息:
- 配置类型动态库.dll
- 使用MFC 在共享 DLL 中使用 MFC
- 使用 ALT不使用 ALT
- 字符集使用多字节字符集
- 运行时库多线程 DLL (/MD)
- 附加依赖项 msvcprtd.lib、Carbon.lib、BUFFER_API.lib、BUFFER_FRAMEWORK.lib、Messages.lib
- 忽略所有默认库否
消息属性信息:
- 配置类型静态库 (.lib)
- 使用MFC 在共享 DLL 中使用 MFC
- 使用 ALT不使用 ALT
- 字符集使用 Unicode 字符集
- 运行时库多线程 DLL (/MD)
- 附加依赖项
- 链接库依赖否
碳属性信息:
- 配置类型静态库 (.lib)
- 使用MFC 在共享 DLL 中使用 MFC
- 使用 ALT不使用 ALT
- 字符集使用 Unicode 字符集
- 运行时库多线程 DLL (/MD)
- 链接库依赖否
我的 CnD 链接输出是:
1>------ Rebuild All started: Project: CnD_Device, Configuration: Debug Win32 ------
1> JDTC_Message.cpp
1>h:\my.name_local_project\project\emd\ofp\cp_sys\packages\cnd_device\src\project_message.cpp(47): warning C4018: '<' : signed/unsigned mismatch
1>h:\my.name_local_project\project\emd\ofp\cp_sys\packages\cnd_device\src\project_message.cpp(54): warning C4244: '=' : conversion from 'float' to 'UInt32', possible loss of data
1>h:\my.name_local_project\project\emd\ofp\cp_sys\packages\cnd_device\src\project_message.cpp(82): warning C4244: '=' : conversion from 'UInt32' to 'float', possible loss of data
1> ComponentEntryDLL.cpp
1> CnD_Network_Driver.cpp
1> CnD_Message_Handler.cpp
1> CnD_Message_Factory.cpp
1> CnD_Heartbeat_Message.cpp
1> CnD_Device.cpp
1> _WIN32_WINNT not defined. Defaulting to _WIN32_WINNT_MAXVER (see WinSDKVer.h)
1>h:\my.name_local_project\project\emd\ofp\cp_sys\packages\cnd_device\src\cnd_device.cpp(61): warning C4101: 'e' : unreferenced local variable
1>h:\my.name_local_project\project\emd\ofp\cp_sys\packages\cnd_device\src\cnd_device.cpp(120): warning C4101: 'e' : unreferenced local variable
1> MonitoringData.cpp
1> tcp_driver.cpp
1> _WIN32_WINNT not defined. Defaulting to _WIN32_WINNT_MAXVER (see WinSDKVer.h)
1> Generating Code...
1>h:\my.name_local_project\project\emd\ofp\cp_sys\packages\cnd_device\src\cnd_message_factory.cpp(59): warning C4715: 'CnD_Message_Factory::createMessage' : not all control paths return a value
1>
1> Searching libraries
1> Searching C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib\msvcprtd.lib:
1> Searching ..\..\..\..\..\..\Carbon\debug\lib\Carbon.lib:
1> Searching ..\..\..\..\..\..\..\EMD\BUFFER_SDK\Libs\BUFFER_API.lib:
1> Searching ..\..\..\..\..\..\..\EMD\BUFFER_SDK\Libs\BUFFER_Framework.lib:
1> Searching ..\..\..\..\..\..\Messages\Debug\lib\Messages.lib:
1> Searching C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\lib\mfc100d.lib:
1> Searching C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\lib\mfcs100d.lib:
1> Searching C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib\msvcrtd.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\kernel32.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\user32.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\gdi32.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\msimg32.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\comdlg32.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\winspool.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\advapi32.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\shell32.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\comctl32.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\shlwapi.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\uuid.lib:
1> Searching C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\lib\atlsd.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\ole32.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\oleaut32.lib:
1> Searching C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib\MSVCRT.lib:
1> Searching C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib\OLDNAMES.lib:
1> Searching C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\lib\mfc100ud.lib:
1> Searching C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\lib\mfcs100ud.lib:
1> Searching C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib\msvcprt.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\wininet.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\ws2_32.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\mswsock.lib:
1> Searching C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib\msvcprtd.lib:
1> Searching ..\..\..\..\..\..\Carbon\debug\lib\Carbon.lib:
1> Searching ..\..\..\..\..\..\..\EMD\BUFFER_SDK\Libs\BUFFER_API.lib:
1> Searching ..\..\..\..\..\..\..\EMD\BUFFER_SDK\Libs\BUFFER_Framework.lib:
1> Searching ..\..\..\..\..\..\Messages\Debug\lib\Messages.lib:
1> Searching C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\lib\mfc100d.lib:
1> Searching C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\lib\mfcs100d.lib:
1> Searching C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib\msvcrtd.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\kernel32.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\user32.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\gdi32.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\msimg32.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\comdlg32.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\winspool.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\advapi32.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\shell32.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\comctl32.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\shlwapi.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\uuid.lib:
1> Searching C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\lib\atlsd.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\ole32.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\oleaut32.lib:
1> Searching C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib\MSVCRT.lib:
1> Searching C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib\OLDNAMES.lib:
1> Searching C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\lib\mfc100ud.lib:
1> Searching C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\lib\mfcs100ud.lib:
1> Searching C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib\msvcprt.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\wininet.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\ws2_32.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\mswsock.lib:
1> Searching C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib\msvcprtd.lib:
1> Searching ..\..\..\..\..\..\Carbon\debug\lib\Carbon.lib:
1> Searching ..\..\..\..\..\..\..\EMD\BUFFER_SDK\Libs\BUFFER_API.lib:
1> Searching ..\..\..\..\..\..\..\EMD\BUFFER_SDK\Libs\BUFFER_Framework.lib:
1> Searching ..\..\..\..\..\..\Messages\Debug\lib\Messages.lib:
1> Searching C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\lib\mfc100d.lib:
1> Searching C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\lib\mfcs100d.lib:
1> Searching C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib\msvcrtd.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\kernel32.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\user32.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\gdi32.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\msimg32.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\comdlg32.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\winspool.lib:
1>
1> Finished searching libraries
1> Creating library H:\my.name_local_project\project\EMD\OFP\CP_SYS\packages\CnD_Device\build\CnD_Device\Debug\CnD_Device.lib and object H:\my.name_local_project\project\EMD\OFP\CP_SYS\packages\CnD_Device\build\CnD_Device\Debug\CnD_Device.exp
1>
1> Searching libraries
1> Searching C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib\msvcprtd.lib:
1> Searching ..\..\..\..\..\..\Carbon\debug\lib\Carbon.lib:
1> Searching ..\..\..\..\..\..\..\EMD\BUFFER_SDK\Libs\BUFFER_API.lib:
1> Searching ..\..\..\..\..\..\..\EMD\BUFFER_SDK\Libs\BUFFER_Framework.lib:
1> Searching ..\..\..\..\..\..\Messages\Debug\lib\Messages.lib:
1> Searching C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\lib\mfc100d.lib:
1> Searching C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\lib\mfcs100d.lib:
1> Searching C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib\msvcrtd.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\kernel32.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\user32.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\gdi32.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\msimg32.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\comdlg32.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\winspool.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\advapi32.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\shell32.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\comctl32.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\shlwapi.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\uuid.lib:
1> Searching C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\lib\atlsd.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\ole32.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\oleaut32.lib:
1> Searching C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib\MSVCRT.lib:
1> Searching C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib\OLDNAMES.lib:
1> Searching C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\lib\mfc100ud.lib:
1> Searching C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\lib\mfcs100ud.lib:
1> Searching C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib\msvcprt.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\wininet.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\ws2_32.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\mswsock.lib:
1>
1> Finished searching libraries
1>LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
1>LINK : warning LNK4098: defaultlib 'mfc100ud.lib' conflicts with use of other libs; use /NODEFAULTLIB:library
1>LINK : warning LNK4098: defaultlib 'mfcs100ud.lib' conflicts with use of other libs; use /NODEFAULTLIB:library
1>tcp_driver.obj : error LNK2019: unresolved external symbol "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl toString(int)" (?toString@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@Z) referenced in function "protected: bool __thiscall Tcp_Driver::readMessage(void)" (?readMessage@Tcp_Driver@@IAE_NXZ)
1>H:\my.name_local_project\project\EMD\OFP\CP_SYS\packages\CnD_Device\build\CnD_Device\Debug\CnD_Device.dll : fatal error LNK1120: 1 unresolved externals
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========