Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Undefined reference to library after static compiling qt
Forum Updated to NodeBB v4.3 + New Features

Undefined reference to library after static compiling qt

Scheduled Pinned Locked Moved Mobile and Embedded
11 Posts 2 Posters 8.8k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    michael_endres
    wrote on 20 Dec 2013, 10:17 last edited by
    #1

    Hey,
    i compiled qt for windows static wothout any error and if i compile and execute a programm with qt creator without libs it is working. But if i want to use the Qt libs and include them, it says i.e QCoreApplication was not declared. After adding them in the*.pro file it says undefined reference to them.

    *.pro file
    #-------------------------------------------------

    Project created by QtCreator 2013-12-20T10:42:53

    #-------------------------------------------------

    QT += core

    QT -= gui

    TARGET = untitled1
    CONFIG += console
    CONFIG -= app_bundle

    TEMPLATE = app
    LIBS += -LC:\qt-everywhere-opensource-src-5.2.0_14Versuch\qtbase\lib -lQt5Core
    INCLUDEPATH += C:\qt-everywhere-opensource-src-5.2.0_14Versuch\qtbase\include\QtCore

    SOURCES += main.cpp

    main.cpp
    #include <QCoreApplication>
    using namespace std;
    int main(int argc, char *argv[])
    {
    QCoreApplication a(argc, argv);

    return a.exec(&#41;;
    

    }

    Can anybody help me?

    1 Reply Last reply
    0
    • R Offline
      R Offline
      raven-worx
      Moderators
      wrote on 20 Dec 2013, 11:34 last edited by
      #2

      first you need to add the following line to your .pro file
      @CONFIG += static@

      And also note that you need to rerun qmake everytime you alter the .pro file.

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0
      • M Offline
        M Offline
        michael_endres
        wrote on 20 Dec 2013, 12:12 last edited by
        #3

        Thx for your answer.

        i added the CONFIG+=static in the project settings in additional arguments, but i can do it in the Pro file again.
        I saw that the #include<QCoreApplication> refers to my standart qt under c: Qt5.2/...
        how can i change this?

        This is my error:
        13:30:12: Führe Schritte für Projekt untitled1 aus...
        13:30:12: Starte "C:\Sourcery_standard\bin\make.exe" clean
        rm -f main.obj
        C:\Sourcery_standard\bin\make.exe: Interrupt/Exception caught (code = 0xc00000fd, addr = 0x4227d3)
        13:30:12: Der Prozess "C:\Sourcery_standard\bin\make.exe" wurde mit dem Rückgabewert 255 beendet.
        13:30:12: Unveränderte Konfiguration, qmake-Schritt wird übersprungen.
        13:30:12: Starte "C:\Sourcery_standard\bin\make.exe"
        C:\Sourcery_standard\bin\arm-none-linux-gnueabi-g++.exe -c -pipe -march=armv7-a -mtune=cortex-a8 -mthumb -mfpu=neon -mfloat-abi=soft -g -Wall -W -D_REENTRANT -fPIE -DQT_STATIC_BUILD -DQT_QML_DEBUG -DQT_DECLARATIVE_DEBUG -DQT_CORE_LIB -I..\qt-everywhere-opensource-src-5.2.0_14Versuch\qtbase\mkspecs\linux-arm-gnueabi-g++ -I..\untitled1 -I..\qt-everywhere-opensource-src-5.2.0_14Versuch\qtbase\include -I..\qt-everywhere-opensource-src-5.2.0_14Versuch\qtbase\include\QtCore -I. -I. -o main.obj ..\untitled1\main.cpp
        C:\Sourcery_standard\bin\arm-none-linux-gnueabi-g++.exe -static -static-libgcc -o untitled1 main.obj -LC:/qt-everywhere-opensource-src-5.2.0_14Versuch/qtbase/lib -lQt5Core -lpthread
        main.obj: In function main': C:\build-untitled1-static-Debug/..\untitled1/main.cpp:6: undefined reference to QCoreApplication::QCoreApplication(int&, char**, int)'
        C:\build-untitled1-static-Debug/..\untitled1/main.cpp:8: undefined reference to QCoreApplication::exec&#40;&#41;' C:\build-untitled1-static-Debug/..\untitled1/main.cpp:8: undefined reference to QCoreApplication::~QCoreApplication()'
        C:\build-untitled1-static-Debug/..\untitled1/main.cpp:8: undefined reference to `QCoreApplication::~QCoreApplication()'
        collect2.exe: error: ld returned 1 exit status
        make: *** [untitled1] Error 1
        13:30:14: Der Prozess "C:\Sourcery_standard\bin\make.exe" wurde mit dem Rückgabewert 2 beendet.
        Fehler beim Erstellen/Deployment des Projekts untitled1(Kit: static )
        Bei der Ausführung von Schritt 'Make'
        13:30:14: Verstrichene Zeit: 00:02.

        1 Reply Last reply
        0
        • R Offline
          R Offline
          raven-worx
          Moderators
          wrote on 20 Dec 2013, 12:56 last edited by
          #4

          check your qt creator settings.
          Or if you use the command prompt make sure your environment variables are pointing to correct qt installation.

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          1 Reply Last reply
          0
          • M Offline
            M Offline
            michael_endres
            wrote on 20 Dec 2013, 13:08 last edited by
            #5

            which settings can i check? the environment variables are ok and i get the same error in command prompt as in qt creator.

            i noticed that the include< offers files depending on the projectpath, but there is no Q... as proposal

            1 Reply Last reply
            0
            • R Offline
              R Offline
              raven-worx
              Moderators
              wrote on 20 Dec 2013, 13:11 last edited by
              #6

              QTDIR, etc.
              just check all of them to make sure ;)

              --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
              If you have a question please use the forum so others can benefit from the solution in the future

              1 Reply Last reply
              0
              • M Offline
                M Offline
                michael_endres
                wrote on 20 Dec 2013, 13:22 last edited by
                #7

                They seem to be ok. No path to the old(normal) qt-version.

                Maybe i built qt wrong?
                here is my command:
                C:\qt-everywhere-opensource-src-5.2.0_14Versuch\qtbase>configure -embedded -platform win32-g++ -xplatform linux-arm-gnueabi-g++ -no-angle -opengl desktop -static -opensource -nomake examples

                @
                qmake.conf:

                qmake configuration for building with arm-linux-gnueabi-g++

                MAKEFILE_GENERATOR = UNIX
                CONFIG += incremental gdb_dwarf_index
                QMAKE_INCREMENTAL_STYLE = sublib

                include(../common/linux.conf)
                include(../common/gcc-base-unix.conf)
                include(../common/g++-unix.conf)

                modifications to g++.conf

                QMAKE_CC = C:\Sourcery_standard\bin\arm-none-linux-gnueabi-gcc.exe
                QMAKE_CXX = C:\Sourcery_standard\bin\arm-none-linux-gnueabi-g++.exe
                QMAKE_LINK = C:\Sourcery_standard\bin\arm-none-linux-gnueabi-g++.exe
                QMAKE_LINK_SHLIB = C:\Sourcery_standard\bin\arm-none-linux-gnueabi-g++.exe

                modifications to linux.conf

                QMAKE_AR = C:\Sourcery_standard\bin\arm-none-linux-gnueabi-ar.exe cqs
                QMAKE_OBJCOPY = C:\Sourcery_standard\bin\arm-none-linux-gnueabi-objcopy.exe
                QMAKE_NM = C:\Sourcery_standard\bin\arm-none-linux-gnueabi-nm.exe -P
                QMAKE_STRIP = C:\Sourcery_standard\bin\arm-none-linux-gnueabi-strip.exe
                COMPILER_FLAGS = -march=armv7-a -mtune=cortex-a8 -mthumb -mfpu=neon -mfloat-abi=soft
                QMAKE_CFLAGS += $${COMPILER_FLAGS}
                QMAKE_CXXFLAGS += $${COMPILER_FLAGS}
                QMAKE_CXXFLAGS_RELEASE += -O3

                QMAKE_CFLAGS_RELEASE = -Os -momit-leaf-frame-pointer
                QMAKE_LFLAGS = -static -static-libgcc
                DEFINES += QT_STATIC_BUILD
                load(qt_config)
                @

                makefile.win32
                ...

                LFLAGS = -static -static-libgcc

                ...

                do i need to set qt.conf?

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  michael_endres
                  wrote on 27 Dec 2013, 11:08 last edited by
                  #8

                  I still have the problem... Can't andybody help me?

                  1 Reply Last reply
                  0
                  • M Offline
                    M Offline
                    michael_endres
                    wrote on 30 Dec 2013, 09:18 last edited by
                    #9

                    I get the same problem also if i compile non-static...

                    1 Reply Last reply
                    0
                    • M Offline
                      M Offline
                      michael_endres
                      wrote on 7 Jan 2014, 14:56 last edited by
                      #10

                      if i compile it on a second Computer the same error appears.
                      I dont know how to solve this ...

                      1 Reply Last reply
                      0
                      • M Offline
                        M Offline
                        michael_endres
                        wrote on 7 Jan 2014, 15:00 last edited by
                        #11

                        This is my PATH variable:
                        PATH=C:\Program Files\Business Objects\Common\3.5\bin\NOTES;C:\Program Files\Bu
                        siness Objects\Common\3.5\bin\NOTES\DATA;C:\Windows\system32;C:\Windows;C:\Wind
                        ows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;
                        C:\qt-everywhere-opensource-src-5.2.0_14Versuch\qtbase\bin;C:\Sourcery_standard\bin;C:\Program Files\Business Objects\Common\3.5\bin\NOTES;C:\Program Files\Business Objects\Common\3.5\bin\NOTES\DATA;C:\Windows\system32;C:\Windows;C:\GnuWin32\bin;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\

                        QTDIR:
                        C:\qt-everywhere-opensource-src-5.2.0\qtbase

                        1 Reply Last reply
                        0

                        • Login

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt Extensions
                        • Unsolved