Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error LNK2019: unresolved external symbol "toString(int)"

Environment: Windows XP. Visual Studios 2010. Language - C++.

I have run into the following link error & have run out of ideas how to fix this problem. I have a project (CnD Device) which links to 2 projects (Messages & Carbon) controlled by my group. I have tried to search for project properties between the 3 projects

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)

I believe this problem is because I am not linking to the string which is in Standard C++ Library. I have scanned my properties list over and over again. Below is some of the properties I believe are critical for this problem.

CnD Device property information:

  1. Configuration Type Dynamic Library .dll
  2. Use of MFC Use MFC in a Shared DLL
  3. Use of ALT Not Using ALT
  4. Character Set Use Multi-Byte Character Set
  5. Runtime Library Multi-threaded DLL (/MD)
  6. Additional Dependencies msvcprtd.lib, Carbon.lib, BUFFER_API.lib, BUFFER_FRAMEWORK.lib, Messages.lib
  7. Ignore All Default Libraries No

Messages Properties Information:

  1. Configuration Type Static Library (.lib)
  2. Use of MFC Use MFC in a Shared DLL
  3. Use of ALT Not Using ALT
  4. Character Set Use Unicode Character Set
  5. Runtime Library Multi-threaded DLL (/MD)
  6. Additional Dependencies
  7. Link Library Dependencies No

Carbon Properties Information:

  1. Configuration Type Static Library (.lib)
  2. Use of MFC Use MFC in a Shared DLL
  3. Use of ALT Not Using ALT
  4. Character Set Use Unicode Character Set
  5. Runtime Library Multi-threaded DLL (/MD)
  6. Link Library Dependencies No

My CnD link output is:

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 ==========
like image 613
Kat Avatar asked Oct 10 '22 16:10

Kat


1 Answers

I found my problem. I would delete this; however, I found this link error is common but never have good general solutions - besides project property changes.

The source of my problem: Carbon and Messages defined Int32 as a long.

CnD defined Int32 as an int.

The unresolved external symbol causing the error was

extern std::string toString(Int32 v);

Thus CnD was expecting a different function than what Carbon and Messages defined.

like image 108
Kat Avatar answered Oct 13 '22 11:10

Kat