0

I have a dll called GMC which includes another dll called nlopt (https://nlopt.readthedocs.io/en/latest/NLopt_on_Windows/). I can create a console, add GMC to the project, and run the program with out any issues. However, when I try to add GMC to a specific project, taking all the same steps that I did to add it to the console I made(include header file, add reference to dll, additional include directories) I get these link errors

I did not have this issue when I was working in VS2017. I have had to change to VS2013 for reasons not important to this question. Originally I thought that these link error were caused because I was using DLL's created from VS2017 in VS2013. However after recreating GMC and nlopt in VS2013 and adding them back into my project, the link errors remain.

I have also gone through and compared all of the project properties for the project that giving me the link errors with the projects that are working and have found no differences (Runtime Library is Multi-threaded Debug DLL (/MDd) for all).

errors:

Error   57  error LNK2019: unresolved external symbol __imp___hypot referenced in function _hypot   C:\Users\h6565169\Documents\tps_trunk\G2GsiBridge\Development\Gsi\Gsi.obj   Gsi
Error   58  error LNK2019: unresolved external symbol "__declspec(dllimport) void __cdecl std::_Debug_message(wchar_t const *,wchar_t const *,unsigned int)" (__imp_?_Debug_message@std@@YAXPB_W0I@Z) referenced in function "void __cdecl std::_Debug_pointer<char>(char const *,wchar_t const *,unsigned int)" (??$_Debug_pointer@D@std@@YAXPBDPB_WI@Z)   C:\Users\h6565169\Documents\tps_trunk\G2GsiBridge\Development\Gsi\Gsi.obj   Gsi
Error   59  error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall std::_Container_base12::_Container_base12(void)" (__imp_??0_Container_base12@std@@QAE@XZ) referenced in function "public: __thiscall std::_String_val<struct std::_Simple_types<char> >::_String_val<struct std::_Simple_types<char> >(void)" (??0?$_String_val@U?$_Simple_types@D@std@@@std@@QAE@XZ)   C:\Users\h6565169\Documents\tps_trunk\G2GsiBridge\Development\Gsi\Gsi.obj   Gsi
Error   60  error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall std::_Container_base12::~_Container_base12(void)" (__imp_??1_Container_base12@std@@QAE@XZ) referenced in function "public: __thiscall std::_String_val<struct std::_Simple_types<char> >::~_String_val<struct std::_Simple_types<char> >(void)" (??1?$_String_val@U?$_Simple_types@D@std@@@std@@QAE@XZ) C:\Users\h6565169\Documents\tps_trunk\G2GsiBridge\Development\Gsi\Gsi.obj   Gsi
Error   61  error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall std::_Container_base12::_Orphan_all(void)" (__imp_?_Orphan_all@_Container_base12@std@@QAEXXZ) referenced in function "public: void __thiscall std::_String_alloc<0,struct std::_String_base_types<char,class std::allocator<char> > >::_Free_proxy(void)" (?_Free_proxy@?$_String_alloc@$0A@U?$_String_base_types@DV?$allocator@D@std@@@std@@@std@@QAEXXZ) C:\Users\h6565169\Documents\tps_trunk\G2GsiBridge\Development\Gsi\Gsi.obj   Gsi
Error   62  error LNK2019: unresolved external symbol "__declspec(dllimport) void __cdecl std::_Xbad_alloc(void)" (__imp_?_Xbad_alloc@std@@YAXXZ) referenced in function "char * __cdecl std::_Allocate<char>(unsigned int,char *)" (??$_Allocate@D@std@@YAPADIPAD@Z)   C:\Users\h6565169\Documents\tps_trunk\G2GsiBridge\Development\Gsi\Gsi.obj   Gsi
Error   63  error LNK2019: unresolved external symbol "__declspec(dllimport) void __cdecl std::_Xlength_error(char const *)" (__imp_?_Xlength_error@std@@YAXPBD@Z) referenced in function "public: void __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::_Xlen(void)const " (?_Xlen@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEXXZ)   C:\Users\h6565169\Documents\tps_trunk\G2GsiBridge\Development\Gsi\Gsi.obj   Gsi
Error   64  error LNK2019: unresolved external symbol "__declspec(dllimport) void __cdecl std::_Xout_of_range(char const *)" (__imp_?_Xout_of_range@std@@YAXPBD@Z) referenced in function "public: void __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::_Xran(void)const " (?_Xran@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEXXZ)   C:\Users\h6565169\Documents\tps_trunk\G2GsiBridge\Development\Gsi\Gsi.obj   Gsi
Error   65  error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall std::locale::id::id(unsigned int)" (__imp_??0id@locale@std@@QAE@I@Z) referenced in function "void __cdecl `dynamic initializer for 'public: static class std::locale::id std::num_put<char,class std::back_insert_iterator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > >::id''(void)" (??__E?id@?$num_put@DV?$back_insert_iterator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@std@@@std@@2V0locale@2@A@@YAXXZ)    C:\Users\h6565169\Documents\tps_trunk\G2GsiBridge\Development\Gsi\Gsi.obj   Gsi
Error   66  error LNK2019: unresolved external symbol "__declspec(dllimport) char const * __cdecl std::_Syserror_map(int)" (__imp_?_Syserror_map@std@@YAPBDH@Z) referenced in function "public: virtual class std::error_condition __thiscall std::_System_error_category::default_error_condition(int)const " (?default_error_condition@_System_error_category@std@@UBE?AVerror_condition@2@H@Z)   C:\Users\h6565169\Documents\tps_trunk\G2GsiBridge\Development\Gsi\Gsi.obj   Gsi
Error   67  error LNK2019: unresolved external symbol "__declspec(dllimport) char const * __cdecl std::_Winerror_map(int)" (__imp_?_Winerror_map@std@@YAPBDH@Z) referenced in function "public: virtual class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall std::_System_error_category::message(int)const " (?message@_System_error_category@std@@UBE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@H@Z)  C:\Users\h6565169\Documents\tps_trunk\G2GsiBridge\Development\Gsi\Gsi.obj   Gsi
Error   68  error LNK1120: 11 unresolved externals  C:\Users\h6565169\Documents\tps_trunk\G2GsiBridge\Development\Debug\Gsi.exe Gsi
drescherjm
  • 10,365
  • 5
  • 44
  • 64
Connor Mote
  • 225
  • 3
  • 11
  • Your question really not answerable unless you provide specific details (exact text error messages).. Even then it may be difficult. If the environment is difficult to setup it will be unlikely anyone will spend the time to reproduce. – drescherjm Jul 16 '18 at 18:40
  • ***add reference to dll*** Normally you add a setting in your projects linker settings to link to the import library in your linker settings. That is if this is a native `c++` application and not .NET / clr. – drescherjm Jul 16 '18 at 18:43
  • @drescherjm What details do would you need? Based on the link errors and the other details I provided do you have any guesses of where I should look for the causes of the errors? thanks – Connor Mote Jul 16 '18 at 18:45
  • Start with the error messages. Does any of them say it can't open the import library (whatever that file name is) for your dll? – drescherjm Jul 16 '18 at 18:45
  • @drescherjm no, have you opened the snapshot of the link errors in my post? – Connor Mote Jul 16 '18 at 18:50
  • No I did not even notice it. Please don't post pictures of text. Instead copy the error messages as text from the Output tab of Visual Studio and put the text into your question. – drescherjm Jul 16 '18 at 18:52
  • hypot does sound like something that would be in my nlopt dll though – Connor Mote Jul 16 '18 at 18:52
  • How did you create the dll for the older version of Visual Studio? Maybe you missed enabling a macro that switches from dllexport to dllimport depending if you are building the dll or using the dll. – drescherjm Jul 16 '18 at 18:54
  • @Connor _"no, have you opened the snapshot of the link errors in my post?"_ You don't provide _snapshots_ or other external links (rather than decoration) to your questions please. [Post such information as text](https://stackoverflow.com/posts/51368152/edit) (and thus searchable for future reference) in your question. Thank you. – πάντα ῥεῖ Jul 16 '18 at 18:58
  • @drescherjm I simply rebuilt a working project in VS2013 that contained the dll's. Unless there is a default macro that does that, I doubt that is the case since all the other projects work fine. – Connor Mote Jul 16 '18 at 19:09
  • 2
    These symbols are defined in the standard C++ library implementation. Lots of changes in that library due to the C++1x improvements, you must find a DLL version that is compatible with VS2013 or rebuild it from source. – Hans Passant Jul 16 '18 at 19:13
  • @HansPassant I'm slightly confused. A DLL version of what? The DLL's I added would seem compatible since I can add them to other VS2013 projects and they work fine. – Connor Mote Jul 16 '18 at 21:00
  • Oops, I suppose it is a static library. Gsi.cpp needs to be recompiled. – Hans Passant Jul 16 '18 at 21:05
  • @HansPassant recompiling Gsi.cpp gives the same link errors – Connor Mote Jul 16 '18 at 21:12
  • ***I can add them to other VS2013 projects and they work fine*** This still could be Undefined Behavior. – drescherjm Jul 16 '18 at 21:42

0 Answers0