How to link against .a files in Visual Studio 2012?

吃可爱长大的小学妹 提交于 2020-01-16 01:12:07

问题


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.



来源:https://stackoverflow.com/questions/21393942/how-to-link-against-a-files-in-visual-studio-2012

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