Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

[SEMI-SOLVED]Linking problem with QT Creator on Mac OS X (boost regex)



  • Hello

    I've added boost_regex.a to my project in qt creator (using the add library... context menu command) but when I run the app it crashes failing to load it and complaining about the dylib instead.
    Here is the relevant part of the generated .pro file:

    INCLUDEPATH += /boost/148/include

    macx: LIBS += -L$$PWD/../../../../../boost/148/lib/ -lboost_regex

    INCLUDEPATH += $$PWD/../../../../../boost/148/include
    DEPENDPATH += $$PWD/../../../../../boost/148/include

    macx: PRE_TARGETDEPS += $$PWD/../../../../../boost/148/lib/libboost_regex.a

    I recall that on osx you don't specify the libs using the -l flag but simply adding them as arguments to the compiler, but qt generates a makefile where this rule is not followed:

    LIBS = $(SUBLIBS) -F/cpplibsQtSDK/Desktop/Qt/4.8.1/gcc/lib -L/cpplibsQtSDK/Desktop/Qt/4.8.1/gcc/lib -L/Users/davidborsodi/Documents/workspace_cpp/sc_leveleditor/../../../../../boost/148/lib/ -lboost_regex -framework QtOpenGL -L/usr/local/pgsql/lib -L/tmp/qt-stuff-85167/source/qt-everywhere-opensource-src-4.8.1/Desktop/Qt/4.8.1/gcc/lib -F/tmp/qt-stuff-85167/source/qt-everywhere-opensource-src-4.8.1/Desktop/Qt/4.8.1/gcc/lib -framework QtGui -framework QtCore -framework OpenGL -framework AGL

    How should I modify the pro file to get qt correctly link the libs?

    thanks
    david



  • I've found one solution for dynamic linking combining the instructions of these two so posts:
    http://stackoverflow.com/questions/3729810/boost-regex-not-playing-welll-with-snow-leopard
    http://stackoverflow.com/questions/135688/setting-environment-variables-in-os-x
    though I haven't tried it for static but I'm content with this for now...


Log in to reply