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?
Asked
Active
Viewed 6,620 times
2 Answers
7
- 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.

Stuti Rastogi
- 1,162
- 2
- 16
- 26
1
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.

Mario
- 35,726
- 5
- 62
- 78
-
This post seems to suggest it is possible to use MinGW compiled libraries in Visual Studio: http://stackoverflow.com/questions/9673252/visual-studio-2010-and-mingw But it apparently doesn't tell the whole story, because I've tried to duplicate the steps he mentioned and I still have linker errors. – duggulous Jan 28 '14 at 17:45
-
There's no way from MinGW's .a files to MSVC's .lib files as far as I know. MinGW/GCC is a lot more tolerant in these regards. Which steps did you try to duplicate? – Mario Jan 29 '14 at 08:47
-
I copied the .a files into the project and added them to the configuration under Linker->Input->Additional Dependencies – duggulous Jan 29 '14 at 16:36
-
You can't do that. As I mentioned above, Visual Studio (or more specific, Microsoft's linker) won't be able to read typical .a files. You'll need to obtain a precompiled library for MSVC or compile it yourself. As far as I know, MinGW has a command line switch to create compatible libraries (i.e. different binary format), but that's not the default. – Mario Jan 30 '14 at 09:17
-
2In fact, you can do that. As it turns out, the only reason I was encountering linker errors is because the .a libs I was using were compiled for 64-bit, while my project is 32-bit. I don't know if MSVC's linker understands all .a files, or just some, but at least in some cases it is possible. – duggulous Feb 03 '14 at 19:29
-
That sounds interesting! From my experience, the formats were different, but that might have changed. – Mario Feb 03 '14 at 22:20