1

我将一个项目从 qmake(最初我使用 qt-creator 在 mac/linux/win 上构建它)转换为 cmake,我得到了很多链接错误。

例如:

架构 x86_64 的未定义符号:“runion(QtRegion const&, QtRegion const&)”,引用自:3DView.cpp.o 中的 Q3DView::ReloadLineData() “pafrand(int)”,引用自:

我的简历:

CONFIG += debug_and_release
QT            += core gui opengl
DEFINES       += _TEST1
TEMPLATE      = app
TARGET        = test
HEADERS       = xxx.h \
                xxxxxx.h \
                etc.h
    Libs/include/generic/xxxxxx.h

SOURCES       = xxxx.cpp \
                xxx.cpp \
                xxxx.cpp 

INCLUDEPATH   += Libs/include
INCLUDEPATH   += ../plugin/srv

RESOURCES     = resource.qrc

##### LINUX
unix:!macx:INCLUDEPATH += . /usr/local/include/boost  
unix:!macx:LIBS += -L/usr/local/lib
unix:!macx:LIBS += -lboost_system -lboost_thread
!win32:!macx: LIBS = -lGL -lGLU
########

#### MAC
macx:INCLUDEPATH += . /usr/local/include/boost
macx:LIBS += -L/usr/local/lib
macx:LIBS += -lboost_system-mt -lboost_thread-mt
macx:QMAKE_LFLAGS_RPATH += /usr/local/lib
####

QMAKE_CXXFLAGS_WARN_ON =

FORMS += \
    UI/xxx.ui \
    UI/xx.ui

还有我的cmake文件版本:

project( test )

cmake_minimum_required( VERSION 2.6 )

if(APPLE)
set(CMAKE_OSX_ARCHITECTURES x86_64)
ENDIF()

set ( CMAKE_BUILD_TYPE Debug )

add_definitions ( -Wall )

find_package ( Qt4 REQUIRED )

FIND_PACKAGE(Boost)
IF (Boost_FOUND)
    INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIR})
    ADD_DEFINITIONS( "-DHAS_BOOST" )
ENDIF()

find_package(GLUT)
find_package(OpenGL)
IF(APPLE)
SET(CMAKE_CXX_LINK_FLAGS "-framework OpenGL -framework GLUT")
ENDIF(APPLE)

set ( test_HDRS
    xxxx.h
    xxxxxx.h
    xxxx.h
    )

set ( test_SRCS
    xxxxx.cpp
    xxx.cpp
    xxxxx.cpp
    )

set ( test_UIS
    UI/xx.ui
    UI/xxxx.ui
    )
QT4_WRAP_UI(UIS ${test_UIS})

set ( test_RSCS
    resource.qrc
    )

QT4_ADD_RESOURCES(RSCS ${test_RSCS})

QT4_WRAP_CPP(MOCS ${test_HDRS})

INCLUDE(${QT_USE_FILE})
ADD_DEFINITIONS(${QT_DEFINITIONS})

include_directories (
    ${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}
    ${QT_QTCORE_INCLUDE_DIR} ${QT_QTGUI_INCLUDE_DIR} ${QT_QTCORE_INCLUDE_DIR} ${QT_QTGUI_INCLUDE_DIR} ${QT_QTOPENGL_INCLUDE_DIR}
    Libs/include
    /usr/local/include/boost
    ../plugin/srv)

link_directories (
        /usr/local/lib
    )

add_executable ( test ${test_SRCS} ${UIS} ${RSCS} ${TRS} ${MOCS} )

target_link_libraries ( test  ${QT_LIBRARIES} ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTOPENGL_LIBRARY} )

我尝试了很多我在网上找到的不同的东西,但总是同样的问题。有任何想法吗?谢谢

4

1 回答 1

0

你没有-lqgis_core -lqgis_gui在你的CMakeLists.txt. 添加qgis_coreqgis_gui调用target_link_libraries()

于 2012-11-25T10:15:42.393 回答