问题
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:
- 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)
- Copy mspdb*.dll(from first directory) to directory with library
- Open cmd.exe in library directory
- 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)
- 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