I am developing a library which is intended to work on all platforms (linux, mac, and windows). This library is based on Qt, which is a cross platform User interface library. I am developing this library using a Mac. The current build that I develop is a static library (.a), which works on Linux and Mac. Will this .a library
also work in Windows (let's say using Visual Studio), or do I have to create a separate library type for that? And if yes, how can I create the windows static library from my Mac? For your information, I am using QtCreator IDE to create the static library. A simple guideline / code examples / useful links would be really helpful.
1 Answers
First, if you want to write crossplatform software, you'll need to test it on the platforms you target. If you don't have a Windows computer to test on, then you can kiss Windows compatibility goodbye.
Second, Windows does have static libraries, but they use the .lib
extension instead of .a
. Serious build systems like qmake should be able to handle this. If you tell it to generate a static library, it will generate a .lib on Windows, and .a on other platforms.
Of course, for it to work with anything, it'll have to be compiled with the same compiler as is used for the program it is being linked into.
If you generate the .lib file with GCC (or MinGW, the Windows port of GCC), then it can't be linked into a Visual Studio project, because they use different ABIs, different standard library implementations and different runtimes (and because the format of MSVC .lib files is undocumented and changes between compiler versions).
However, since qmake works with most compilers, there should be no problem in generating the .lib file with Visual Studio.