Search code examples
macosqtmakefileqt4

Library not found for -lQtCore


I am attempting to compile a large project from school onto my own machine (Mac OS X 10.8.4). Thankfully, I've managed to figure out most of the native dependency/library locations and have modified the makefiles accordingly.

I am getting stuck, however, with the following error:

ld: library not found for -lQtCore

Within the makefile, the lQtCore is part of this line:

QT_LIBS = -L$(QT4DIR)/lib -lQtCore -lQtGui -lQtOpenGL

The QT4DIR variable should be correct; it represents this directory location:

/sw/lib/qt4-mac/

When I go into /sw/lib/qt4-mac/ and then into lib from there, I have these (sorry for poor alignment):

Qt3Support.framework             QtSql.framework
Qt3Support.la                    QtSql.la
Qt3Support_debug.la              QtSql_debug.la
QtAssistant.framework            QtSvg.framework
QtCore.framework                 QtSvg.la
QtCore.la                        QtSvg_debug.la
QtCore_debug.la                  QtTest.framework
QtDBus.framework                 QtTest.la
QtDBus.la                        QtTest_debug.la
QtDBus_debug.la                  QtWebKit.framework
QtDeclarative.framework          QtXml.framework
QtDeclarative.la                 QtXml.la
QtDeclarative_debug.la           QtXmlPatterns.framework
QtDesigner.framework             QtXmlPatterns.la
QtDesignerComponents.framework   QtXmlPatterns_debug.la
QtGui.framework                  QtXml_debug.la
QtGui.la                         libQtCLucene.4.7.3.dylib
QtGui_debug.la                   libQtCLucene.4.7.dylib
QtHelp.framework                 libQtCLucene.4.dylib
QtHelp.la                        libQtCLucene.dylib
QtHelp_debug.la                  libQtCLucene.la
QtMultimedia.framework           libQtCLucene.prl
QtMultimedia.la                  libQtCLucene_debug.4.7.3.dylib
QtMultimedia_debug.la            libQtCLucene_debug.4.7.dylib
QtNetwork.framework              libQtCLucene_debug.4.dylib
QtNetwork.la                     libQtCLucene_debug.dylib
QtNetwork_debug.la               libQtCLucene_debug.la
QtOpenGL.framework               libQtCLucene_debug.prl
QtOpenGL.la                      libQtUiTools.a
QtOpenGL_debug.la                libQtUiTools.prl
QtScript.framework               libQtUiTools_debug.a
QtScript.la                      libQtUiTools_debug.prl
QtScriptTools.framework          phonon.framework
QtScriptTools.la                 phononexperimental.framework
QtScriptTools_debug.la           pkgconfig
QtScript_debug.la

I'm not an expert on this stuff, but it looks like I need to have something that is just called QtOpenGL, for example, and not just QtOpenGL.framework, QtOpenGL.la, etc.

To get the (presumably) missing link, do I need to do something within Qt to produce these files, or just give different information to the makefile because they're somewhere else?


Solution

  • So the linker is looking for a library file (lib) aka an archive file. Like a .a or a .lib.

    http://doc.qt.io/qt-4.8/qmake-variable-reference.html#libs

    The -lgenericLibraryName command should look for:

    genericLibraryName.a
    genericLibraryName.lib
    genericLibraryName<num>.lib (where <num> is the highest version that can be found if you are on windows...)
    

    Here is some more documentation that may help with building statically for Mac:

    https://doc.qt.io/qt-4.8/developing-on-mac.html

    https://doc.qt.io/qt-4.8/mac-support.html

    https://doc.qt.io/qt-4.8/deployment-mac.html

    Not Editing Makefiles...

    If I were you, I would make sure that I have the same version of Qt that was used to build it at school, downloaded off the qt website, and make sure that I can build and run one of the Qt examples in Qt Creator for OSX.

    Then I would try compiling the school project in Qt Creator.

    Hope that helps.