Qt App built in Mac environment, deploy to Windows
I built my Qt app in Mac OSX and I've been compiling it fine in this environment. I wanted to make the app compatible with Windows, so I copied all the source files and started working on a Windows XP machine.
My source files include two statically linked libraries, "libcp.a" and "libgsl.a" and I also copied all the necessary header files.
I'm confused about what I need to do with these libraries now that I'm on a Windows machine. I can't add them to my .pro file in the same manner I did in OSX since QtCreator in this environment seems to only accept libraries with the .lib extension.
Do I need to rebuild or modify my libraries somehow? I've been poking around online, and from what I've read, Qt is cross-platform, and should therefore be able to compile source files on different machines without needing to modify these source files. What am I missing? If someone with more experience could assist me, that would be greatly appreciated!
Thanks so much.
Are those two libraries created from your sources, or are 3rd party libraries your application is linking to? From the names, I'd say it's the latter case. Therefore, you have to find those libraries as static libraries for Windows (eventually: compile them by yourself).
The fact that Qt is a cross platform toolkit doens't imply that the libraries you use are cross platform as well :-)
You will have to compile the libcp and libgsl libraries on the windows machine.
Qt being cross platform means that the source code will compile on every supported platform: code once, compile everywhere. It does not mean that a once compiled binary will on every platform (that would be "compile once, run everywhere").
Thanks for clearing that up for me!
Moving forward with your suggestion to rebuild the libraries in Windows, I've been trying things all day with no luck so far. Here's what I've done:
So "libcp.a" was a library that I created using the gcc compiler while on my Mac machine.
Moving over to Windows, (I think) I was able to recompile the library using Visual Studio C++. I now have a library called "libcp.lib" and I've linked it in my Qt project file.
But I'm still having trouble with the other library, called "libgsl". As you guessed, this is a 3rd party library- the GNU Scientific Library, which I downloaded from their site. Since QtCreator in Windows uses the MinGW compiler, I assumed this is what I needed to use when I installed the GNU Scientific Library. I completed the installation, and then I went through the installed files looking for something with a ".lib" extension (something like "libgsl.lib"). All I find are archive files (like "libgsl.a") and something called "libgsl.dll.a"
I was under the impression that if I installed GSL using the MinGW compiler on my Windows computer, that I would end up with a static library which I would then be able to link to my Qt app in QtCreator.
I also tried copying "libgsl.a" to my working directory and then adding the following line to the .pro file:
@LIBS += -L$$PWD/ -lgsl@
This didn't work either. It seems the ".a" extension libraries are not recognized in Windows? Do you have any ideas for what I can try next?
Thanks in advance
You must not mix compilers. Never ever. Neither one version of Visual Studio with another, nor Visual Studio with MinGW. You must stick to one toolchain! For the reasons have a look on "Application Binary Interface (ABI)":http://en.wikipedia.org/wiki/Application_binary_interface and "name mangling":http://en.wikipedia.org/wiki/Name_mangling.
So, as you switched to Visual Studio, you must recompile GSL with that too. I never used that myself and don't know if that's an easy task.