Results 1 to 4 of 4

Thread: undefined reference to QwtPlotCurve

  1. #1
    Join Date
    Jan 2010
    Posts
    7
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default undefined reference to QwtPlotCurve

    I'm running a Qt application that uses a lot of external libraries, and I'm forced to use CMake.

    I'm compiled, linked and run a Qt application already. I can add a plot, and everything works. But when I try to add a marker I get linking errors. After hours lost, posting a question on stackoverflow , I cannot find out why. I reproduced the error using the curvdemo1.cpp example. I'm using Qt 4.8 (kept having issues with Qwt and Qt 5) and Qwt 6.1.2. The code is the same, I just did copy paste, and the CMakeLists.txt is as follows:

    Qt Code:
    1. cmake_minimum_required(VERSION 2.8.11)
    2.  
    3. # Find includes in corresponding build directories
    4. set(CMAKE_INCLUDE_CURRENT_DIR ON)
    5.  
    6. # Find the QtWidgets library
    7. find_package(Qt4 REQUIRED)
    8. INCLUDE(${QT_USE_FILE})
    9. # Find qwt
    10. find_path(QWTDIR qwt.h HINTS /usr/local/qwt-6.1.2/include)
    11. find_library(QWTLIBRARY qwt /usr/local/qwt-6.1.2/lib/)
    12. include_directories(${QWTDIR})
    13.  
    14. # source, header and resources files list
    15. set(CPP_SOURCES curvdemo1.cpp) #
    16.  
    17. # Generate moc files from cpp
    18. qt4_wrap_cpp(MOC_SOURCES ${CPP_SOURCES})
    19.  
    20. # Add compiler flags for building executables (-fPIE)
    21. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
    22.  
    23.  
    24. # Tell CMake to create the helloworld executable
    25. add_executable(demo1 ${CPP_SOURCES} ${MOC_SOURCES})
    26.  
    27. #Link the helloworld executable to the Qt 5 widgets library.
    28. target_link_libraries(demo1 ${QT_LIBRARIES} ${QWTLIBRARY} Qt4::QtSvg)
    To copy to clipboard, switch view to plain text mode 

    The output of the compilation is:

    Qt Code:
    1. >> make
    2. [ 33%] Generating moc_curvdemo1.cxx
    3. /home/jcolmenares/development/qwt/qwt-6.1.2/examples/curvdemo2/curvdemo1.cpp:0: Note: No relevant classes found. No output generated.
    4. Scanning dependencies of target demo1
    5. [ 66%] Building CXX object CMakeFiles/demo1.dir/curvdemo1.cpp.o
    6. [100%] Building CXX object CMakeFiles/demo1.dir/moc_curvdemo1.cxx.o
    7. Linking CXX executable demo1
    8. CMakeFiles/demo1.dir/curvdemo1.cpp.o: In function `MainWin::MainWin()':
    9. curvdemo1.cpp:(.text+0x2d4): undefined reference to `QwtPlotCurve::setSymbol(QwtSymbol*)'
    10. curvdemo1.cpp:(.text+0x343): undefined reference to `QwtPlotCurve::setPen(QColor const&, double, Qt::PenStyle)'
    11. curvdemo1.cpp:(.text+0x46b): undefined reference to `QwtPlotCurve::setSymbol(QwtSymbol*)'
    12. curvdemo1.cpp:(.text+0x4d4): undefined reference to `QwtPlotCurve::setPen(QColor const&, double, Qt::PenStyle)'
    13. curvdemo1.cpp:(.text+0x561): undefined reference to `QwtPlotCurve::setPen(QColor const&, double, Qt::PenStyle)'
    14. curvdemo1.cpp:(.text+0x5ee): undefined reference to `QwtPlotCurve::setPen(QColor const&, double, Qt::PenStyle)'
    15. curvdemo1.cpp:(.text+0x6b5): undefined reference to `QwtPlotCurve::setPen(QColor const&, double, Qt::PenStyle)'
    16. curvdemo1.cpp:(.text+0x79e): undefined reference to `QwtPlotCurve::setSymbol(QwtSymbol*)'
    17. collect2: error: ld returned 1 exit status
    18. make[2]: *** [demo1] Error 1
    19. make[1]: *** [CMakeFiles/demo1.dir/all] Error 2
    20. make: *** [all] Error 2
    21. >>
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,253
    Thanked 860 Times in 809 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: undefined reference to QwtPlotCurve

    Well, when having a problem with linking it would be helpful to see the command, that is used for linking.

    Uwe

  3. #3
    Join Date
    Jan 2010
    Posts
    7
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: undefined reference to QwtPlotCurve

    I posted the CMakeList.txt file, and the output !!!

    What else can I post? the command is there: make. The instruction given to cmake for the linking is in the last line that I posted

    target_link_libraries(demo1 ${QT_LIBRARIES} ${QWTLIBRARY} Qt4::QtSvg)

  4. #4
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,253
    Thanked 860 Times in 809 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: undefined reference to QwtPlotCurve

    Guess it is obvious, that "Linking CXX executable demo1" is not a command, that does something on your system.

    make processes commands from a Makefile, that has been generated from cmake. In your case you have configured cmake in a way, that the rules in the Makefile suppress the echoing of the executed command.
    I'm not familiar with cmake, but in case of qmake it would be "CONFIG += silent"

    So you have 2 options:

    • configure cmake without this silent mode
    • edit the Makefile ( grep for "Linking" ) and modify the rule manually


    Uwe

Similar Threads

  1. undefined reference
    By deepakswaroop in forum Newbie
    Replies: 1
    Last Post: 2nd March 2011, 07:46
  2. Undefined reference
    By eekhoorn12 in forum Qt Programming
    Replies: 2
    Last Post: 6th January 2011, 16:45
  3. undefined reference
    By digidas in forum Newbie
    Replies: 9
    Last Post: 19th May 2010, 14:04
  4. Undefined reference to crt
    By derektaprell in forum Installation and Deployment
    Replies: 0
    Last Post: 20th October 2009, 09:34
  5. Undefined Reference To...
    By ManuMies in forum Qt Programming
    Replies: 6
    Last Post: 10th February 2009, 13:14

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.