Undefined reference to EVERYTHING

  • My problem is pretty simple: [url=http://www.yaharr.com/i/qt_1331errors.png]Everything is an undefined reference (CLICK FOR SCREENSHOT)[/url].

    This project was not made by me. It compiles just fine on it's author's computer with Qt Creator (on Windows 7).

    When I open the CMakeLists.txt with Qt (File > Open File or Project...) and Build All (Build > Build All), however, I get over a thousand errors due to everything being an undefined reference.

    • I'm using Windows 7 Professional 64-bit
    • I'm using MinGW 4.4 to compile - the same MinGW 4.4 that comes with Qt Creator's installer.
    • I have CMake 2.8
    • My packages are here: [url=http://www.yaharr.com/i/qt_packages2.png]Screenshot[/url] (updated)
    • Here's the part of my PATH variable that isn't just basic system stuff:
      ... C:\Program Files\Java\jre6\bin;C:\Program Files\TortoiseSVN\bin;C:\Program Files (x86)\CMake 2.8\bin;C:\Program Files (x86)\QuickTime\QTSystem;C:\Dynamic\QtSDK\mingw\bin;C:\Dynamic\QtSDK\Desktop\Qt\4.7.4\msvc2008\bin;C:\Dynamic\QtSDK\Desktop\Qt\4.7.4\mingw\bin

    To reiterate, this project compiles just fine on another Windows 7 PC.

  • My guess is, that you are trying to link against another version of the Qt libraries than the one you are #including somehow.

  • @Andre: How do we determine which library versions we're referencing?

    We're both using the same version of Desktop Qt.

  • Well, you might take a look at the commands qmake is generating / make is executing (and post them here).

  • -How would I obtain that information?-

    EDIT: Our makefile (CMakeLists.txt) contains this:

    cmake_minimum_required(VERSION 2.6)
    find_package(Qt4 REQUIRED)

    include_directories(${QT_INCLUDES} ${CMAKE_CURRENT_BINARY_DIR} "../libjson/Source")

    set(flist_messenger_SRCS ../libjson/Source/internalJSONNode.cpp ../libjson/Source/JSONNode.cpp ../libjson/Source/JSONChildren.cpp ../libjson/Source/JSONDebug.cpp
    ../libjson/Source/JSONMemory.cpp ../libjson/Source/JSONWorker.cpp ../libjson/Source/JSONWriter.cpp
    flist_avatar.cpp flist_character.cpp flist_sound.cpp main.cpp
    flist_channel.cpp flist_messenger.cpp flist_userlist.cpp flist_parser.cpp)
    SET(flist_messenger_HEADERS flist_avatar.h flist_character.h)
    set(QtApp_RCCS resources.qrc)

    QT4_WRAP_CPP(flist_messenger_HEADERS_MOC ${flist_messenger_HEADERS})
    add_executable(flist_messenger ${flist_messenger_SRCS} ${QtApp_RCC_SRCS} ${flist_messenger_HEADERS_MOC})
    target_link_libraries(flist_messenger ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTNETWORK_LIBRARY})@

    The information in the Compile Output tab follows:

    @Running build steps for project flist_messenger...
    Starting: "C:\Dynamic\QtSDK\mingw\bin\mingw32-make.exe"
    Linking CXX executable flist_messenger.exe
    CMakeFiles\flist_messenger.dir/objects.a(flist_avatar.cpp.obj):flist_avatar.cpp:(.text+0x16): undefined reference to _imp___ZN7QObjectC2EPS_' CMakeFiles\flist_messenger.dir/objects.a(flist_avatar.cpp.obj):flist_avatar.cpp:(.text+0x53): undefined reference to_imp___ZN21QNetworkAccessManagerC1EP7QObject'

    <it continues like this for ~1500 lines>

    CMakeFiles\flist_messenger.dir/objects.a(moc_flist_avatar.cxx.obj):moc_flist_avatar.cxx:(.rdata$_ZTV7FAvatar[vtable for FAvatar]+0x34): undefined reference to QObject::disconnectNotify(char const*)' CMakeFiles\flist_messenger.dir/objects.a(moc_flist_avatar.cxx.obj):moc_flist_avatar.cxx:(.text$_ZN7FAvatarD0Ev[FAvatar::~FAvatar()]+0x1b): undefined reference to_imp___ZN21QNetworkAccessManagerD1Ev'
    CMakeFiles\flist_messenger.dir/objects.a(moc_flist_avatar.cxx.obj):moc_flist_avatar.cxx:(.text$_ZN7FAvatarD0Ev[FAvatar::~FAvatar()]+0x78): undefined reference to _imp___ZN7QObjectD2Ev' CMakeFiles\flist_messenger.dir/objects.a(moc_flist_avatar.cxx.obj):moc_flist_avatar.cxx:(.text$_ZN7FAvatarD0Ev[FAvatar::~FAvatar()]+0x94): undefined reference to_imp___ZN7QObjectD2Ev'
    collect2: ld returned 1 exit status
    mingw32-make[2]: *** [flist_messenger.exe] Error 1
    mingw32-make[1]: *** [CMakeFiles/flist_messenger.dir/all] Error 2
    mingw32-make: *** [all] Error 2
    The process "C:\Dynamic\QtSDK\mingw\bin\mingw32-make.exe" exited with code 2.
    Error while building project flist_messenger (target: Desktop)
    When executing build step 'Make'@

    (The full output is [url=http://www.yaharr.com/i/make-output.txt]here[/url])

    Is that the information you're after?

  • The acutal call to the linker would be interesting, especially which pathes and libraries get passed.

  • [quote author="Lukas Geyer" date="1321879284"]The acutal call to the linker would be interesting, especially which pathes and libraries get passed.[/quote]
    How do I acquire that call information?

    This is my first time dealing with makefiles, and my usage of C++ compilers (apart from Visual Studio's) has just involved single-document scripts.

Log in to reply

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