将项目转换为qt5,并对qt5和cmake的vtable进行未定义的引用。

时间:2021-11-29 04:54:00

I have been working on converting a windows qt4 project to work with qt5 and cmake. I get to what I think is close the done and then I keep getting weird "undefined reference errors" from the linker. but I can't seem to make them go away. included is the cmake file. I am new to cmake and qt. Thanks for the help.

我一直在致力于将一个windows qt4项目转换为qt5和cmake。我得到了我认为已经完成的事情,然后我不断地从链接器中得到奇怪的“未定义的引用错误”。但我似乎不能让他们离开。包括cmake文件。我是cmake和qt的新成员,谢谢你的帮助。

cmake_minimum_required(VERSION 3.0.0)

project(JF-Cut)


include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
if(COMPILER_SUPPORTS_CXX11)
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
#elseif(COMPILER_SUPPORTS_CXX0X)
#   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
else()
        message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
endif()


set(FIND_GLM ./FindGLM.cmake)

# Find the QtWidgets library
find_package(OpenCL REQUIRED)
find_package(OpenGL REQUIRED)
#find_package(GLM REQUIRED)
#include_directories(${GLM_INCLUDE_DIRS})
#link_directories(${GLM_LIBRARY_DIRS})
#add_definitions(${GLM_DEFINITIONS})

find_package(Qt5 COMPONENTS Core Gui
            OpenGL Xml Declarative
            Widgets 
            REQUIRED
            )
find_package(GLEW REQUIRED )
find_package(Boost COMPONENTS system)

#FIND_PATH(GLM_INCLUDE_DIR /usr/include)

# Interoperation with clogs
option(CLOGS " use clogs algorithms " OFF)
if (CLOGS)
  find_path(CLOGS_INCLUDE clogs/clogs.h)
  find_library(CLOGS_LIB clogs)
  include_directories(${CLOGS_INCLUDE})
  add_definitions(-DHAVE_CLOGS)
endif()

#set(CMAKE_AUTOMOC ON)
#SET(CMAKE_AUTOUIC ON)

add_definitions(-DUNICODE
                -DQT_LARGEFILE_SUPPORT
                -D__CL_ENABLE_EXCEPTIONS
                -D__CL_ENABLE_DEBUG_
                -DQT_CORE_LIB
                -DQT_GUI_LIB
                -DQT_DLL
                -DQT_XML_LIB
                -DNOMINMAX
                )

SET(CMAKE_INCLUDE_CURRENT_DIR ON)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})

set(SOURCE
  ${CMAKE_CURRENT_SOURCE_DIR}/3rdParty/bench/mfi.cpp
  ${CMAKE_CURRENT_SOURCE_DIR}/Graph_Cut/QGCMain.cpp
  ${CMAKE_CURRENT_SOURCE_DIR}/Graph_Cut/QGCSetting.cpp
  ${CMAKE_CURRENT_SOURCE_DIR}/infrastructures/QSetting.cpp
  ${CMAKE_CURRENT_SOURCE_DIR}/Graph_Cut/QGCPanel.cpp
  ${CMAKE_CURRENT_SOURCE_DIR}/Graph_Cut/QGCVisualizer.cpp
  ${CMAKE_CURRENT_SOURCE_DIR}/Graph_Cut/QGCWidget.cpp
  ${CMAKE_CURRENT_SOURCE_DIR}/infrastructures/QHoverPoints.cpp
  ${CMAKE_CURRENT_SOURCE_DIR}/infrastructures/QProfile.cpp
  ${CMAKE_CURRENT_SOURCE_DIR}/infrastructures/QTransferFunction1D.cpp
  ${CMAKE_CURRENT_SOURCE_DIR}/templates/QCommon.cpp
  ${CMAKE_CURRENT_SOURCE_DIR}/utilities/QIO.cpp
  ${CMAKE_CURRENT_SOURCE_DIR}/utilities/QUtilityCL.cpp
  ${CMAKE_CURRENT_SOURCE_DIR}/utilities/QUtilityConsole.cpp
  ${CMAKE_CURRENT_SOURCE_DIR}/utilities/QUtilityData.cpp
  ${CMAKE_CURRENT_SOURCE_DIR}/utilities/QUtilityGL.cpp
  ${CMAKE_CURRENT_SOURCE_DIR}/utilities/QUtilityMath.cpp
  ${CMAKE_CURRENT_SOURCE_DIR}/utilities/QUtilityUI.cpp

)
set(HEADERS
  ${CMAKE_CURRENT_SOURCE_DIR}/3rdParty/bench/mfi.h
  ${CMAKE_CURRENT_SOURCE_DIR}/3rdParty/cl/cl_stacktrace.hpp
  ${CMAKE_CURRENT_SOURCE_DIR}/3rdParty/stacktrace/call_stack.hpp
  ${CMAKE_CURRENT_SOURCE_DIR}/3rdParty/stacktrace/call_stack_msvc.hpp
  ${CMAKE_CURRENT_SOURCE_DIR}/3rdParty/stacktrace/call_stack_gcc.hpp
  ${CMAKE_CURRENT_SOURCE_DIR}/Graph_Cut/QGCSetting.h
  ${CMAKE_CURRENT_SOURCE_DIR}/infrastructures/QError.h
  ${CMAKE_CURRENT_SOURCE_DIR}/3rdParty/stacktrace/StackWalker.hpp
  ${CMAKE_CURRENT_SOURCE_DIR}/3rdParty/stacktrace/StackWalker.h
  ${CMAKE_CURRENT_SOURCE_DIR}/infrastructures/QSetting.h
  ${CMAKE_CURRENT_SOURCE_DIR}/infrastructures/QStructure.h
  ${CMAKE_CURRENT_SOURCE_DIR}/Graph_Cut/QGCPanel.h
  ${CMAKE_CURRENT_SOURCE_DIR}/Graph_Cut/QGCVisualizer.h
  ${CMAKE_CURRENT_SOURCE_DIR}/Graph_Cut/QGCWidget.h
  ${CMAKE_CURRENT_SOURCE_DIR}/infrastructures/QHoverPoints.h
  ${CMAKE_CURRENT_SOURCE_DIR}/infrastructures/QProfile.h
  ${CMAKE_CURRENT_SOURCE_DIR}/infrastructures/QTransferFunction1D.h
  ${CMAKE_CURRENT_SOURCE_DIR}/templates/QCommon.h
  ${CMAKE_CURRENT_SOURCE_DIR}/utilities/QIO.h
  ${CMAKE_CURRENT_SOURCE_DIR}/utilities/QUtilityCL.h
  ${CMAKE_CURRENT_SOURCE_DIR}/utilities/QUtilityConsole.h
  ${CMAKE_CURRENT_SOURCE_DIR}/utilities/QUtilityData.h
  ${CMAKE_CURRENT_SOURCE_DIR}/utilities/QUtilityGL.h
  ${CMAKE_CURRENT_SOURCE_DIR}/utilities/QUtilityMath.h
  ${CMAKE_CURRENT_SOURCE_DIR}/utilities/QUtilityUI.h
  ${CMAKE_CURRENT_SOURCE_DIR}/cl/GraphCut/graphcut_bfs_block.cl
  ${CMAKE_CURRENT_SOURCE_DIR}/cl/GraphCut/graphcut_compute_capacity.cl
  ${CMAKE_CURRENT_SOURCE_DIR}/cl/GraphCut/graphcut_compute_cut.cl
  ${CMAKE_CURRENT_SOURCE_DIR}/cl/GraphCut/graphcut_compute_excessflow.cl
  ${CMAKE_CURRENT_SOURCE_DIR}/cl/GraphCut/graphcut_compute_flow.cl
  ${CMAKE_CURRENT_SOURCE_DIR}/cl/GraphCut/graphcut_compute_tag.cl
  ${CMAKE_CURRENT_SOURCE_DIR}/cl/GraphCut/graphcut_count_block.cl
  ${CMAKE_CURRENT_SOURCE_DIR}/cl/GraphCut/graphcut_global_relabel.cl
  ${CMAKE_CURRENT_SOURCE_DIR}/cl/GraphCut/graphcut_histogram.cl
  ${CMAKE_CURRENT_SOURCE_DIR}/cl/GraphCut/graphcut_kmeans.cl
  ${CMAKE_CURRENT_SOURCE_DIR}/cl/GraphCut/graphcut_push_relabel.cl
  ${CMAKE_CURRENT_SOURCE_DIR}/cl/GraphCut/graphcut_push_relabel_fast.cl
  ${CMAKE_CURRENT_SOURCE_DIR}/cl/GraphCut/graphcut_render_ray_casting.cl
  ${CMAKE_CURRENT_SOURCE_DIR}/cl/GraphCut/graphcut_render_ray_casting_feature.cl
  ${CMAKE_CURRENT_SOURCE_DIR}/cl/GraphCut/graphcut_render_ray_casting_preint.cl
)

Set (UI_FILES
    ${CMAKE_CURRENT_SOURCE_DIR}/ui/Graph_Cut/QGCPanel.ui
    ${CMAKE_CURRENT_SOURCE_DIR}/ui/Graph_Cut/QGCVisualizer.ui
    )


QT5_WRAP_CPP(QGCPanel_hdr_moc ${CMAKE_CURRENT_SOURCE_DIR}/Graph_Cut/QGCPanel.h )
qt5_wrap_ui(QGCPanel_ui_moc  ${CMAKE_CURRENT_SOURCE_DIR}/ui/Graph_Cut/QGCPanel.ui)

QT5_WRAP_CPP(QGCVisualizer_hdr_moc  ${CMAKE_CURRENT_SOURCE_DIR}/Graph_Cut/QGCVisualizer.h)
qt5_wrap_ui(QGCVisualizer_ui_moc  ${CMAKE_CURRENT_SOURCE_DIR}/ui/Graph_Cut/QGCVisualizer.ui)


QT5_WRAP_CPP(QGCWidget_hdr_moc  ${CMAKE_CURRENT_SOURCE_DIR}/Graph_Cut/QGCWidget.h )
QT5_WRAP_CPP(QTransferFunction1D_hdr_moc  ${CMAKE_CURRENT_SOURCE_DIR}/infrastructures/QTransferFunction1D.h )
QT5_WRAP_CPP(QProfile_hdr_moc  ${CMAKE_CURRENT_SOURCE_DIR}/infrastructures/QProfile.h )
QT5_WRAP_CPP(QHoverPoints_hdr_moc  ${CMAKE_CURRENT_SOURCE_DIR}/infrastructures/QHoverPoints.h )

QT5_WRAP_CPP(QCommon_hdr_moc  ${CMAKE_CURRENT_SOURCE_DIR}/templates/QCommon.h )


add_library(QGCPanel
            ${CMAKE_CURRENT_SOURCE_DIR}/Graph_Cut/QGCPanel.cpp
            ${QGCPanel_ui_moc})
target_link_libraries(QGCPanel Qt5::Widgets ${QGCPanel_hdr_moc} ${QCommon_hdr_moc})

add_library(QGCVisualizer
            ${CMAKE_CURRENT_SOURCE_DIR}/Graph_Cut/QGCVisualizer.cpp
            ${CMAKE_CURRENT_SOURCE_DIR}/templates/QCommon.cpp
            ${QGCVisualizer_ui_moc} ${QGCPanel_ui_moc}
            )
target_link_libraries(QGCVisualizer
                        Qt5::Widgets
                        Qt5::Core
                        ${QGCVisualizer_hdr_moc}
                        ${QGCPanel_hdr_moc}
                        ${CMAKE_CURRENT_SOURCE_DIR}/templates/QCommon.h
                        ${CMAKE_CURRENT_SOURCE_DIR}/Graph_Cut/QGCPanel.h
                        ${CMAKE_CURRENT_SOURCE_DIR}/Graph_Cut/QGCWidget.h
                        )

add_library(QGCWidget
            ${CMAKE_CURRENT_SOURCE_DIR}/Graph_Cut/QGCWidget.cpp)
target_link_libraries(QGCWidget Qt5::Widgets ${QGCWidget_hdr_moc})

add_library(QTransferFunction1D
           ${CMAKE_CURRENT_SOURCE_DIR}/infrastructures/QTransferFunction1D.cpp)
target_link_libraries(QTransferFunction1D  Qt5::Widgets ${QTransferFunction1D_hdr_moc})

add_library(QProfile
            ${CMAKE_CURRENT_SOURCE_DIR}/infrastructures/QProfile.cpp)
target_link_libraries(QProfile  Qt5::Widgets ${QProfile_hdr_moc})

add_library(QHoverPoints
            ${CMAKE_CURRENT_SOURCE_DIR}/infrastructures/QHoverPoints.cpp)
target_link_libraries(QHoverPoints  Qt5::Widgets ${QHoverPoints_hdr_moc})

add_library(QCommon
            ${CMAKE_CURRENT_SOURCE_DIR}/templates/QCommon.cpp)
target_link_libraries(QCommon  Qt5::Widgets Qt5::Core ${QCommon_hdr_moc})


include_directories(${Boost_INCLUDE_DIR}
                    ${OpenCL_INCLUDE_DIRS}
                    ${CLOGS_INCLUDE}
                    ${OPENGL_INCLUDE_DIRS} 
                    ${GLUT_INCLUDE_DIRS}
                    $(GLEW_INCLUDE_DIRS)
                    )
add_executable(test_build
                ${SOURCE} ${HEADERS}
                ${QGCVisualizer_ui_moc}
                ${QGCPanel_ui_moc}
                )
target_link_libraries(test_build
  Qt5::Widgets  Qt5::Xml Qt5::Core Qt5::Gui Qt5::OpenGL
  Qt5::Xml Qt5::Declarative
  ${GLM_INCLUDE_DIR} ${Boost_LIBRARIES}  ${OpenCL_LIBRARIES}
  ${QGCVisualizer} ${QGCPanel} ${QGCSetting} ${QGCWidget}
  ${QTransferFunction1D}  ${QProfile} ${QHoverPoints}  ${QCommon}
  ${CLOGS_LIB}/libclogs.so ${OPENGL_LIBRARIES} ${GLUT_LIBRARY}
  dl ${GLEW_LIBRARIES}
  )

Here is the command the compiler is barfing on.

这是编译器正在进行的命令。

[ 94%] Linking CXX executable test_build
/home/sansomk/anaconda/bin/cmake -E cmake_link_script CMakeFiles/test_build.dir/link.txt --verbose=1
/usr/bin/c++    -std=c++11   CMakeFiles/test_build.dir/3rdParty/bench/mfi.cpp.o CMakeFiles/test_build.dir/Graph_Cut/QGCMain.cpp.o CMakeFiles/test_build.dir/Graph_Cut/QGCSetting.cpp.o CMakeFiles/test_build.dir/infrastructures/QSetting.cpp.o CMakeFiles/test_build.dir/Graph_Cut/QGCPanel.cpp.o CMakeFiles/test_build.dir/Graph_Cut/QGCVisualizer.cpp.o CMakeFiles/test_build.dir/Graph_Cut/QGCWidget.cpp.o CMakeFiles/test_build.dir/infrastructures/QHoverPoints.cpp.o CMakeFiles/test_build.dir/infrastructures/QProfile.cpp.o CMakeFiles/test_build.dir/infrastructures/QTransferFunction1D.cpp.o CMakeFiles/test_build.dir/templates/QCommon.cpp.o CMakeFiles/test_build.dir/utilities/QIO.cpp.o CMakeFiles/test_build.dir/utilities/QUtilityCL.cpp.o CMakeFiles/test_build.dir/utilities/QUtilityConsole.cpp.o CMakeFiles/test_build.dir/utilities/QUtilityData.cpp.o CMakeFiles/test_build.dir/utilities/QUtilityGL.cpp.o CMakeFiles/test_build.dir/utilities/QUtilityMath.cpp.o CMakeFiles/test_build.dir/utilities/QUtilityUI.cpp.o  -o test_build -rdynamic /opt/Qt/5.5/gcc_64/lib/libQt5OpenGL.so.5.5.1 /opt/Qt/5.5/gcc_64/lib/libQt5Xml.so.5.5.1 /opt/Qt/5.5/gcc_64/lib/libQt5Declarative.so.5.5.1 -lboost_system -lOpenCL /home/sansomk/code/cuda/clogs-install/lib/libclogs.so -lGLU /usr/lib/nvidia-352/libGL.so -ldl -lGLEW /opt/Qt/5.5/gcc_64/lib/libQt5Widgets.so.5.5.1 /opt/Qt/5.5/gcc_64/lib/libQt5Gui.so.5.5.1 /opt/Qt/5.5/gcc_64/lib/libQt5Script.so.5.5.1 /opt/Qt/5.5/gcc_64/lib/libQt5Core.so.5.5.1 -Wl,-rpath,/opt/Qt/5.5/gcc_64/lib:/home/sansomk/code/cuda/clogs-install/lib:/usr/lib/nvidia-352 
CMakeFiles/test_build.dir/Graph_Cut/QGCPanel.cpp.o: In function `QGCPanel::QGCPanel(QWidget*)':
QGCPanel.cpp:(.text+0x1d3): undefined reference to `vtable for QGCPanel'
QGCPanel.cpp:(.text+0x1e5): undefined reference to `vtable for QGCPanel'
CMakeFiles/test_build.dir/Graph_Cut/QGCPanel.cpp.o: In function `QGCPanel::~QGCPanel()':
QGCPanel.cpp:(.text+0x339): undefined reference to `vtable for QGCPanel'
QGCPanel.cpp:(.text+0x34b): undefined reference to `vtable for QGCPanel'
CMakeFiles/test_build.dir/Graph_Cut/QGCPanel.cpp.o: In function `QList<QProfile*> QObject::findChildren<QProfile*>(QString const&, QFlags<Qt::FindChildOption>) const':
QGCPanel.cpp:(.text._ZNK7QObject12findChildrenIP8QProfileEE5QListIT_ERK7QString6QFlagsIN2Qt15FindChildOptionEE[_ZNK7QObject12findChildrenIP8QProfileEE5QListIT_ERK7QString6QFlagsIN2Qt15FindChildOptionEE]+0x3c): undefined reference to `QProfile::staticMetaObject'
CMakeFiles/test_build.dir/Graph_Cut/QGCVisualizer.cpp.o: In function `QGCVisualizer::QGCVisualizer(QWidget*)':
QGCVisualizer.cpp:(.text+0x1d3): undefined reference to `vtable for QGCVisualizer'
QGCVisualizer.cpp:(.text+0x1e5): undefined reference to `vtable for QGCVisualizer'
CMakeFiles/test_build.dir/Graph_Cut/QGCVisualizer.cpp.o: In function `QGCVisualizer::~QGCVisualizer()':
QGCVisualizer.cpp:(.text+0x25d): undefined reference to `vtable for QGCVisualizer'
QGCVisualizer.cpp:(.text+0x26f): undefined reference to `vtable for QGCVisualizer'
CMakeFiles/test_build.dir/Graph_Cut/QGCWidget.cpp.o: In function `QGCWidget::QGCWidget(QWidget*)':
QGCWidget.cpp:(.text+0x535): undefined reference to `vtable for QGCWidget'
QGCWidget.cpp:(.text+0x547): undefined reference to `vtable for QGCWidget'
CMakeFiles/test_build.dir/Graph_Cut/QGCWidget.cpp.o: In function `QGCWidget::~QGCWidget()':
QGCWidget.cpp:(.text+0x1f62): undefined reference to `vtable for QGCWidget'
QGCWidget.cpp:(.text+0x1f74): undefined reference to `vtable for QGCWidget'
CMakeFiles/test_build.dir/Graph_Cut/QGCWidget.cpp.o: In function `QGCWidget::initData(std::string const&)':
QGCWidget.cpp:(.text+0x3f40): undefined reference to `QGCWidget::signalPartitionInitialized(unsigned long, float*)'
QGCWidget.cpp:(.text+0x3f75): undefined reference to `QGCWidget::signalHistogramInitialized(unsigned long, float*)'
CMakeFiles/test_build.dir/infrastructures/QHoverPoints.cpp.o: In function `QHoverPoints::QHoverPoints(QWidget*, QHoverPoints::PointShape)':
QHoverPoints.cpp:(.text+0x58): undefined reference to `vtable for QHoverPoints'
CMakeFiles/test_build.dir/infrastructures/QHoverPoints.cpp.o: In function `QHoverPoints::eventFilter(QObject*, QEvent*)':
QHoverPoints.cpp:(.text+0x70b): undefined reference to `QHoverPoints::signalPointsChanged()'
QHoverPoints.cpp:(.text+0xc46): undefined reference to `QHoverPoints::signalPointsChanged()'
QHoverPoints.cpp:(.text+0xd25): undefined reference to `QHoverPoints::signalPointsChanged()'
QHoverPoints.cpp:(.text+0xe03): undefined reference to `QHoverPoints::signalPointsChanged()'
CMakeFiles/test_build.dir/infrastructures/QHoverPoints.cpp.o: In function `QHoverPoints::firePointChange()':
QHoverPoints.cpp:(.text+0x21bd): undefined reference to `QHoverPoints::signalPointsChanged(QPolygonF)'
CMakeFiles/test_build.dir/infrastructures/QHoverPoints.cpp.o: In function `QHoverPoints::load(std::string const&, QSize const&)':
QHoverPoints.cpp:(.text+0x2a62): undefined reference to `QHoverPoints::signalPointsChanged()'
CMakeFiles/test_build.dir/infrastructures/QProfile.cpp.o: In function `QProfile::QProfile(QWidget*)':
QProfile.cpp:(.text+0x43): undefined reference to `vtable for QProfile'
QProfile.cpp:(.text+0x55): undefined reference to `vtable for QProfile'
CMakeFiles/test_build.dir/infrastructures/QProfile.cpp.o: In function `QProfile::~QProfile()':
QProfile.cpp:(.text+0x575): undefined reference to `vtable for QProfile'
QProfile.cpp:(.text+0x587): undefined reference to `vtable for QProfile'
CMakeFiles/test_build.dir/infrastructures/QTransferFunction1D.cpp.o: In function `QTransferFunction1D::QTransferFunction1D(QWidget*)':
QTransferFunction1D.cpp:(.text+0x1d5): undefined reference to `vtable for QTransferFunction1D'
QTransferFunction1D.cpp:(.text+0x1e7): undefined reference to `vtable for QTransferFunction1D'
CMakeFiles/test_build.dir/infrastructures/QTransferFunction1D.cpp.o: In function `QTransferFunction1D::resizeEvent(QResizeEvent*)':
QTransferFunction1D.cpp:(.text+0x1364): undefined reference to `QTransferFunction1D::signalControlPointsChanged()'
CMakeFiles/test_build.dir/infrastructures/QTransferFunction1D.cpp.o: In function `QTransferFunction1D::showEvent(QShowEvent*)':
QTransferFunction1D.cpp:(.text+0x138e): undefined reference to `QTransferFunction1D::signalControlPointsChanged()'
CMakeFiles/test_build.dir/infrastructures/QTransferFunction1D.cpp.o: In function `QTransferFunction1D::slotUpdateTransferFunction()':
QTransferFunction1D.cpp:(.text+0x1558): undefined reference to `QTransferFunction1D::signalControlPointsChanged()'
CMakeFiles/test_build.dir/templates/QCommon.cpp.o: In function `QCommon::QCommon()':
QCommon.cpp:(.text+0x3b): undefined reference to `vtable for QCommon'
QCommon.cpp:(.text+0x4d): undefined reference to `vtable for QCommon'
CMakeFiles/test_build.dir/templates/QCommon.cpp.o: In function `QCommon::QCommon(QWidget*, QFlags<Qt::WindowType>)':
QCommon.cpp:(.text+0xf6): undefined reference to `vtable for QCommon'
QCommon.cpp:(.text+0x108): undefined reference to `vtable for QCommon'
CMakeFiles/test_build.dir/templates/QCommon.cpp.o: In function `QCommon::~QCommon()':
QCommon.cpp:(.text+0x181): undefined reference to `vtable for QCommon'
CMakeFiles/test_build.dir/templates/QCommon.cpp.o:QCommon.cpp:(.text+0x193): more undefined references to `vtable for QCommon' follow
collect2: error: ld returned 1 exit status
make[2]: *** [test_build] Error 1
make[2]: Leaving directory `/home/sansomk/code/cuda/JF-Cut/src/build'
make[1]: *** [CMakeFiles/test_build.dir/all] Error 2
make[1]: Leaving directory `/home/sansomk/code/cuda/JF-Cut/src/build'
make: *** [all] Error 2

1 个解决方案

#1


0  

I think I figured it out. I was making things to complicated by creating the target link libraries. My code doesn't run correctly, but it's a start. I instead appended the generated moc and ui files.

我想我算出来了。我通过创建目标链接库使事情变得复杂。我的代码不能正常运行,但这是一个开始。相反,我添加了生成的moc和ui文件。

cmake_minimum_required(VERSION 3.0.0)

project(JF-Cut)


include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
if(COMPILER_SUPPORTS_CXX11)
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
#elseif(COMPILER_SUPPORTS_CXX0X)
#   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
else()
        message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
endif()


set(FIND_GLM ./FindGLM.cmake)

# Find the QtWidgets library
find_package(OpenCL REQUIRED)
find_package(OpenGL REQUIRED)
#find_package(GLM REQUIRED)
#include_directories(${GLM_INCLUDE_DIRS})
#link_directories(${GLM_LIBRARY_DIRS})
#add_definitions(${GLM_DEFINITIONS})

find_package(Qt5 COMPONENTS Core Gui
            OpenGL Xml Declarative
            Widgets 
            REQUIRED
            )
find_package(GLEW REQUIRED )
find_package(Boost COMPONENTS system)

#FIND_PATH(GLM_INCLUDE_DIR /usr/include)

# Interoperation with clogs
option(CLOGS " use clogs algorithms " OFF)
if (CLOGS)
  find_path(CLOGS_INCLUDE clogs/clogs.h)
  find_library(CLOGS_LIB clogs)
  include_directories(${CLOGS_INCLUDE})
  add_definitions(-DHAVE_CLOGS)
endif()

#set(CMAKE_AUTOMOC ON)
#SET(CMAKE_AUTOUIC ON)

add_definitions(-DUNICODE
                -DQT_LARGEFILE_SUPPORT
                -D__CL_ENABLE_EXCEPTIONS
                -D__CL_ENABLE_DEBUG_
                -DQT_CORE_LIB
                -DQT_GUI_LIB
                -DQT_DLL
                -DQT_XML_LIB
                -DNOMINMAX
                )

SET(CMAKE_INCLUDE_CURRENT_DIR ON)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})

set(SOURCE
  ${CMAKE_CURRENT_SOURCE_DIR}/3rdParty/bench/mfi.cpp
  ${CMAKE_CURRENT_SOURCE_DIR}/Graph_Cut/QGCMain.cpp
  ${CMAKE_CURRENT_SOURCE_DIR}/Graph_Cut/QGCSetting.cpp
  ${CMAKE_CURRENT_SOURCE_DIR}/infrastructures/QSetting.cpp
  ${CMAKE_CURRENT_SOURCE_DIR}/Graph_Cut/QGCPanel.cpp
  ${CMAKE_CURRENT_SOURCE_DIR}/Graph_Cut/QGCVisualizer.cpp
  ${CMAKE_CURRENT_SOURCE_DIR}/Graph_Cut/QGCWidget.cpp
  ${CMAKE_CURRENT_SOURCE_DIR}/infrastructures/QHoverPoints.cpp
  ${CMAKE_CURRENT_SOURCE_DIR}/infrastructures/QProfile.cpp
  ${CMAKE_CURRENT_SOURCE_DIR}/infrastructures/QTransferFunction1D.cpp
  ${CMAKE_CURRENT_SOURCE_DIR}/templates/QCommon.cpp
  ${CMAKE_CURRENT_SOURCE_DIR}/utilities/QIO.cpp
  ${CMAKE_CURRENT_SOURCE_DIR}/utilities/QUtilityCL.cpp
  ${CMAKE_CURRENT_SOURCE_DIR}/utilities/QUtilityConsole.cpp
  ${CMAKE_CURRENT_SOURCE_DIR}/utilities/QUtilityData.cpp
  ${CMAKE_CURRENT_SOURCE_DIR}/utilities/QUtilityGL.cpp
  ${CMAKE_CURRENT_SOURCE_DIR}/utilities/QUtilityMath.cpp
  ${CMAKE_CURRENT_SOURCE_DIR}/utilities/QUtilityUI.cpp

)
set(HEADERS
  ${CMAKE_CURRENT_SOURCE_DIR}/3rdParty/bench/mfi.h
  ${CMAKE_CURRENT_SOURCE_DIR}/3rdParty/cl/cl_stacktrace.hpp
  ${CMAKE_CURRENT_SOURCE_DIR}/3rdParty/stacktrace/call_stack.hpp
  ${CMAKE_CURRENT_SOURCE_DIR}/3rdParty/stacktrace/call_stack_msvc.hpp
  ${CMAKE_CURRENT_SOURCE_DIR}/3rdParty/stacktrace/call_stack_gcc.hpp
  ${CMAKE_CURRENT_SOURCE_DIR}/Graph_Cut/QGCSetting.h
  ${CMAKE_CURRENT_SOURCE_DIR}/infrastructures/QError.h
  ${CMAKE_CURRENT_SOURCE_DIR}/3rdParty/stacktrace/StackWalker.hpp
  ${CMAKE_CURRENT_SOURCE_DIR}/3rdParty/stacktrace/StackWalker.h
  ${CMAKE_CURRENT_SOURCE_DIR}/infrastructures/QSetting.h
  ${CMAKE_CURRENT_SOURCE_DIR}/infrastructures/QStructure.h
  ${CMAKE_CURRENT_SOURCE_DIR}/Graph_Cut/QGCPanel.h
  ${CMAKE_CURRENT_SOURCE_DIR}/Graph_Cut/QGCVisualizer.h
  ${CMAKE_CURRENT_SOURCE_DIR}/Graph_Cut/QGCWidget.h
  ${CMAKE_CURRENT_SOURCE_DIR}/infrastructures/QHoverPoints.h
  ${CMAKE_CURRENT_SOURCE_DIR}/infrastructures/QProfile.h
  ${CMAKE_CURRENT_SOURCE_DIR}/infrastructures/QTransferFunction1D.h
  ${CMAKE_CURRENT_SOURCE_DIR}/templates/QCommon.h
  ${CMAKE_CURRENT_SOURCE_DIR}/utilities/QIO.h
  ${CMAKE_CURRENT_SOURCE_DIR}/utilities/QUtilityCL.h
  ${CMAKE_CURRENT_SOURCE_DIR}/utilities/QUtilityConsole.h
  ${CMAKE_CURRENT_SOURCE_DIR}/utilities/QUtilityData.h
  ${CMAKE_CURRENT_SOURCE_DIR}/utilities/QUtilityGL.h
  ${CMAKE_CURRENT_SOURCE_DIR}/utilities/QUtilityMath.h
  ${CMAKE_CURRENT_SOURCE_DIR}/utilities/QUtilityUI.h
  ${CMAKE_CURRENT_SOURCE_DIR}/cl/GraphCut/graphcut_bfs_block.cl
  ${CMAKE_CURRENT_SOURCE_DIR}/cl/GraphCut/graphcut_compute_capacity.cl
  ${CMAKE_CURRENT_SOURCE_DIR}/cl/GraphCut/graphcut_compute_cut.cl
  ${CMAKE_CURRENT_SOURCE_DIR}/cl/GraphCut/graphcut_compute_excessflow.cl
  ${CMAKE_CURRENT_SOURCE_DIR}/cl/GraphCut/graphcut_compute_flow.cl
  ${CMAKE_CURRENT_SOURCE_DIR}/cl/GraphCut/graphcut_compute_tag.cl
  ${CMAKE_CURRENT_SOURCE_DIR}/cl/GraphCut/graphcut_count_block.cl
  ${CMAKE_CURRENT_SOURCE_DIR}/cl/GraphCut/graphcut_global_relabel.cl
  ${CMAKE_CURRENT_SOURCE_DIR}/cl/GraphCut/graphcut_histogram.cl
  ${CMAKE_CURRENT_SOURCE_DIR}/cl/GraphCut/graphcut_kmeans.cl
  ${CMAKE_CURRENT_SOURCE_DIR}/cl/GraphCut/graphcut_push_relabel.cl
  ${CMAKE_CURRENT_SOURCE_DIR}/cl/GraphCut/graphcut_push_relabel_fast.cl
  ${CMAKE_CURRENT_SOURCE_DIR}/cl/GraphCut/graphcut_render_ray_casting.cl
  ${CMAKE_CURRENT_SOURCE_DIR}/cl/GraphCut/graphcut_render_ray_casting_feature.cl
  ${CMAKE_CURRENT_SOURCE_DIR}/cl/GraphCut/graphcut_render_ray_casting_preint.cl
)


QT5_WRAP_CPP(QGCPanel_hdr_moc ${CMAKE_CURRENT_SOURCE_DIR}/Graph_Cut/QGCPanel.h )
qt5_wrap_ui(QGCPanel_ui_moc  ${CMAKE_CURRENT_SOURCE_DIR}/ui/Graph_Cut/QGCPanel.ui)

QT5_WRAP_CPP(QGCVisualizer_hdr_moc  ${CMAKE_CURRENT_SOURCE_DIR}/Graph_Cut/QGCVisualizer.h)
qt5_wrap_ui(QGCVisualizer_ui_moc  ${CMAKE_CURRENT_SOURCE_DIR}/ui/Graph_Cut/QGCVisualizer.ui)

QT5_WRAP_CPP(QGCWidget_hdr_moc  ${CMAKE_CURRENT_SOURCE_DIR}/Graph_Cut/QGCWidget.h )
QT5_WRAP_CPP(QTransferFunction1D_hdr_moc  ${CMAKE_CURRENT_SOURCE_DIR}/infrastructures/QTransferFunction1D.h )
QT5_WRAP_CPP(QProfile_hdr_moc  ${CMAKE_CURRENT_SOURCE_DIR}/infrastructures/QProfile.h )
QT5_WRAP_CPP(QHoverPoints_hdr_moc  ${CMAKE_CURRENT_SOURCE_DIR}/infrastructures/QHoverPoints.h )
QT5_WRAP_CPP(QCommon_hdr_moc  ${CMAKE_CURRENT_SOURCE_DIR}/templates/QCommon.h )

LIST(APPEND SOURCE ${QGCPanel_hdr_moc} ${QCommon_hdr_moc}
    ${QGCVisualizer_ui_moc} ${QGCPanel_ui_moc}
    ${QGCVisualizer_hdr_moc} ${QGCPanel_hdr_moc}
    ${QGCWidget_hdr_moc}  ${QTransferFunction1D_hdr_moc}
    ${QProfile_hdr_moc} ${QHoverPoints_hdr_moc}
    ${QCommon_hdr_moc}
    )

include_directories(${Boost_INCLUDE_DIR}
                    ${OpenCL_INCLUDE_DIRS}
                    ${CLOGS_INCLUDE}
                    ${OPENGL_INCLUDE_DIRS} 
                    ${GLUT_INCLUDE_DIRS}
                    $(GLEW_INCLUDE_DIRS)
                    )

add_executable(test_build
                ${SOURCE} ${HEADERS}
                )
target_link_libraries(test_build
  Qt5::Widgets  Qt5::Xml Qt5::Core Qt5::Gui Qt5::OpenGL
  Qt5::Xml Qt5::Declarative
  ${GLM_INCLUDE_DIR} ${Boost_LIBRARIES}  ${OpenCL_LIBRARIES}
  ${CLOGS_LIB}/libclogs.so ${OPENGL_LIBRARIES} ${GLUT_LIBRARY}
  dl ${GLEW_LIBRARIES}
  )

#1


0  

I think I figured it out. I was making things to complicated by creating the target link libraries. My code doesn't run correctly, but it's a start. I instead appended the generated moc and ui files.

我想我算出来了。我通过创建目标链接库使事情变得复杂。我的代码不能正常运行,但这是一个开始。相反,我添加了生成的moc和ui文件。

cmake_minimum_required(VERSION 3.0.0)

project(JF-Cut)


include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
if(COMPILER_SUPPORTS_CXX11)
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
#elseif(COMPILER_SUPPORTS_CXX0X)
#   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
else()
        message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
endif()


set(FIND_GLM ./FindGLM.cmake)

# Find the QtWidgets library
find_package(OpenCL REQUIRED)
find_package(OpenGL REQUIRED)
#find_package(GLM REQUIRED)
#include_directories(${GLM_INCLUDE_DIRS})
#link_directories(${GLM_LIBRARY_DIRS})
#add_definitions(${GLM_DEFINITIONS})

find_package(Qt5 COMPONENTS Core Gui
            OpenGL Xml Declarative
            Widgets 
            REQUIRED
            )
find_package(GLEW REQUIRED )
find_package(Boost COMPONENTS system)

#FIND_PATH(GLM_INCLUDE_DIR /usr/include)

# Interoperation with clogs
option(CLOGS " use clogs algorithms " OFF)
if (CLOGS)
  find_path(CLOGS_INCLUDE clogs/clogs.h)
  find_library(CLOGS_LIB clogs)
  include_directories(${CLOGS_INCLUDE})
  add_definitions(-DHAVE_CLOGS)
endif()

#set(CMAKE_AUTOMOC ON)
#SET(CMAKE_AUTOUIC ON)

add_definitions(-DUNICODE
                -DQT_LARGEFILE_SUPPORT
                -D__CL_ENABLE_EXCEPTIONS
                -D__CL_ENABLE_DEBUG_
                -DQT_CORE_LIB
                -DQT_GUI_LIB
                -DQT_DLL
                -DQT_XML_LIB
                -DNOMINMAX
                )

SET(CMAKE_INCLUDE_CURRENT_DIR ON)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})

set(SOURCE
  ${CMAKE_CURRENT_SOURCE_DIR}/3rdParty/bench/mfi.cpp
  ${CMAKE_CURRENT_SOURCE_DIR}/Graph_Cut/QGCMain.cpp
  ${CMAKE_CURRENT_SOURCE_DIR}/Graph_Cut/QGCSetting.cpp
  ${CMAKE_CURRENT_SOURCE_DIR}/infrastructures/QSetting.cpp
  ${CMAKE_CURRENT_SOURCE_DIR}/Graph_Cut/QGCPanel.cpp
  ${CMAKE_CURRENT_SOURCE_DIR}/Graph_Cut/QGCVisualizer.cpp
  ${CMAKE_CURRENT_SOURCE_DIR}/Graph_Cut/QGCWidget.cpp
  ${CMAKE_CURRENT_SOURCE_DIR}/infrastructures/QHoverPoints.cpp
  ${CMAKE_CURRENT_SOURCE_DIR}/infrastructures/QProfile.cpp
  ${CMAKE_CURRENT_SOURCE_DIR}/infrastructures/QTransferFunction1D.cpp
  ${CMAKE_CURRENT_SOURCE_DIR}/templates/QCommon.cpp
  ${CMAKE_CURRENT_SOURCE_DIR}/utilities/QIO.cpp
  ${CMAKE_CURRENT_SOURCE_DIR}/utilities/QUtilityCL.cpp
  ${CMAKE_CURRENT_SOURCE_DIR}/utilities/QUtilityConsole.cpp
  ${CMAKE_CURRENT_SOURCE_DIR}/utilities/QUtilityData.cpp
  ${CMAKE_CURRENT_SOURCE_DIR}/utilities/QUtilityGL.cpp
  ${CMAKE_CURRENT_SOURCE_DIR}/utilities/QUtilityMath.cpp
  ${CMAKE_CURRENT_SOURCE_DIR}/utilities/QUtilityUI.cpp

)
set(HEADERS
  ${CMAKE_CURRENT_SOURCE_DIR}/3rdParty/bench/mfi.h
  ${CMAKE_CURRENT_SOURCE_DIR}/3rdParty/cl/cl_stacktrace.hpp
  ${CMAKE_CURRENT_SOURCE_DIR}/3rdParty/stacktrace/call_stack.hpp
  ${CMAKE_CURRENT_SOURCE_DIR}/3rdParty/stacktrace/call_stack_msvc.hpp
  ${CMAKE_CURRENT_SOURCE_DIR}/3rdParty/stacktrace/call_stack_gcc.hpp
  ${CMAKE_CURRENT_SOURCE_DIR}/Graph_Cut/QGCSetting.h
  ${CMAKE_CURRENT_SOURCE_DIR}/infrastructures/QError.h
  ${CMAKE_CURRENT_SOURCE_DIR}/3rdParty/stacktrace/StackWalker.hpp
  ${CMAKE_CURRENT_SOURCE_DIR}/3rdParty/stacktrace/StackWalker.h
  ${CMAKE_CURRENT_SOURCE_DIR}/infrastructures/QSetting.h
  ${CMAKE_CURRENT_SOURCE_DIR}/infrastructures/QStructure.h
  ${CMAKE_CURRENT_SOURCE_DIR}/Graph_Cut/QGCPanel.h
  ${CMAKE_CURRENT_SOURCE_DIR}/Graph_Cut/QGCVisualizer.h
  ${CMAKE_CURRENT_SOURCE_DIR}/Graph_Cut/QGCWidget.h
  ${CMAKE_CURRENT_SOURCE_DIR}/infrastructures/QHoverPoints.h
  ${CMAKE_CURRENT_SOURCE_DIR}/infrastructures/QProfile.h
  ${CMAKE_CURRENT_SOURCE_DIR}/infrastructures/QTransferFunction1D.h
  ${CMAKE_CURRENT_SOURCE_DIR}/templates/QCommon.h
  ${CMAKE_CURRENT_SOURCE_DIR}/utilities/QIO.h
  ${CMAKE_CURRENT_SOURCE_DIR}/utilities/QUtilityCL.h
  ${CMAKE_CURRENT_SOURCE_DIR}/utilities/QUtilityConsole.h
  ${CMAKE_CURRENT_SOURCE_DIR}/utilities/QUtilityData.h
  ${CMAKE_CURRENT_SOURCE_DIR}/utilities/QUtilityGL.h
  ${CMAKE_CURRENT_SOURCE_DIR}/utilities/QUtilityMath.h
  ${CMAKE_CURRENT_SOURCE_DIR}/utilities/QUtilityUI.h
  ${CMAKE_CURRENT_SOURCE_DIR}/cl/GraphCut/graphcut_bfs_block.cl
  ${CMAKE_CURRENT_SOURCE_DIR}/cl/GraphCut/graphcut_compute_capacity.cl
  ${CMAKE_CURRENT_SOURCE_DIR}/cl/GraphCut/graphcut_compute_cut.cl
  ${CMAKE_CURRENT_SOURCE_DIR}/cl/GraphCut/graphcut_compute_excessflow.cl
  ${CMAKE_CURRENT_SOURCE_DIR}/cl/GraphCut/graphcut_compute_flow.cl
  ${CMAKE_CURRENT_SOURCE_DIR}/cl/GraphCut/graphcut_compute_tag.cl
  ${CMAKE_CURRENT_SOURCE_DIR}/cl/GraphCut/graphcut_count_block.cl
  ${CMAKE_CURRENT_SOURCE_DIR}/cl/GraphCut/graphcut_global_relabel.cl
  ${CMAKE_CURRENT_SOURCE_DIR}/cl/GraphCut/graphcut_histogram.cl
  ${CMAKE_CURRENT_SOURCE_DIR}/cl/GraphCut/graphcut_kmeans.cl
  ${CMAKE_CURRENT_SOURCE_DIR}/cl/GraphCut/graphcut_push_relabel.cl
  ${CMAKE_CURRENT_SOURCE_DIR}/cl/GraphCut/graphcut_push_relabel_fast.cl
  ${CMAKE_CURRENT_SOURCE_DIR}/cl/GraphCut/graphcut_render_ray_casting.cl
  ${CMAKE_CURRENT_SOURCE_DIR}/cl/GraphCut/graphcut_render_ray_casting_feature.cl
  ${CMAKE_CURRENT_SOURCE_DIR}/cl/GraphCut/graphcut_render_ray_casting_preint.cl
)


QT5_WRAP_CPP(QGCPanel_hdr_moc ${CMAKE_CURRENT_SOURCE_DIR}/Graph_Cut/QGCPanel.h )
qt5_wrap_ui(QGCPanel_ui_moc  ${CMAKE_CURRENT_SOURCE_DIR}/ui/Graph_Cut/QGCPanel.ui)

QT5_WRAP_CPP(QGCVisualizer_hdr_moc  ${CMAKE_CURRENT_SOURCE_DIR}/Graph_Cut/QGCVisualizer.h)
qt5_wrap_ui(QGCVisualizer_ui_moc  ${CMAKE_CURRENT_SOURCE_DIR}/ui/Graph_Cut/QGCVisualizer.ui)

QT5_WRAP_CPP(QGCWidget_hdr_moc  ${CMAKE_CURRENT_SOURCE_DIR}/Graph_Cut/QGCWidget.h )
QT5_WRAP_CPP(QTransferFunction1D_hdr_moc  ${CMAKE_CURRENT_SOURCE_DIR}/infrastructures/QTransferFunction1D.h )
QT5_WRAP_CPP(QProfile_hdr_moc  ${CMAKE_CURRENT_SOURCE_DIR}/infrastructures/QProfile.h )
QT5_WRAP_CPP(QHoverPoints_hdr_moc  ${CMAKE_CURRENT_SOURCE_DIR}/infrastructures/QHoverPoints.h )
QT5_WRAP_CPP(QCommon_hdr_moc  ${CMAKE_CURRENT_SOURCE_DIR}/templates/QCommon.h )

LIST(APPEND SOURCE ${QGCPanel_hdr_moc} ${QCommon_hdr_moc}
    ${QGCVisualizer_ui_moc} ${QGCPanel_ui_moc}
    ${QGCVisualizer_hdr_moc} ${QGCPanel_hdr_moc}
    ${QGCWidget_hdr_moc}  ${QTransferFunction1D_hdr_moc}
    ${QProfile_hdr_moc} ${QHoverPoints_hdr_moc}
    ${QCommon_hdr_moc}
    )

include_directories(${Boost_INCLUDE_DIR}
                    ${OpenCL_INCLUDE_DIRS}
                    ${CLOGS_INCLUDE}
                    ${OPENGL_INCLUDE_DIRS} 
                    ${GLUT_INCLUDE_DIRS}
                    $(GLEW_INCLUDE_DIRS)
                    )

add_executable(test_build
                ${SOURCE} ${HEADERS}
                )
target_link_libraries(test_build
  Qt5::Widgets  Qt5::Xml Qt5::Core Qt5::Gui Qt5::OpenGL
  Qt5::Xml Qt5::Declarative
  ${GLM_INCLUDE_DIR} ${Boost_LIBRARIES}  ${OpenCL_LIBRARIES}
  ${CLOGS_LIB}/libclogs.so ${OPENGL_LIBRARIES} ${GLUT_LIBRARY}
  dl ${GLEW_LIBRARIES}
  )