Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. error: undefined reference to
QtWS25 Last Chance

error: undefined reference to

Scheduled Pinned Locked Moved Solved General and Desktop
shared librarylinker errorsqmakeundefined refer
6 Posts 3 Posters 12.6k Views
  • 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.
  • R Offline
    R Offline
    remizero
    wrote on 7 Apr 2017, 17:47 last edited by remizero 4 Jul 2017, 17:59
    #1

    Hello friends.

    I come here because of the problem described in the title of the message.

    I know there are many references to this problem in this forum and in many others. You have done all the solutions presented in each topic that you have reviewed but it has not helped me to solve and / or understand the why? Of my problem

    I have the following project, structured in subdirectories project:

    Ecomoditorgui/ecomoditorgui.pro // Sub-directories project
    Ecomoditorgui/com/com.pro // Sub-directories project
    Ecomoditorgui/com/ecosoftware/ecosoftware.pro // Sub-directories project
    Ecomoditorgui/com/ecosoftware/app/app.pro // Shared library
    Ecomoditorgui/com/ecosoftware/window/window.pro // Sub subdirectories project
    Ecomoditorgui/com/ecosoftware/window/mainwindow/mainwindow.pro // Shared library
    Ecomoditorgui/examples/examples.pro // Sub-directories project
    Ecomoditorgui/examples/maingui / maingui.pro // Test executable
    

    Now, these are the .pro of each subproject.

    ecomoditorgui/ecomoditorgui.pro
    TEMPLATE = subdirs
    CONFIG += ordered
    UI_DIR = ui
    SUBDIRS += \
    com \
    examples
    
    examples.depends = com
    
    
    ecomoditorgui/com/com.pro
    TEMPLATE = subdirs
    UI_DIR = ../ui
    SUBDIRS += \
    ecosoftware
    
    
    ecomoditorgui/com/ecosoftware/ecosoftware.pro
    TEMPLATE = subdirs
    CONFIG += ordered
    UI_DIR = ../../ui
    SUBDIRS += \
    app \
    window
    
    window.depends = app
    
    
    ecomoditorgui/com/ecosoftware/app/app.pro
    QT       -= gui
    CONFIG += c++14
    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets core xml xmlpatterns
    TARGET = app
    TEMPLATE = lib
    DESTDIR = ../
    UI_DIR = ../../../ui
    DEFINES += APP_LIBRARY
    DEFINES += QT_DEPRECATED_WARNINGS
    
    SOURCES += \
    AppInfo.cpp \
    AppInit.cpp \
    AppSettings.cpp \
    AppUtils.cpp \
    AppPaths.cpp
    
    HEADERS += \
    app_global.h \
    AppInfo.h \
    AppInit.h \
    AppSettings.h \
    AppUtils.h \
    AppPaths.h
    
    unix {
        target.path = /usr/lib
        INSTALLS += target
    }
    
    
    ecomoditorgui/com/ecosoftware/window/window.pro
    TEMPLATE = subdirs
    CONFIG += ordered
    UI_DIR = ../../../ui
    SUBDIRS += \
    mainwindow
    
    
    ecomoditorgui/com/ecosoftware/window/mainwindow/mainwindow.pro
    QT       -= gui
    CONFIG += c++14
    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
    TARGET = mainwindow
    TEMPLATE = lib
    DESTDIR = ../
    UI_DIR = ../../../../ui
    DEFINES += MAINWINDOW_LIBRARY
    DEFINES += QT_DEPRECATED_WARNINGS
    
    SOURCES += \
    MainWindow.cpp \
    MainWindowActions.cpp \
    MainWindowEvents.cpp \
    MainWindowSignals.cpp \
    MainWindowSlots.cpp
    
    HEADERS += \
    mainwindow_global.h \
    MainWindow.h \
    MainWindowActions.h \
    MainWindowEvents.h \
    MainWindowSignals.h \
    MainWindowSlots.h
    
    unix {
        target.path = /usr/lib
        INSTALLS += target
    }
    
    win32:CONFIG(release, debug|release): LIBS += \
    -L$$OUT_PWD/../../app/release/ -lapp
    else:win32:CONFIG(debug, debug|release): LIBS += \
    -L$$OUT_PWD/../../app/debug/ -lapp
    else:unix: LIBS += \
    -L$$OUT_PWD/../../ -lapp
    
    INCLUDEPATH += \
    $$PWD/../../app
    
    DEPENDPATH += \
    $$PWD/../../app
    
    
    ecomoditorgui/examples/examples.pro
    TEMPLATE = subdirs
    SUBDIRS += \
    maingui
    
    
    ecomoditorgui/examples/maingui/maingui.pro
    CONFIG += c++14
    greaterThan(QT_MAJOR_VERSION, 4): QT += core gui widgets core xml xmlpatterns
    TARGET = mainecomoditorgui
    TEMPLATE = app
    DESTDIR = ../
    UI_DIR = ../../../ui
    DEFINES += QT_DEPRECATED_WARNINGS
    
    SOURCES += \
    main.cpp \
    MainWindowGui.cpp
    
    HEADERS  += \
    MainWindowGui.h
    
    win32:CONFIG(release, debug|release): LIBS += \
    -L$$OUT_PWD/../../com/ecosoftware/app/debug/ -lapp \
    -L$$OUT_PWD/../../com/ecosoftware/window/debug/ -lmainwindow
    else:win32:CONFIG(debug, debug|release): LIBS += \
    -L$$OUT_PWD/../../com/ecosoftware/app/debug/ -lapp \
    -L$$OUT_PWD/../../com/ecosoftware/window/debug/ -lmainwindow
    else:unix: LIBS += \
    -L$$OUT_PWD/../../com/ecosoftware/ -lapp \
    -L$$OUT_PWD/../../com/ecosoftware/window/ -lmainwindow
    
    INCLUDEPATH += \
    ../../ui \
    $$PWD/../../com/ecosoftware/app \
    $$PWD/../../com/ecosoftware/window/mainwindow
    
    DEPENDPATH += \
    $$PWD/../../com/ecosoftware/app \
    $$PWD/../../com/ecosoftware/window/mainwindow
    

    I have simplified the whole project which is much more extensive, only to reproduce the error with the minimum possible code, so that they can check it more easily and can make a manito to me as much as possible.

    The errors that are presented to me are the following (although in fact it is the same):

    /home/remizero/Proyectos/Qt/ecomoditorgui-Debug/examples/maingui/MainWindowGui.o:-1: In function `Com::Ecosoftware::Ecomoditor::Examples::Maingui::MainWindowGui::MainWindowGui(QWidget*)':
    /home/remizero/Proyectos/Qt/ecomoditorgui/examples/maingui/MainWindowGui.cpp:7: error: undefined reference to `Com::Ecosoftware::Window::MainWindow::MainWindow::MainWindow(QWidget*)'
    /home/remizero/Proyectos/Qt/ecomoditorgui/examples/maingui/MainWindowGui.cpp:7: error: undefined reference to `Com::Ecosoftware::Window::MainWindow::MainWindow::~MainWindow()'
    /home/remizero/Proyectos/Qt/ecomoditorgui-Debug/examples/maingui/MainWindowGui.o:-1: In function `Com::Ecosoftware::Ecomoditor::Examples::Maingui::MainWindowGui::~MainWindowGui()':
    /home/remizero/Proyectos/Qt/ecomoditorgui/examples/maingui/MainWindowGui.cpp:17: error: undefined reference to `Com::Ecosoftware::Window::MainWindow::MainWindow::~MainWindow()'
    /home/remizero/Proyectos/Qt/ecomoditorgui-Debug/examples/maingui/moc_MainWindowGui.o:-1: In function `Com::Ecosoftware::Ecomoditor::Examples::Maingui::MainWindowGui::qt_metacast(char const*)':
    /home/remizero/Proyectos/Qt/ecomoditorgui-Debug/examples/maingui/moc_MainWindowGui.cpp:93: error: undefined reference to `Com::Ecosoftware::Window::MainWindow::MainWindow::qt_metacast(char const*)'
    /home/remizero/Proyectos/Qt/ecomoditorgui-Debug/examples/maingui/moc_MainWindowGui.o:-1: In function `Com::Ecosoftware::Ecomoditor::Examples::Maingui::MainWindowGui::qt_metacall(QMetaObject::Call, int, void**)':
    /home/remizero/Proyectos/Qt/ecomoditorgui-Debug/examples/maingui/moc_MainWindowGui.cpp:98: error: undefined reference to `Com::Ecosoftware::Window::MainWindow::MainWindow::qt_metacall(QMetaObject::Call, int, void**)'
    /home/remizero/Proyectos/Qt/ecomoditorgui-Debug/examples/maingui/moc_MainWindowGui.o:-1: error: undefined reference to `Com::Ecosoftware::Window::MainWindow::MainWindow::staticMetaObject'
    /home/remizero/Proyectos/Qt/ecomoditorgui-Debug/examples/maingui/moc_MainWindowGui.o:-1: error: undefined reference to `Com::Ecosoftware::Window::MainWindow::MainWindow::resizeEvent(QResizeEvent*)'
    /home/remizero/Proyectos/Qt/ecomoditorgui-Debug/examples/maingui/moc_MainWindowGui.o:-1: error: undefined reference to `Com::Ecosoftware::Window::MainWindow::MainWindow::closeEvent(QCloseEvent*)'
    moc_MainWindowGui.o:-1: error: undefined reference to `Com::Ecosoftware::Window::MainWindow::MainWindow::changeEvent(QEvent*)' moc_MainWindowGui.o:-1: error: undefined reference to `typeinfo for Com::Ecosoftware::Window::MainWindow::MainWindow'
    :-1: error: collect2: error: ld returned 1 exit status
    

    I understand that all these errors are presented at the linker level.

    But I have already tried a huge amount of solutions exposed in this forum and many others but none has helped me to solve the problem.
    They could tell me that doing this wrong!;).

    It should be noted that this project has already been fully done and it works. But of course I have it just as a static application, but the problem is that it weighs a lot and for large projects like those that development consumes many resources. Because I have decided to restructure it to work with shared libraries and thus reuse the code more dynamically and on demand and reduce resource consumption that makes me quite expensive in some teams with few resources.

    If you need any additional code let me know and I will gladly upload it. I do not know how to upload the code to the forum, but I leave this link to my account in mega so that they download it and they can try and see that I am doing wrong, if that was so.

    I'm working on Debian 9 64bit, QtCreator 4.2.0 and Qt 5.7.1

    https://mega.nz/#!eIY32DDT!QTK5jIXBr1pRu7T3WrRg6T5UXkvpghkPeNBYNEwstNk

    Thanks in advance.

    A 2 Replies Last reply 8 Apr 2017, 03:30
    0
    • R Offline
      R Offline
      remizero
      wrote on 8 Apr 2017, 16:40 last edited by remizero 4 Aug 2017, 16:47
      #5

      Thanks for your prompt response.

      Hi @SGaist, that line automatically places the QtCreator, so I only leave it there because it allows me to add the additional Qt modules that I require, when I require clear is jejeje.

      Hi @ambershark. Well, taking into account what you told me, has made a more exhaustive review of my files.

      LIBS + = -L../../com/ecosoftware/window -lmainwindow
      

      I still had a question about why? It did not work correctly if indeed that line that your comments are included in the LIBS variable for all platforms.

      Well, I realized that by doing tests on tests, I was not looking for the backslash at the end of the last included library.

      The funniest thing about everything is for the code published in the post, if it worked, then the correct thing, but in the code that is in the attachment, I left it as it was in the tests and that's where it can be appreciated The error

      For example, attachment with the error:

      Win32: CONFIG (release, debug | release): LIBS + = \
      -L$$OUT_PWD/../../com/ecosoftware/app/debug/ -lapp \
      -L$$OUT_PWD/../../com/ecosoftware/window/debug/ -lmainwindow \
      Else: win32: CONFIG (debug, debug | release): LIBS + = \
      -L$$OUT_PWD/../../com/ecosoftware/app/debug/ -lapp \
      -L$$OUT_PWD/../../com/ecosoftware/window/debug/ -lmainwindow \
      Else: unix: LIBS + = \
      -L$$OUT_PWD/../../com/ecosoftware/ -app \
      -L$$OUT_PWD/../../com/ecosoftware/window/ -lmainwindow \
      
      INCLUDEPATH + = \
      ../../ui \
      $$PWD/../../com/ecosoftware/app \
      $$PWD/../../com/ecosoftware/window/mainwindow
      
      DEPENDPATH + = \
      $$PWD/../../com/ecosoftware/app \
      $$PWD/../../com/ecosoftware/window/mainwindow
      

      Correct form of the file, correcting the error:

      Win32: CONFIG (release, debug | release): LIBS + = \
      -L$$OUT_PWD/../../com/ecosoftware/app/debug/ -lapp \
      -L$$OUT_PWD/../../com/ecosoftware/window/debug/ -lmainwindow
      Else: win32: CONFIG (debug, debug | release): LIBS + = \
      -L$$OUT_PWD/../../com/ecosoftware/app/debug/ -lapp \
      -L$$OUT_PWD/../../com/ecosoftware/window/debug/ -lmainwindow
      Else: unix: LIBS + = \
      -L$$OUT_PWD/../../com/ecosoftware/ -app \
      -L$$OUT_PWD/../../com/ecosoftware/window/ -lmainwindow
      
      INCLUDEPATH + = \
      ../../ui \
      $$PWD/../../com/ecosoftware/app \
      $$PWD/../../com/ecosoftware/window/mainwindow
      
      DEPENDPATH + = \
      $$PWD/../../com/ecosoftware/app \
      $$PWD/../../com/ecosoftware/window/mainwindow
      

      Thank you very much for your help, I hereby solve this thread. I hope this explanation will help others identify the why? Of this error when they only work with qmake.

      1 Reply Last reply
      1
      • S Offline
        S Offline
        SGaist
        Lifetime Qt Champion
        wrote on 7 Apr 2017, 20:41 last edited by
        #2

        Hi,

        Did you check whether you have warning lines with libraries not found message ?

        Note that you greaterThan(QT_MAJOR_VERSION, 4): lines don't make sense. This construct is only useful for the widgets module.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        1
        • R remizero
          7 Apr 2017, 17:47

          Hello friends.

          I come here because of the problem described in the title of the message.

          I know there are many references to this problem in this forum and in many others. You have done all the solutions presented in each topic that you have reviewed but it has not helped me to solve and / or understand the why? Of my problem

          I have the following project, structured in subdirectories project:

          Ecomoditorgui/ecomoditorgui.pro // Sub-directories project
          Ecomoditorgui/com/com.pro // Sub-directories project
          Ecomoditorgui/com/ecosoftware/ecosoftware.pro // Sub-directories project
          Ecomoditorgui/com/ecosoftware/app/app.pro // Shared library
          Ecomoditorgui/com/ecosoftware/window/window.pro // Sub subdirectories project
          Ecomoditorgui/com/ecosoftware/window/mainwindow/mainwindow.pro // Shared library
          Ecomoditorgui/examples/examples.pro // Sub-directories project
          Ecomoditorgui/examples/maingui / maingui.pro // Test executable
          

          Now, these are the .pro of each subproject.

          ecomoditorgui/ecomoditorgui.pro
          TEMPLATE = subdirs
          CONFIG += ordered
          UI_DIR = ui
          SUBDIRS += \
          com \
          examples
          
          examples.depends = com
          
          
          ecomoditorgui/com/com.pro
          TEMPLATE = subdirs
          UI_DIR = ../ui
          SUBDIRS += \
          ecosoftware
          
          
          ecomoditorgui/com/ecosoftware/ecosoftware.pro
          TEMPLATE = subdirs
          CONFIG += ordered
          UI_DIR = ../../ui
          SUBDIRS += \
          app \
          window
          
          window.depends = app
          
          
          ecomoditorgui/com/ecosoftware/app/app.pro
          QT       -= gui
          CONFIG += c++14
          greaterThan(QT_MAJOR_VERSION, 4): QT += widgets core xml xmlpatterns
          TARGET = app
          TEMPLATE = lib
          DESTDIR = ../
          UI_DIR = ../../../ui
          DEFINES += APP_LIBRARY
          DEFINES += QT_DEPRECATED_WARNINGS
          
          SOURCES += \
          AppInfo.cpp \
          AppInit.cpp \
          AppSettings.cpp \
          AppUtils.cpp \
          AppPaths.cpp
          
          HEADERS += \
          app_global.h \
          AppInfo.h \
          AppInit.h \
          AppSettings.h \
          AppUtils.h \
          AppPaths.h
          
          unix {
              target.path = /usr/lib
              INSTALLS += target
          }
          
          
          ecomoditorgui/com/ecosoftware/window/window.pro
          TEMPLATE = subdirs
          CONFIG += ordered
          UI_DIR = ../../../ui
          SUBDIRS += \
          mainwindow
          
          
          ecomoditorgui/com/ecosoftware/window/mainwindow/mainwindow.pro
          QT       -= gui
          CONFIG += c++14
          greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
          TARGET = mainwindow
          TEMPLATE = lib
          DESTDIR = ../
          UI_DIR = ../../../../ui
          DEFINES += MAINWINDOW_LIBRARY
          DEFINES += QT_DEPRECATED_WARNINGS
          
          SOURCES += \
          MainWindow.cpp \
          MainWindowActions.cpp \
          MainWindowEvents.cpp \
          MainWindowSignals.cpp \
          MainWindowSlots.cpp
          
          HEADERS += \
          mainwindow_global.h \
          MainWindow.h \
          MainWindowActions.h \
          MainWindowEvents.h \
          MainWindowSignals.h \
          MainWindowSlots.h
          
          unix {
              target.path = /usr/lib
              INSTALLS += target
          }
          
          win32:CONFIG(release, debug|release): LIBS += \
          -L$$OUT_PWD/../../app/release/ -lapp
          else:win32:CONFIG(debug, debug|release): LIBS += \
          -L$$OUT_PWD/../../app/debug/ -lapp
          else:unix: LIBS += \
          -L$$OUT_PWD/../../ -lapp
          
          INCLUDEPATH += \
          $$PWD/../../app
          
          DEPENDPATH += \
          $$PWD/../../app
          
          
          ecomoditorgui/examples/examples.pro
          TEMPLATE = subdirs
          SUBDIRS += \
          maingui
          
          
          ecomoditorgui/examples/maingui/maingui.pro
          CONFIG += c++14
          greaterThan(QT_MAJOR_VERSION, 4): QT += core gui widgets core xml xmlpatterns
          TARGET = mainecomoditorgui
          TEMPLATE = app
          DESTDIR = ../
          UI_DIR = ../../../ui
          DEFINES += QT_DEPRECATED_WARNINGS
          
          SOURCES += \
          main.cpp \
          MainWindowGui.cpp
          
          HEADERS  += \
          MainWindowGui.h
          
          win32:CONFIG(release, debug|release): LIBS += \
          -L$$OUT_PWD/../../com/ecosoftware/app/debug/ -lapp \
          -L$$OUT_PWD/../../com/ecosoftware/window/debug/ -lmainwindow
          else:win32:CONFIG(debug, debug|release): LIBS += \
          -L$$OUT_PWD/../../com/ecosoftware/app/debug/ -lapp \
          -L$$OUT_PWD/../../com/ecosoftware/window/debug/ -lmainwindow
          else:unix: LIBS += \
          -L$$OUT_PWD/../../com/ecosoftware/ -lapp \
          -L$$OUT_PWD/../../com/ecosoftware/window/ -lmainwindow
          
          INCLUDEPATH += \
          ../../ui \
          $$PWD/../../com/ecosoftware/app \
          $$PWD/../../com/ecosoftware/window/mainwindow
          
          DEPENDPATH += \
          $$PWD/../../com/ecosoftware/app \
          $$PWD/../../com/ecosoftware/window/mainwindow
          

          I have simplified the whole project which is much more extensive, only to reproduce the error with the minimum possible code, so that they can check it more easily and can make a manito to me as much as possible.

          The errors that are presented to me are the following (although in fact it is the same):

          /home/remizero/Proyectos/Qt/ecomoditorgui-Debug/examples/maingui/MainWindowGui.o:-1: In function `Com::Ecosoftware::Ecomoditor::Examples::Maingui::MainWindowGui::MainWindowGui(QWidget*)':
          /home/remizero/Proyectos/Qt/ecomoditorgui/examples/maingui/MainWindowGui.cpp:7: error: undefined reference to `Com::Ecosoftware::Window::MainWindow::MainWindow::MainWindow(QWidget*)'
          /home/remizero/Proyectos/Qt/ecomoditorgui/examples/maingui/MainWindowGui.cpp:7: error: undefined reference to `Com::Ecosoftware::Window::MainWindow::MainWindow::~MainWindow()'
          /home/remizero/Proyectos/Qt/ecomoditorgui-Debug/examples/maingui/MainWindowGui.o:-1: In function `Com::Ecosoftware::Ecomoditor::Examples::Maingui::MainWindowGui::~MainWindowGui()':
          /home/remizero/Proyectos/Qt/ecomoditorgui/examples/maingui/MainWindowGui.cpp:17: error: undefined reference to `Com::Ecosoftware::Window::MainWindow::MainWindow::~MainWindow()'
          /home/remizero/Proyectos/Qt/ecomoditorgui-Debug/examples/maingui/moc_MainWindowGui.o:-1: In function `Com::Ecosoftware::Ecomoditor::Examples::Maingui::MainWindowGui::qt_metacast(char const*)':
          /home/remizero/Proyectos/Qt/ecomoditorgui-Debug/examples/maingui/moc_MainWindowGui.cpp:93: error: undefined reference to `Com::Ecosoftware::Window::MainWindow::MainWindow::qt_metacast(char const*)'
          /home/remizero/Proyectos/Qt/ecomoditorgui-Debug/examples/maingui/moc_MainWindowGui.o:-1: In function `Com::Ecosoftware::Ecomoditor::Examples::Maingui::MainWindowGui::qt_metacall(QMetaObject::Call, int, void**)':
          /home/remizero/Proyectos/Qt/ecomoditorgui-Debug/examples/maingui/moc_MainWindowGui.cpp:98: error: undefined reference to `Com::Ecosoftware::Window::MainWindow::MainWindow::qt_metacall(QMetaObject::Call, int, void**)'
          /home/remizero/Proyectos/Qt/ecomoditorgui-Debug/examples/maingui/moc_MainWindowGui.o:-1: error: undefined reference to `Com::Ecosoftware::Window::MainWindow::MainWindow::staticMetaObject'
          /home/remizero/Proyectos/Qt/ecomoditorgui-Debug/examples/maingui/moc_MainWindowGui.o:-1: error: undefined reference to `Com::Ecosoftware::Window::MainWindow::MainWindow::resizeEvent(QResizeEvent*)'
          /home/remizero/Proyectos/Qt/ecomoditorgui-Debug/examples/maingui/moc_MainWindowGui.o:-1: error: undefined reference to `Com::Ecosoftware::Window::MainWindow::MainWindow::closeEvent(QCloseEvent*)'
          moc_MainWindowGui.o:-1: error: undefined reference to `Com::Ecosoftware::Window::MainWindow::MainWindow::changeEvent(QEvent*)' moc_MainWindowGui.o:-1: error: undefined reference to `typeinfo for Com::Ecosoftware::Window::MainWindow::MainWindow'
          :-1: error: collect2: error: ld returned 1 exit status
          

          I understand that all these errors are presented at the linker level.

          But I have already tried a huge amount of solutions exposed in this forum and many others but none has helped me to solve the problem.
          They could tell me that doing this wrong!;).

          It should be noted that this project has already been fully done and it works. But of course I have it just as a static application, but the problem is that it weighs a lot and for large projects like those that development consumes many resources. Because I have decided to restructure it to work with shared libraries and thus reuse the code more dynamically and on demand and reduce resource consumption that makes me quite expensive in some teams with few resources.

          If you need any additional code let me know and I will gladly upload it. I do not know how to upload the code to the forum, but I leave this link to my account in mega so that they download it and they can try and see that I am doing wrong, if that was so.

          I'm working on Debian 9 64bit, QtCreator 4.2.0 and Qt 5.7.1

          https://mega.nz/#!eIY32DDT!QTK5jIXBr1pRu7T3WrRg6T5UXkvpghkPeNBYNEwstNk

          Thanks in advance.

          A Offline
          A Offline
          ambershark
          wrote on 8 Apr 2017, 03:30 last edited by
          #3

          @remizero It sounds like it isn't linking the libs you need. So since you are moving from static to dynamic libraries I'm guessing your project settings are wrong.

          I can grab the project and compile it and I'll let you know in a bit.

          My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

          1 Reply Last reply
          0
          • R remizero
            7 Apr 2017, 17:47

            Hello friends.

            I come here because of the problem described in the title of the message.

            I know there are many references to this problem in this forum and in many others. You have done all the solutions presented in each topic that you have reviewed but it has not helped me to solve and / or understand the why? Of my problem

            I have the following project, structured in subdirectories project:

            Ecomoditorgui/ecomoditorgui.pro // Sub-directories project
            Ecomoditorgui/com/com.pro // Sub-directories project
            Ecomoditorgui/com/ecosoftware/ecosoftware.pro // Sub-directories project
            Ecomoditorgui/com/ecosoftware/app/app.pro // Shared library
            Ecomoditorgui/com/ecosoftware/window/window.pro // Sub subdirectories project
            Ecomoditorgui/com/ecosoftware/window/mainwindow/mainwindow.pro // Shared library
            Ecomoditorgui/examples/examples.pro // Sub-directories project
            Ecomoditorgui/examples/maingui / maingui.pro // Test executable
            

            Now, these are the .pro of each subproject.

            ecomoditorgui/ecomoditorgui.pro
            TEMPLATE = subdirs
            CONFIG += ordered
            UI_DIR = ui
            SUBDIRS += \
            com \
            examples
            
            examples.depends = com
            
            
            ecomoditorgui/com/com.pro
            TEMPLATE = subdirs
            UI_DIR = ../ui
            SUBDIRS += \
            ecosoftware
            
            
            ecomoditorgui/com/ecosoftware/ecosoftware.pro
            TEMPLATE = subdirs
            CONFIG += ordered
            UI_DIR = ../../ui
            SUBDIRS += \
            app \
            window
            
            window.depends = app
            
            
            ecomoditorgui/com/ecosoftware/app/app.pro
            QT       -= gui
            CONFIG += c++14
            greaterThan(QT_MAJOR_VERSION, 4): QT += widgets core xml xmlpatterns
            TARGET = app
            TEMPLATE = lib
            DESTDIR = ../
            UI_DIR = ../../../ui
            DEFINES += APP_LIBRARY
            DEFINES += QT_DEPRECATED_WARNINGS
            
            SOURCES += \
            AppInfo.cpp \
            AppInit.cpp \
            AppSettings.cpp \
            AppUtils.cpp \
            AppPaths.cpp
            
            HEADERS += \
            app_global.h \
            AppInfo.h \
            AppInit.h \
            AppSettings.h \
            AppUtils.h \
            AppPaths.h
            
            unix {
                target.path = /usr/lib
                INSTALLS += target
            }
            
            
            ecomoditorgui/com/ecosoftware/window/window.pro
            TEMPLATE = subdirs
            CONFIG += ordered
            UI_DIR = ../../../ui
            SUBDIRS += \
            mainwindow
            
            
            ecomoditorgui/com/ecosoftware/window/mainwindow/mainwindow.pro
            QT       -= gui
            CONFIG += c++14
            greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
            TARGET = mainwindow
            TEMPLATE = lib
            DESTDIR = ../
            UI_DIR = ../../../../ui
            DEFINES += MAINWINDOW_LIBRARY
            DEFINES += QT_DEPRECATED_WARNINGS
            
            SOURCES += \
            MainWindow.cpp \
            MainWindowActions.cpp \
            MainWindowEvents.cpp \
            MainWindowSignals.cpp \
            MainWindowSlots.cpp
            
            HEADERS += \
            mainwindow_global.h \
            MainWindow.h \
            MainWindowActions.h \
            MainWindowEvents.h \
            MainWindowSignals.h \
            MainWindowSlots.h
            
            unix {
                target.path = /usr/lib
                INSTALLS += target
            }
            
            win32:CONFIG(release, debug|release): LIBS += \
            -L$$OUT_PWD/../../app/release/ -lapp
            else:win32:CONFIG(debug, debug|release): LIBS += \
            -L$$OUT_PWD/../../app/debug/ -lapp
            else:unix: LIBS += \
            -L$$OUT_PWD/../../ -lapp
            
            INCLUDEPATH += \
            $$PWD/../../app
            
            DEPENDPATH += \
            $$PWD/../../app
            
            
            ecomoditorgui/examples/examples.pro
            TEMPLATE = subdirs
            SUBDIRS += \
            maingui
            
            
            ecomoditorgui/examples/maingui/maingui.pro
            CONFIG += c++14
            greaterThan(QT_MAJOR_VERSION, 4): QT += core gui widgets core xml xmlpatterns
            TARGET = mainecomoditorgui
            TEMPLATE = app
            DESTDIR = ../
            UI_DIR = ../../../ui
            DEFINES += QT_DEPRECATED_WARNINGS
            
            SOURCES += \
            main.cpp \
            MainWindowGui.cpp
            
            HEADERS  += \
            MainWindowGui.h
            
            win32:CONFIG(release, debug|release): LIBS += \
            -L$$OUT_PWD/../../com/ecosoftware/app/debug/ -lapp \
            -L$$OUT_PWD/../../com/ecosoftware/window/debug/ -lmainwindow
            else:win32:CONFIG(debug, debug|release): LIBS += \
            -L$$OUT_PWD/../../com/ecosoftware/app/debug/ -lapp \
            -L$$OUT_PWD/../../com/ecosoftware/window/debug/ -lmainwindow
            else:unix: LIBS += \
            -L$$OUT_PWD/../../com/ecosoftware/ -lapp \
            -L$$OUT_PWD/../../com/ecosoftware/window/ -lmainwindow
            
            INCLUDEPATH += \
            ../../ui \
            $$PWD/../../com/ecosoftware/app \
            $$PWD/../../com/ecosoftware/window/mainwindow
            
            DEPENDPATH += \
            $$PWD/../../com/ecosoftware/app \
            $$PWD/../../com/ecosoftware/window/mainwindow
            

            I have simplified the whole project which is much more extensive, only to reproduce the error with the minimum possible code, so that they can check it more easily and can make a manito to me as much as possible.

            The errors that are presented to me are the following (although in fact it is the same):

            /home/remizero/Proyectos/Qt/ecomoditorgui-Debug/examples/maingui/MainWindowGui.o:-1: In function `Com::Ecosoftware::Ecomoditor::Examples::Maingui::MainWindowGui::MainWindowGui(QWidget*)':
            /home/remizero/Proyectos/Qt/ecomoditorgui/examples/maingui/MainWindowGui.cpp:7: error: undefined reference to `Com::Ecosoftware::Window::MainWindow::MainWindow::MainWindow(QWidget*)'
            /home/remizero/Proyectos/Qt/ecomoditorgui/examples/maingui/MainWindowGui.cpp:7: error: undefined reference to `Com::Ecosoftware::Window::MainWindow::MainWindow::~MainWindow()'
            /home/remizero/Proyectos/Qt/ecomoditorgui-Debug/examples/maingui/MainWindowGui.o:-1: In function `Com::Ecosoftware::Ecomoditor::Examples::Maingui::MainWindowGui::~MainWindowGui()':
            /home/remizero/Proyectos/Qt/ecomoditorgui/examples/maingui/MainWindowGui.cpp:17: error: undefined reference to `Com::Ecosoftware::Window::MainWindow::MainWindow::~MainWindow()'
            /home/remizero/Proyectos/Qt/ecomoditorgui-Debug/examples/maingui/moc_MainWindowGui.o:-1: In function `Com::Ecosoftware::Ecomoditor::Examples::Maingui::MainWindowGui::qt_metacast(char const*)':
            /home/remizero/Proyectos/Qt/ecomoditorgui-Debug/examples/maingui/moc_MainWindowGui.cpp:93: error: undefined reference to `Com::Ecosoftware::Window::MainWindow::MainWindow::qt_metacast(char const*)'
            /home/remizero/Proyectos/Qt/ecomoditorgui-Debug/examples/maingui/moc_MainWindowGui.o:-1: In function `Com::Ecosoftware::Ecomoditor::Examples::Maingui::MainWindowGui::qt_metacall(QMetaObject::Call, int, void**)':
            /home/remizero/Proyectos/Qt/ecomoditorgui-Debug/examples/maingui/moc_MainWindowGui.cpp:98: error: undefined reference to `Com::Ecosoftware::Window::MainWindow::MainWindow::qt_metacall(QMetaObject::Call, int, void**)'
            /home/remizero/Proyectos/Qt/ecomoditorgui-Debug/examples/maingui/moc_MainWindowGui.o:-1: error: undefined reference to `Com::Ecosoftware::Window::MainWindow::MainWindow::staticMetaObject'
            /home/remizero/Proyectos/Qt/ecomoditorgui-Debug/examples/maingui/moc_MainWindowGui.o:-1: error: undefined reference to `Com::Ecosoftware::Window::MainWindow::MainWindow::resizeEvent(QResizeEvent*)'
            /home/remizero/Proyectos/Qt/ecomoditorgui-Debug/examples/maingui/moc_MainWindowGui.o:-1: error: undefined reference to `Com::Ecosoftware::Window::MainWindow::MainWindow::closeEvent(QCloseEvent*)'
            moc_MainWindowGui.o:-1: error: undefined reference to `Com::Ecosoftware::Window::MainWindow::MainWindow::changeEvent(QEvent*)' moc_MainWindowGui.o:-1: error: undefined reference to `typeinfo for Com::Ecosoftware::Window::MainWindow::MainWindow'
            :-1: error: collect2: error: ld returned 1 exit status
            

            I understand that all these errors are presented at the linker level.

            But I have already tried a huge amount of solutions exposed in this forum and many others but none has helped me to solve the problem.
            They could tell me that doing this wrong!;).

            It should be noted that this project has already been fully done and it works. But of course I have it just as a static application, but the problem is that it weighs a lot and for large projects like those that development consumes many resources. Because I have decided to restructure it to work with shared libraries and thus reuse the code more dynamically and on demand and reduce resource consumption that makes me quite expensive in some teams with few resources.

            If you need any additional code let me know and I will gladly upload it. I do not know how to upload the code to the forum, but I leave this link to my account in mega so that they download it and they can try and see that I am doing wrong, if that was so.

            I'm working on Debian 9 64bit, QtCreator 4.2.0 and Qt 5.7.1

            https://mega.nz/#!eIY32DDT!QTK5jIXBr1pRu7T3WrRg6T5UXkvpghkPeNBYNEwstNk

            Thanks in advance.

            A Offline
            A Offline
            ambershark
            wrote on 8 Apr 2017, 03:45 last edited by
            #4

            @remizero Ok I found your problem..

            The blocks with win32:CONFIG and else:unix: etc are not correct.

            I don't remember the exact syntax since I don't work with qmake much any more (prefer cmake) so I'll let you google it or someone else can come in and tell you how.

            But basically I noticed when I built it that the compile line that was failing looked like this:

            g++ -Wl,-O1 -Wl,-rpath,/usr/local/Qt/lib -o ../mainecomoditorgui main.o MainWindowGui.o moc_MainWindowGui.o   -L/usr/local/Qt/lib -lQt5Widgets -lQt5Gui -lQt5Xml -lQt5XmlPatterns -L/opt/Qt/5.8/gcc_64/lib -lQt5Network -lQt5Core -lGL -lpthread
            

            You'll notice there is no -L../../com/ecosoftware/window and no -lmainwindow. So since you never included that library path or linked to the mainwindow lib that is why things are undefined.

            To confirm I added this to your examples/maingui/maingui.pro file:

            LIBS += -L../../com/ecosoftware/window -lmainwindow
            

            And when I built it worked. Not completely as there was another project file with the same errors but I confirmed the problem, so now that you know why you should be able to fix it easily. ;)

            My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

            1 Reply Last reply
            1
            • R Offline
              R Offline
              remizero
              wrote on 8 Apr 2017, 16:40 last edited by remizero 4 Aug 2017, 16:47
              #5

              Thanks for your prompt response.

              Hi @SGaist, that line automatically places the QtCreator, so I only leave it there because it allows me to add the additional Qt modules that I require, when I require clear is jejeje.

              Hi @ambershark. Well, taking into account what you told me, has made a more exhaustive review of my files.

              LIBS + = -L../../com/ecosoftware/window -lmainwindow
              

              I still had a question about why? It did not work correctly if indeed that line that your comments are included in the LIBS variable for all platforms.

              Well, I realized that by doing tests on tests, I was not looking for the backslash at the end of the last included library.

              The funniest thing about everything is for the code published in the post, if it worked, then the correct thing, but in the code that is in the attachment, I left it as it was in the tests and that's where it can be appreciated The error

              For example, attachment with the error:

              Win32: CONFIG (release, debug | release): LIBS + = \
              -L$$OUT_PWD/../../com/ecosoftware/app/debug/ -lapp \
              -L$$OUT_PWD/../../com/ecosoftware/window/debug/ -lmainwindow \
              Else: win32: CONFIG (debug, debug | release): LIBS + = \
              -L$$OUT_PWD/../../com/ecosoftware/app/debug/ -lapp \
              -L$$OUT_PWD/../../com/ecosoftware/window/debug/ -lmainwindow \
              Else: unix: LIBS + = \
              -L$$OUT_PWD/../../com/ecosoftware/ -app \
              -L$$OUT_PWD/../../com/ecosoftware/window/ -lmainwindow \
              
              INCLUDEPATH + = \
              ../../ui \
              $$PWD/../../com/ecosoftware/app \
              $$PWD/../../com/ecosoftware/window/mainwindow
              
              DEPENDPATH + = \
              $$PWD/../../com/ecosoftware/app \
              $$PWD/../../com/ecosoftware/window/mainwindow
              

              Correct form of the file, correcting the error:

              Win32: CONFIG (release, debug | release): LIBS + = \
              -L$$OUT_PWD/../../com/ecosoftware/app/debug/ -lapp \
              -L$$OUT_PWD/../../com/ecosoftware/window/debug/ -lmainwindow
              Else: win32: CONFIG (debug, debug | release): LIBS + = \
              -L$$OUT_PWD/../../com/ecosoftware/app/debug/ -lapp \
              -L$$OUT_PWD/../../com/ecosoftware/window/debug/ -lmainwindow
              Else: unix: LIBS + = \
              -L$$OUT_PWD/../../com/ecosoftware/ -app \
              -L$$OUT_PWD/../../com/ecosoftware/window/ -lmainwindow
              
              INCLUDEPATH + = \
              ../../ui \
              $$PWD/../../com/ecosoftware/app \
              $$PWD/../../com/ecosoftware/window/mainwindow
              
              DEPENDPATH + = \
              $$PWD/../../com/ecosoftware/app \
              $$PWD/../../com/ecosoftware/window/mainwindow
              

              Thank you very much for your help, I hereby solve this thread. I hope this explanation will help others identify the why? Of this error when they only work with qmake.

              1 Reply Last reply
              1
              • S Offline
                S Offline
                SGaist
                Lifetime Qt Champion
                wrote on 8 Apr 2017, 20:29 last edited by
                #6

                Just use QT += module

                That test is really only useful for code bases that should be built with both Qt 4 and Qt 5 since the widgets have moved to their own module in Qt 5.

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                1

                6/6

                8 Apr 2017, 20:29

                • Login

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