使用QWT构建时出错

时间:2016-10-25 09:14:31

标签: qt cmake qwt

我收到错误

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

当我尝试构建我的项目时,即使设置中的一切看起来都很好。

在我的CmakeLists.txt中我有

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

指向我拥有Qwt标头的位置 和

find_package(Qwt REQUIRED)

有效,因为QWT_FOUND设置为True

这是我的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)

使用消息打印$ {QWT_INCLUDE_DIR}指向qwt_plot.h,其中定义了QwtPlot :: QwtPlot(QWidget *),所以我不确定我可能缺少什么。

1 个答案:

答案 0 :(得分:2)

我忘了将库实际链接到项目

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