Mac: Moved from Qt5 back to Qt4: Makefile picking up wrong lib dir; but kit & including seems ok [SOLVED]



  • Hi all,

    I moved from Qt5 to Qt4, but somehow the build system is picking up leftovers from an old setting. As stated above, the kit seems to point to the right place. The qmake part of things seems to show right path according to compile output pane; tons of these:

    @clang -c -pipe -g -arch x86_64 -Wall -W -DQT_SCRIPT_LIB -DQT_SQL_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/local/Qt4.8/mkspecs/unsupported/macx-clang -I../src -I/Library/Frameworks/QtCore.framework/Versions/4/Headers -I/usr/include/QtCore -I/Library/Frameworks/QtNetwork.framework/Versions/4/Headers -I/usr/include/QtNetwork -I/Library/Frameworks/QtGui.framework/Versions/4/Headers -I/usr/include/QtGui -I/Library/Frameworks/QtSql.framework/Versions/4/Headers -I/usr/include/QtSql -I/Library/Frameworks/QtScript.framework/Versions/4/Headers -I/usr/include/QtScript -I/usr/include -I../src/lib -I../src/qtsingleapplication/src -I. -I. -I../src -I. -F/Library/Frameworks ../src/urlhandlercommand/URLHandlerCommand.mm -o URLHandlerCommand.o@

    The Build And Run settings for the current Qt version tells me that qmake is located at /Developer/Tools/Qt/qmake, which is indeed the qt4.x location.

    However, when it comes to linking stuff, the process dies:

    @ld: framework not found QtWidgets@

    Clang is indeed invoked with a wrong path:

    @clang++ -headerpad_max_install_names -arch x86_64 -o ... F/Users/jan/Qt5.0.2/5.0.2/clang_64/lib -framework AppKit -framework QtWidgets -F/Users/jan/Qt5.0.2/5.0.2/clang_64/qtbase/lib -framework QtGui -framework QtCore -framework QtScript -framework QtSql -framework QtNetwork@

    ...which stems from the Makefile:

    @LIBS = $(SUBLIBS) -F/Library/Frameworks -L/Library/Frameworks -lssl -lcrypto -framework Foundation -framework Appkit -framework QtMacExtras -F/Users/jan/Qt5.0.2/5.0.2/clang_64/lib -framework AppKit -framework QtWidgets -F/Users/jan/Qt5.0.2/5.0.2/clang_64/qtbase/lib -framework QtGui -framework QtCore -framework QtScript -framework QtSql -framework QtNetwork
    @

    ...which is all wrong. Qt5.0.2 is long time gone.

    I have looked for a .qmake.cache file (does not exist); I have checked my pro.user files: No mention of Qt5.0.2.

    The relevant part of my .pro file looks like this:

    @QT += core network script sql gui

    greaterThan(QT_MAJOR_VERSION, 4) {
    QT += widgets
    mac: QT+= macextras
    }@

    Does anyone have a clue what's going on? Where does the information about the old Qt5.0.2 come from?


  • Moderators

    Delete the Makefile and then build again.



  • Been there, done that - no luck.



  • Ok, so I

    • added symlinks from the missing dirs to /Library/Frameworks, which shut up the complaints about missing locations.

    • Edited qglobal.h in order to make it shut up about Mac OS 10.9 not being supported

    Didn't help.

    One thing I noticed, though. The linker complains about missing framework "QtWidgets". But, there's no framework called QtWidgets in Qt4. It was only introduced in Qt5 AFAIK.

    The last steps of the make process is as follows:

    @clang++ -c -pipe -O2 -arch x86_64 -Wall -W -DQT_NO_DEBUG_OUTPUT -DQT_NO_DEBUG -DQT_SCRIPT_LIB -DQT_SQL_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_SHARED
    -I/usr/local/Qt4.8/mkspecs/unsupported/macx-clang -I../src
    -I/Library/Frameworks/QtCore.framework/Versions/4/Headers
    -I/usr/include/QtCore -I/Library/Frameworks/QtNetwork.framework/Versions/4/Headers
    -I/usr/include/QtNetwork -I/Library/Frameworks/QtGui.framework/Versions/4/Headers
    -I/usr/include/QtGui -I/Library/Frameworks/QtSql.framework/Versions/4/Headers
    -I/usr/include/QtSql -I/Library/Frameworks/QtScript.framework/Versions/4/Headers
    -I/usr/include/QtScript -I/usr/include
    -I../src/lib -I../src/qtsingleapplication/src -I. -I.
    -I../src -I. -F/Library/Frameworks -o qrc_resources_mac.o qrc_resources_mac.cpp@

    No problems here. The compiler is looking at /Library/Frameworks/*/Versions/4/Headers, which is good.

    Then:

    @clang++ -headerpad_max_install_names -arch x86_64 -o (LOTS OF OBJECT FILES)
    -F/Library/Frameworks -L/Library/Frameworks -lssl -lcrypto -framework Foundation -framework Appkit -framework QtMacExtras
    -F/Users/jan/Qt5.0.2/5.0.2/clang_64/lib -framework AppKit -framework QtWidgets
    -F/Users/jan/Qt5.0.2/5.0.2/clang_64/qtbase/lib -framework QtGui -framework QtCore -framework QtScript -framework QtSql -framework QtNetwork@

    Here's the trouble. WHAT ARE THE LAST TWO LINES DOING HERE?
    I am not including the widgets module, yet it says "-framework QtWidgets" (apart from the wrong path to the framework, of course). Where on earth does the last two lines come from? I've run qmake a thousand times, removed the build dir, rebuilt... nothing changes.

    Does anyone see something obvious that I don't?


  • Lifetime Qt Champion

    Hi,

    Did you delete the .pro.user file from your project ? If not, close Qt Creator, remove it and open your project again. You'll have to configure it again but you won't have the old settings lurking back



  • I tried that as well. No luck. Just did it again, removed everything in my build did, ran qmake, and here's the result in the makefile:

    LIBS = $(SUBLIBS) -F/Library/Frameworks -L/Library/Frameworks -lssl -lcrypto -framework Foundation -framework Appkit -framework QtMacExtras -F/Users/jan/Qt5.0.2/5.0.2/clang_64/lib -framework AppKit -framework QtWidgets -F/Users/jan/Qt5.0.2/5.0.2/clang_64/qtbase/lib -framework QtGui -framework QtCore -framework QtScript -framework QtSql -framework QtNetwork

    The culprits are still there. I'm looking at the right directory; I'm manually removing the files, and I see the makefile appear when I run qmake.

    Edit: All versions of the pro.user files was removed before this.


  • Lifetime Qt Champion

    What is the path of the qmake that is used with your current kit ?



  • /Developer/Tools/Qt/qmake, which is indeed the qt4.x location

    From the "Details" pane in Preferences->Build & Run ->Qt Versions:

    Name:
    Qt 4.8.5 (Tools)
    ABI:
    x86-macos-generic-mach_o-64bit
    Source:
    /
    mkspec:
    macx-g++
    qmake:
    /Developer/Tools/Qt/qmake
    Default:
    debug
    Version:
    4.8.5
    QMAKE_VERSION
    2.01a
    QT_HOST_BINS
    /Developer/Tools/Qt
    QT_HOST_DATA
    /usr/local/Qt4.8
    QT_HOST_PREFIX
    /
    QT_INSTALL_BINS
    /Developer/Tools/Qt
    QT_INSTALL_CONFIGURATION
    /Library/Preferences/Qt
    QT_INSTALL_DATA
    /usr/local/Qt4.8
    QT_INSTALL_DEMOS
    /Developer/Examples/Qt/Demos
    QT_INSTALL_DOCS
    /Developer/Documentation/Qt
    QT_INSTALL_EXAMPLES
    /Developer/Examples/Qt/
    QT_INSTALL_HEADERS
    /usr/include
    QT_INSTALL_IMPORTS
    /Developer/Applications/Qt/imports
    QT_INSTALL_LIBS
    /Library/Frameworks
    QT_INSTALL_PLUGINS
    /Developer/Applications/Qt/plugins
    QT_INSTALL_PREFIX
    /
    QT_INSTALL_TRANSLATIONS
    /Developer/Applications/Qt/translations
    QT_VERSION
    4.8.5



  • I've run a find . -type f -exec grep -l "5.0.2" {} + in my project directory; I find no instances. I did the same in /usr/local/Qt4.8, where the makespecs are located. Same.


  • Moderators

    What is the output of:
    @
    qmake -v
    @



  • @~/Library/Preferences > /Developer/Tools/Qt/qmake -v
    QMake version 2.01a
    Using Qt version 4.8.5 in /Library/Frameworks@

    (That's the qmake I'm pointing to in my Creator settings as well)


  • Moderators

    This is all very weird. Every part of configuration you mention looks correct.



  • To say the least. And very frustrating at my end.


  • Lifetime Qt Champion

    Can you do a build from the command line ?



  • Never done that before. Copied the stuff from build settings in Creator, ran

    @/Developer/Tools/Qt/qmake /Users/jan/Dev/TubulatorQt_4.8/src/TubulatorQt.pro -r -spec macx-g++ CONFIG+=x86_64@

    which still generates the same #### line in the makefile:
    @LIBS = $(SUBLIBS) -F/Library/Frameworks -L/Library/Frameworks -lssl -lcrypto -framework Foundation -framework Appkit -framework QtMacExtras -F/Users/jan/Qt5.0.2/5.0.2/clang_64/lib -framework AppKit -framework QtWidgets -F/Users/jan/Qt5.0.2/5.0.2/clang_64/qtbase/lib -framework QtGui -framework QtCore -framework QtScript -framework QtSql -framework QtNetwork @


  • Lifetime Qt Champion

    looks like your are running qmake from 5.0.2 Oo

    Do you have any Q environment variable set in your console ?



  • But two posts above, qmake -v tells me it's 4.8.5. Same binary location.

    Environment variables: Not that I know of. What would I check for?


  • Moderators

    This could give you some nice results:
    @
    env | grep Q
    @



  • @> env | grep Q
    OLDPWD=/Users/jan/Dev/TubulatorQt_4.8
    PWD=/Users/jan/Dev/TubulatorQt_4.8/build-TubulatorQt-Qt_4_8_Desktop-Debug@


  • Moderators

    I'm out of ideas ;)

    Oh wait, just one more thing: see if you have a file named qt.conf anywhere on your OS. You can also take a look at Qt makespecs, maybe there are some problems there, but that would be insane.



  • Thanks anyway ;-)

    Lots of qt.conf files, but none global (belongs to projects), and all only specifiy the plugins path.

    I deleted the make specs before installing anew yesterday, so I doub't there'll be any references to an old Qt install location there.



  • Tried installing and uninstalling 5.0.2. As I suspected - no luck after that either.

    Am I really forced to move to another computer?


  • Lifetime Qt Champion

    What does a

    @find / -name qmake@

    return ?



  • Fixed it! I took a long, hard look at my .pro file, starting commenting things out and running quake to how it affected the Makefile.

    The culprit was this line:

    @LIBS += -framework Foundation -framework Appkit -framework QtMacExtras@

    First off, QtMacExtras does not exist as a separate module in Qt 4 (AFAIK), so away it went. That wixed the complaint about missing QtWidgets module and include of 5.0.2 stuff.

    What I still don't understand is

    1. Why I wasn't getting a complaint about an unknown module instead of a reference to Qt5.0.2 stuff.

    2. How the system would pick Qt5.0.2 as a candidate of where the module would be located. I have searched my system intensively, and I find NO references to 5.0.2. I would understand refs to 5.2.0, because that's installed and being used - but not 5.0.2.


  • Lifetime Qt Champion

    You're correct, QtMacExtras is new for Qt 5.

    1. you set the framework in LIBS, not the module QT, so it links directly

    2. Did you build QtMacExtras with Qt 5.0.2 ?



    1. Got it, thanks!

    2. I do recall building Extras. There's a QtMacExtras.framework in my /Library/Frameworks folder, but it says 5.1 in the Info.plist file. Not sure if that can be trusted though. Is the Qt framework location baked into the .framework bundle? That has to be the only place the Qt install location can be picked up, right?


  • Lifetime Qt Champion

    1. You're welcome !

    2. You could have a look at the library in the framework with otool -L to see with what it's linked


Log in to reply
 

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