0

i am trying to import functions from a self built dll the function in dll is:

std::string stringFunc(std::string str) {
         return str;
  }

in another project I try to call this function, Visual Studio shows error:

Error   LNK2019 unresolved external symbol "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl stringFunc(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?stringFunc@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@@Z) referenced in function main    YouCanDoAnythingHere    C:\Users\langj\source\repos\YouCanDoAnythingHere\YouCanDoAnythingHere\Source.obj    1   

Where is the problem?

benkyou
  • 45
  • 9
  • Many things could be wrong. Perhaps you didn't export the function from the DLL. Perhaps you didn't link with the import LIB. – Raymond Chen Jun 26 '18 at 04:52
  • You should export that function. Use ``__declspec(dllexport)`` to export that function and then use ``__declspec(dllimport)`` to import that function from another project – Asesh Jun 26 '18 at 04:54
  • @Asesh your suggestion works! thanks – benkyou Jun 26 '18 at 07:51

0 Answers0