Results 1 to 5 of 5

Thread: error: undefined reference to. Where?

  1. #1
    Join Date
    Jan 2015
    Location
    Barquisimeto, Venezuela
    Posts
    24
    Thanks
    2
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Android

    Question error: undefined reference to. Where?

    Hello again, friends.

    In this opportunity I am writing to see how far they can guide me with this problem that has been presented to me.

    After a question I asked a few weeks ago and orientations of anda_skoa, I have managed to "compile" a project that I have been developing gradually. The point is that when compiling my executable I have the following errors:

    Qt Code:
    1. /home/remizero/Projects/Qt/ecomoditor-Debug/common/language/libphp.so:-1: error: undefined reference to `With: Ecosoftware :: Ecomoditor :: Common :: Language :: Core :: Model: : ClassAbs :: staticMetaObject '
    2. /home/remizero/Projects/Qt/ecomoditor-Debug/common/addons/libclass-viewer.so:-1: error: undefined reference to `With: Ecosoftware :: Ecomoditor :: Common :: Language :: Core :: Model :: MethodAbs :: getMethodReturn () const '
    3. /home/remizero/Projects/Qt/ecomoditor-Debug/common/libactions.so:-1: error: undefined reference to `With: Ecosoftware :: Ecomoditor :: Common :: CodeGenerator :: Core :: ClassGeneratorAbs :: save (QString) '
    To copy to clipboard, switch view to plain text mode 

    Well they really are more, but I think with them is enough to get an idea of ​​what happens to me. Clarifying that all libraries get to compile completely and without problems, I only throw the undefined reference error when I try to compile the executable that is:

    Qt Code:
    1. Ecomoditor/bin/ecomoditor
    To copy to clipboard, switch view to plain text mode 

    It should be noted that I have reviewed a lot of documentation and references on the web about this problem, but so far I have not been able to solve it with any solution offered, which in most cases have nothing to do with mine.

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

    In addition to this, I can comment that all the libraries work correctly, I have tried them all separately and all the code works correctly, costing me a lot to separate this project in libraries because initially I had it as a whole in an app type project.

    You may notice some hazards in the .pro files, but it's only so far that I'm programming something serious with Qt and of course there are the errors that are being presented to me. I put what I take so far from the project to have it tested and verify where the error may be and then they can tell me that I am doing wrong and where to go.

    By the way, what is commented in .pro files is because I'm not using it yet and so I did not put those portions of code.

    No more to add, thank you very much in advance.
    Attached Files Attached Files

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: error: undefined reference to. Where?

    Undefined references are always due to failure to link to a library or object code module that contains the implementation of those classes or methods. I don't know about Debian, but on Windows you cannot link a debug mode program to release mode libraries or vice-versa. This could be another cause of undefined references.

    Check your linker options to make sure you have included all of the necessary libraries or object files. If the undefined classes are QObject-based, make sure that MOC has been run to generate the moc*.cpp files and that these are also being compiled. Sometimes a qmake / make clean is needed.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  3. #3
    Join Date
    Jan 2015
    Location
    Barquisimeto, Venezuela
    Posts
    24
    Thanks
    2
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Android

    Default Re: error: undefined reference to. Where?

    Hi d_stranz, thanks for your quick reply.

    I understand what you say, although at the configuration level of the .pro file I have no reference to the compilation mode, the QtCreator configuration I have at the moment for compilations in debug mode, so I do not think it is that aspect, but I'll give you a look at the QtCreator configuration again to see if any unexpected and/or unintentional changes have been made without my noticing.

    On the other hand what you comment about the preprocessor MOC, yes. The moc_.cpp files are being generated with their respective moc_.o.

    I also cleaned the project (including deleting the whole folder), running qmake, then build (including, one by one each sub project), and finally run, but at the time of build the executable project that in this case is ecomoditor/Bin/ecomoditor, throws the above mentioned errors to me.

    I will continue to look in the documentation, which I may be doing wrong so that it does not compile properly.

  4. #4
    Join Date
    Jan 2015
    Location
    Barquisimeto, Venezuela
    Posts
    24
    Thanks
    2
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Android

    Wink Re: error: undefined reference to. Where?

    Hello friends, I am writing to give for solving the problem raised.

    The detail was, he wanted to run without learning to crawl first.

    Although the problem was not in the libraries proper, since each one does what it has to do, there was a detail in the order in which the libraries were generated.

    I had to add one by one the libraries to be able to realize the order that had to be compiled and linked and thus to prevent the mistakes of linking, because that was my whole problem.

    Thanks for your help.

  5. #5
    Join Date
    Jan 2015
    Location
    Barquisimeto, Venezuela
    Posts
    24
    Thanks
    2
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Android

    Smile Re: error: undefined reference to. Where?

    Hi again. Reactivate this post, to clarify the error due to lack of reference in link time that was coming to me.

    Having written the "solution" to this problem and doing a serious test on tests, I was again presented with the problem.

    The detail was at the moment of commenting on the lines of libraries that I did not want to use for various functional tests and for decoupling all the code.

    Well, at the moment of commenting on these lines of libraries in the .pro file, I forgot to remove the backslash, leaving in many cases configurations like this:

    Qt Code:
    1. win32:CONFIG(release, debug|release): LIBS += \
    2. -L$$OUT_PWD/../../com/ecosoftware/app/debug/ -lapp \
    3. #-L$$OUT_PWD/../../com/ecosoftware/singleinstance/debug/ -lsingleinstance \
    4. #-L$$OUT_PWD/../../com/ecosoftware/files/xmlmanager/debug/ -lxmlmanager \
    5. [COLOR="#FF0000"]-L$$OUT_PWD/../../com/ecosoftware/window/debug/ -lmainwindow \[/COLOR]
    6. #-L$$OUT_PWD/../../com/ecosoftware/window/components/debug/ -lexpandtoolbar \
    7. #-L$$OUT_PWD/../../com/ecosoftware/window/components/debug/ -lmenubar \
    8. #-L$$OUT_PWD/../../com/ecosoftware/window/components/debug/ -ltabpanel \
    9. #-L$$OUT_PWD/../../common/debug/ -lworkspace \
    10. else:win32:CONFIG(debug, debug|release): LIBS += \
    11. -L$$OUT_PWD/../../com/ecosoftware/app/debug/ -lapp \
    12. #-L$$OUT_PWD/../../com/ecosoftware/singleinstance/debug/ -lsingleinstance \
    13. #-L$$OUT_PWD/../../com/ecosoftware/files/xmlmanager/debug/ -lxmlmanager \
    14. [COLOR="#FF0000"]-L$$OUT_PWD/../../com/ecosoftware/window/debug/ -lmainwindow \[/COLOR]
    15. #-L$$OUT_PWD/../../com/ecosoftware/window/components/debug/ -lexpandtoolbar \
    16. #-L$$OUT_PWD/../../com/ecosoftware/window/components/debug/ -lmenubar \
    17. #-L$$OUT_PWD/../../com/ecosoftware/window/components/debug/ -ltabpanel \
    18. #-L$$OUT_PWD/../../common/debug/ -lworkspace \
    19. else:unix: LIBS += \
    20. -L$$OUT_PWD/../../com/ecosoftware/ -lapp \
    21. #-L$$OUT_PWD/../../com/ecosoftware/ -lsingleinstance \
    22. #-L$$OUT_PWD/../../com/ecosoftware/files/ -lxmlmanager \
    23. [COLOR="#FF0000"]-L$$OUT_PWD/../../com/ecosoftware/window/ -lmainwindow \[/COLOR]
    24. #-L$$OUT_PWD/../../com/ecosoftware/window/components/ -lexpandtoolbar \
    25. #-L$$OUT_PWD/../../com/ecosoftware/window/components/ -lmenubar \
    26. #-L$$OUT_PWD/../../com/ecosoftware/window/components/ -ltabpanel \
    27. #-L$$OUT_PWD/../../common/ -lworkspace \
    To copy to clipboard, switch view to plain text mode 

    Where, the correct form would be the following:

    Qt Code:
    1. win32:CONFIG(release, debug|release): LIBS += \
    2. -L$$OUT_PWD/../../com/ecosoftware/app/debug/ -lapp \
    3. #-L$$OUT_PWD/../../com/ecosoftware/singleinstance/debug/ -lsingleinstance \
    4. #-L$$OUT_PWD/../../com/ecosoftware/files/xmlmanager/debug/ -lxmlmanager \
    5. [COLOR="#FF0000"]-L$$OUT_PWD/../../com/ecosoftware/window/debug/ -lmainwindow[/COLOR]
    6. #-L$$OUT_PWD/../../com/ecosoftware/window/components/debug/ -lexpandtoolbar \
    7. #-L$$OUT_PWD/../../com/ecosoftware/window/components/debug/ -lmenubar \
    8. #-L$$OUT_PWD/../../com/ecosoftware/window/components/debug/ -ltabpanel \
    9. #-L$$OUT_PWD/../../common/debug/ -lworkspace \
    10. else:win32:CONFIG(debug, debug|release): LIBS += \
    11. -L$$OUT_PWD/../../com/ecosoftware/app/debug/ -lapp \
    12. #-L$$OUT_PWD/../../com/ecosoftware/singleinstance/debug/ -lsingleinstance \
    13. #-L$$OUT_PWD/../../com/ecosoftware/files/xmlmanager/debug/ -lxmlmanager \
    14. [COLOR="#FF0000"]-L$$OUT_PWD/../../com/ecosoftware/window/debug/ -lmainwindow[/COLOR]
    15. #-L$$OUT_PWD/../../com/ecosoftware/window/components/debug/ -lexpandtoolbar \
    16. #-L$$OUT_PWD/../../com/ecosoftware/window/components/debug/ -lmenubar \
    17. #-L$$OUT_PWD/../../com/ecosoftware/window/components/debug/ -ltabpanel \
    18. #-L$$OUT_PWD/../../common/debug/ -lworkspace \
    19. else:unix: LIBS += \
    20. -L$$OUT_PWD/../../com/ecosoftware/ -lapp \
    21. #-L$$OUT_PWD/../../com/ecosoftware/ -lsingleinstance \
    22. #-L$$OUT_PWD/../../com/ecosoftware/files/ -lxmlmanager \
    23. [COLOR="#FF0000"]-L$$OUT_PWD/../../com/ecosoftware/window/ -lmainwindow[/COLOR]
    24. #-L$$OUT_PWD/../../com/ecosoftware/window/components/ -lexpandtoolbar \
    25. #-L$$OUT_PWD/../../com/ecosoftware/window/components/ -lmenubar \
    26. #-L$$OUT_PWD/../../com/ecosoftware/window/components/ -ltabpanel \
    27. #-L$$OUT_PWD/../../common/ -lworkspace \
    To copy to clipboard, switch view to plain text mode 

    Thanks also for the help lent me, he guided me a lot to understand the why? Of this error.

Similar Threads

  1. error: undefined reference to `_imp___ZN19QGrouping !!
    By Fatemeh in forum Qt Programming
    Replies: 2
    Last Post: 14th May 2013, 12:38
  2. error: undefined reference to qInitResources_pbuffers()
    By saman_artorious in forum Qt Programming
    Replies: 0
    Last Post: 8th April 2013, 10:42
  3. Getting Undefined Reference Error
    By A.H.M. Mahfuzur Rahman in forum Qt Programming
    Replies: 2
    Last Post: 22nd June 2009, 03:12
  4. error undefined reference ...............
    By amit_pansuria in forum Qt Programming
    Replies: 2
    Last Post: 8th June 2007, 15:28
  5. Undefined Reference error!!!
    By Kapil in forum Newbie
    Replies: 25
    Last Post: 28th March 2006, 13:03

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.