Important: Please read the Qt Code of Conduct -

Using same "Qt include files set" for window and linux (Qt 4.8.0)

  • Hello,

    I am having an application which is multi-platform, windows and linux.
    I have built Qt 4.8.0 on windows and linux, and placed the build output (lib and bin) in appropriate folder structure. As far as Qt's include folder is concerned, I am using a common folder for Windows and linux.

    Thus to sum up, when I am building my application on widows or linux, I am using a common Qt's include folder.

    Is this allowed, since it is causing problem at run time ?
    Is the include folder set for windows and linux different ?

    Any help is greatly appreciated.


  • For include files, it's OK. But you have to make sure that libs don't conflict (because they hold same names in linux and windows usually). In general, you have to have a folder of libs for linux and another for windows, and then in your qmake, use the right prefix for the right operating system. Here's an example

    win32:DEPENDPATH += ../../libsrc/gsl/gsl-1.8-mvsc
    win32:DEPENDPATH += ../../libsrc/gsl/gsl-1.8-mvsc/lib
    win32:INCLUDEPATH += ../../libsrc/gsl/gsl-1.8-mvsc/include

    win32:LIBS += -L../../libsrc/gsl/gsl-1.8-mvsc/lib
    win32:LIBS += -llibgsl
    win32:LIBS += -llibgslcblas

    win32:CXXFLAGS += /O2

    unix:LIBS += -lrt
    unix:LIBS += -lm
    unix:LIBS += -lpthread
    unix:LIBS += -lgsl
    unix:LIBS += -lgslcblas

  • Moderators

    Most headers are bound to be identical, you are right there, but there must be some place where all the information queried by "configure" needs to hit the code. Usually that happens by configure writing a header file, defining/undefining a lot of macros. These files that are then included all over the place, modifying the code visible to any one compiler run.

    I have to admit that I never bothered to find out how Qt actually does this (it does pass some of the configure information using the compiler command line, but not sure whether that is done for everything).

    Anyway: As long as you manage to keep those configurations that are picked up by the headers separate you should be fine... the easiest way to do so is of course to have separate sets of header files for each built of Qt;-)

  • Thanks a lot for replying.

    To add to above information, here is what I get when I exchange header files on windows and linux.

    When I use the header files on linux, which are generated on windows, I do not get build errors but, i get run time crash

    When I use the header files on windows, which are generated on linux, I get following link errors

    error LNK2001: unresolved external symbol "private: static struct QString::Data QString::shared_null" (?shared_null@QString@@0UData@1@A)

Log in to reply