Unresolved external symbol when linking my library

血红的双手。 提交于 2019-12-24 09:59:57

问题


I've compiled my own library file(.lib) with VS2010, but when I try to reference it like

#pragma comment(lib,"path/to/lib.lib")

I keep getting unresolved external symbols...What am I doing wrong? the #pragma comment(lib, "*.lib") worked for any library so far, and I also tried linking it under settings, no succes.


回答1:


1) Open a VS command console (Tools/Visual Studio Command Prompt).

2) Use cd command to change to the directory containing the library in question.

3) Enter:

dumpbin /all my_lib_name.lib > lib.txt

replacing my_lib_name.lib with the name of your library. (You'll want to write the output to a text file lib.txt for large libraries)

4) Open this newly created lib.txt to view the contents of the library. More details can be found here.




回答2:


  1. Open Two directories.
    • First contained library that fails
    • Second contains binary directory with compilator (For me its C:\Program Files\Microsoft Visual Studio 9.0\VC)
  2. Copy mspdb*.dll(from first directory) to directory with library
  3. Open cmd.exe in library directory
  4. Write "%FIRST_DIRECTORY/bin/dumpbin.exe" /ALL library.lib > lib.txt (For example i am writed "C:\Program Files\Microsoft Visual Studio 9.0\VC\bin\dumpbin.exe" /ALL MyTestLibrary.lib > lib.txt)
  5. Search for methods that you want(by class name or method name)

If you dont found - developer dont writed it. OR that methods implementations are inline

If second - you should told IDE whereis source. BTW remember, no methods in library-compiling project, that accessable through user headers could be inline. All you can do to optimise speed - fastcall.



来源:https://stackoverflow.com/questions/11737017/unresolved-external-symbol-when-linking-my-library

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!