Creating Libraries on Windows (for Linux Programmers)



  • Hi

    I have a project that needs to run on Windows. The caveat is that I'm a Linux guy. The end project will be on Linux but in the interim, it needs to run on both with hopefully no hoops to jump through. Most of my code compiled and ran fine until I made one of my classes a library.

    I compile the project on Windows, and it creates working_dir/debug/MyLibrary.dll. It makes no other file (no .a, not .lib). I'd like these to be loaded statically... doesn't Windows need the .a file for that?

    I am using mingw which comes w/ QtCreator. My firm has Visual Studio but that seems like overkill for this issue. All of my work is done on the Linux side. I'm only pulling the code in and compiling on Windows. The only reason I'm using QtCreator to compile is that it seemed like the easiest way to get qmake going out of the box. I'm lost on a Windows "terminal" to say the least.


  • Moderators

    If it creates a .dll then it's configured to be built as a dynamic library (dll). If the project is qmake based then you need to add this to the .pro file:
    @
    CONFIG += staticlib
    @
    and re-run qmake. This will configure your project to generate a .lib file (or .a in case of MinGW) that you can statically link to.



  • Thanks, Chris. That worked. I got the static lib, and linking it seemed to work. It may or may not have opened me up to something else though. Before I used any of my own libraries, I was able to compile and run a simple program. After this last compile, it tells me it's missing QtCored.dll. I can probably sort that out though.

    EDIT: Which I did. Thanks again.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.