Search code examples
qtcmakeqwt

Errors while building with QWT


I get an error

undefined reference to `QwtPlot::QwtPlot(QWidget*)'

when I try to build my project even though everything seems fine in the setup.

In my CmakeLists.txt I have

include_directories(
  [...]
  ${QWT_INCLUDE_DIR})

which points to where I have my Qwt headers and

find_package(Qwt REQUIRED)

works because QWT_FOUND is set to True

Here's my FindQwt.cmake:

#MESSAGE("Searching for QWT")
FIND_PATH(QWT_INCLUDE_DIR NAMES qwt.h PATHS
  /usr/include
  /usr/local/include
  "$ENV{LIB_DIR}/include" 
  "$ENV{INCLUDE}" 
  PATH_SUFFIXES qwt-qt4 qwt
  )

FIND_LIBRARY(QWT_LIBRARY NAMES qwt qwt5 qwt-qt4 qwt5-qt4 PATHS 
  /usr/lib
  /usr/local/lib
  "$ENV{LIB_DIR}/lib" 
  "$ENV{LIB}/lib" 
  )

IF (QWT_INCLUDE_DIR AND QWT_LIBRARY)
  SET(QWT_FOUND TRUE)
ENDIF (QWT_INCLUDE_DIR AND QWT_LIBRARY)

IF (QWT_FOUND)
  IF (NOT QWT_FIND_QUIETLY)
    MESSAGE(STATUS "Found QWT: ${QWT_LIBRARY}")
  ENDIF (NOT QWT_FIND_QUIETLY)
ELSE (QWT_FOUND)
  IF (QWT_FIND_REQUIRED)
    MESSAGE(FATAL_ERROR "Could not find QWT")
  ENDIF (QWT_FIND_REQUIRED)
ENDIF (QWT_FOUND)

Using message to print ${QWT_INCLUDE_DIR} points to qwt_plot.h, which has QwtPlot::QwtPlot(QWidget*) defined, so I'm not sure what I could be missing.


Solution

  • I forgot to actually link the library to the project

    target_link_libraries(project
       [...]
       ${QWT_LIBRARY}
     )