linux使用qt4却报qt5错误,Ubuntu 13.04 CMake和Qt4和Qt5

我正在使用新的Ubuntu 13.04并通过apt-get install安装了qt.现在似乎安装了qt5.使用qt5的CMake项目运行良好.

我在ubuntu 12.04上安装了qt4的机器上运行相同的代码并且运行良好.但现在我得到以下错误:(不要担心增强的东西,它来自父CMakeLists.txt)

CMake Error at /usr/share/cmake-2.8/Modules/FindQt4.cmake:619 (message):

Could NOT find QtCore. Check

/home/simongroth/Projects/pgCrazyMachinesVR/src-build2/CMakeFiles/CMakeError.log

for more details.

Call Stack (most recent call first):

Views/LevelEditor/CMakeLists.txt:32 (FIND_PACKAGE)

CMake Warning at /usr/share/cmake-2.8/Modules/FindQt4.cmake:615 (message):

/usr/bin/qmake-qt4 reported QT_INSTALL_LIBS as "/usr/lib/x86_64-linux-gnu"

but QtCore could not be found there. Qt is NOT installed correctly for the

target build environment.

Call Stack (most recent call first):

Views/LevelEditor/CMakeLists.txt:32 (FIND_PACKAGE)

-- Boost version: 1.49.0

-- Found the following Boost libraries:

-- thread

-- Configuring incomplete, errors occurred!

这是我的CMakeLists.txt.有没有人知道如何在新的ubuntu上同时使用qt4和qt5?提前致谢.

FILE(GLOB COLLECTED_HDR_FILES *.hpp)

FILE(GLOB COLLECTED_SRC_FILES *.cpp)

FILE(GLOB COLLECTED_UI_FILES *.ui)

FILE(GLOB COLLECTED_RCS_FILES *.qrc)

SET( SRCS

${COLLECTED_SRC_FILES}

)

SET( HDRS

${COLLECTED_HDR_FILES}

)

SET( MOC_HDRS

${HDRS}

)

SET( UIS

${COLLECTED_UI_FILES}

)

SET( RCS

${COLLECTED_UI_FILES}

MainWindow.qrc

)

# enable warnings

ADD_DEFINITIONS(-Wall)

# this command finds Qt4 libraries and sets all required variables

# note that it's Qt4, not QT4 or qt4

FIND_PACKAGE(Qt4 REQUIRED)

FIND_PACKAGE(OpenGL REQUIRED)

# by default only QtCore and QtGui modules are enabled

# other modules must be enabled like this:

SET(QT_USE_QTXML TRUE)

SET(QT_USE_QTOPENGL TRUE)

# add some useful macros and variables

# (QT_USE_FILE is a variable defined by FIND_PACKAGE( Qt4 ) that contains a path to CMake script)

INCLUDE( ${QT_USE_FILE} )

# this command will generate rules that will run rcc on all files from SAMPLE_RCS

# in result SAMPLE_RC_SRCS variable will contain paths to files produced by rcc

QT4_ADD_RESOURCES( RC_SRCS ${RCS} )

# this will run uic on .ui files:

QT4_WRAP_UI( UI_HDRS ${UIS} )

# and finally this will run moc:

QT4_WRAP_CPP( MOC_SRCS ${MOC_HDRS} ${UI_HDRS} )

# we need this to be able to include headers produced by uic in our code

# (CMAKE_BINARY_DIR holds a path to the build directory, while INCLUDE_DIRECTORIES() works just like INCLUDEPATH from qmake)

INCLUDE_DIRECTORIES( ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${OPENGL_INCLUDE_DIR})

# here we instruct CMake to build executable from all of the source files

ADD_EXECUTABLE( LevelEditor ${HDRS} ${SRCS} ${MOC_SRCS} ${RC_SRCS} ${UI_HDRS} )

# last thing we have to do is to tell CMake what libraries our executable needs,

# luckily FIND_PACKAGE prepared QT_LIBRARIES variable for us:

TARGET_LINK_LIBRARIES( LevelEditor ${QT_LIBRARIES} ${OPENGL_LIBRARIES})

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值