#56 Including Qt Libraries?

Nick Wallin

Hello, I am trying to cross-compile (on Linux for Windows 32-bit) a simple Qt program. Just one main.cpp file that includes QTime. Here is my Makefile:


main: main.cpp Makefile
$(CCPATH)$(PREFIX)g++ -o main main.cpp -I$(QTDIR)/include -I$(QTDIR)/include/Qt -I$(QTDIR)/include/QtCore -L$(QTDIR)/lib -lQtCore -pipe -D_REENTRANT -DQT_CORE_LIB

Now, if I switch the comments on CCPATH and PREFIX, making them both be blank, it compiles and works fine. (In other words, it compiles fine on Linux for Linux.) However, as it is shown above, I get the error:

/usr/mw32/bin/../lib/gcc/i686-w64-mingw32/4.5.4/../../../../i686-w64-mingw32/bin/ld: cannot find -lQtCore

In case you cannot see because of this horrible font, the -I$(QTCORE) are all with a capital i, and the -lQtCore has a lowercase L.

Any reason why mingw-w64 cannot build my program, but regular g++ can?

Thanks a bunch!


  • Jonathan Yong

    Jonathan Yong - 2011-06-21

    Are you sure there is a libQtCore.dll.a or libQtCore.a?

    It looks like you are trying to use libraries compiled for Linux with mingw, it won't work.

  • Nick Wallin

    Nick Wallin - 2011-06-21

    So I must also cross compile (for the target Windows type) any libraries I want to use? Okay, I was not aware of this. Thanks.

  • Jonathan Yong

    Jonathan Yong - 2011-06-21

    Yes, for every program and library.

    Take note that regular mingw.org offerings and mingw-w64 may not be ABI compatible, so avoid precompiled libraries if possible.

  • Jonathan Yong

    Jonathan Yong - 2011-06-21
    • status: open --> closed-invalid

Log in to post a comment.