I have some static libraries in the form of .a files, and accompanying header (.h) files. How can I tell the linker Visual Studio 2012 Windows Desktop Express to reference these files so that I don't get "unresolved external symbol" errors when I try to build?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
- Include the .h header files, and make sure they are present in your project
- Go to Project Properties > Configuration Properties > C/C++ > General > Additional Include Directories and add the path to the include directory where your header files can be found
- Go to Project Properties > Configuration Properties > Linker > General > Additional Library Directories and add the path to the lib directory where your .a files can be found
- Go to Project Properties > Configuration Properties > Linker > Input > Additional Dependencies and add the .a file accurately
Apart from this make sure you are in the correct configuration platform while building (x86 vs x64) and it is same as the one your library uses.
回答2:
As far as I'm aware, you can't. They're usually using a different internal binary format the linker won't be able to understand. In a similar way, MinGW won't be able to use Visual Studio's lib files (except when using an additional tool to convert them).
You'll have to recompile the library from source or obtain library files that are compatible with Visual Studio.