这里制作文件非常新,所以如果这是一个菜鸟问题,请原谅我。我似乎无法在互联网上找到答案。
我从github分叉了一个公共存储库,它本身应该是下载,制作和运行的存储库,但我已经修复了他们的make文件中的六个错误,试图让它运行。现在我要回到这一点,这似乎与CMake没有找到正确的QT4命令有关。
当我在构建文件夹中时,指令(根据存储库的所有者)说要输入“cmake ..” - 这是对父文件夹中CMakeList.txt的明显引用。文件是hosted on Github,抛出错误的行是第94行,它说:
QT4_ADD_RESOURCES(OFFNAO_RES_SRCS ${OFFNAO_RES})
我正在尝试在Ubuntu 14.04.5上构建这个程序(因为它是最初构建的操作系统,我可以在它工作后进行升级)。 它吐出的错误文本是:
CMake Error at CMakeLists.txt:94(QT$_ADD_RESOURCES):
Unknown CMake command "QT4_ADD_RESOURCES".
- 配置不完整,发生错误!
我安装了qt4-dev-tools(它还安装了所有qt4库)。 我似乎无法找到如何让CMake识别QT4及其命令。
我是CMake的新手,这是我第一次遇到QT4,所以我不知道我在寻找什么。如果需要,很高兴提供更多信息。感谢所有帮助。
编辑: 这是offnao CMakeList.txt的内容:
cmake_minimum_required(VERSION 2.8.0 FATAL_ERROR)
PROJECT(OFFNAO)
INCLUDE_DIRECTORIES("${CMAKE_CURRENT_BINARY_DIR}")
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIR})
INCLUDE_DIRECTORIES(${CTC_DIR}/libnaoqi/include)
INCLUDE_DIRECTORIES(${CTC_DIR}/zlib/include)
INCLUDE_DIRECTORIES(${CTC_DIR}/../sysroot_legacy/usr/include)
SET(OFFNAO_CXX_SRCS
utils/OverlayPainter.cpp
// contents skipped for brevity
tabs/teamBallTab.cpp
)
SET(OFFNAO_MOC
readers/reader.hpp
// contents skipped for brevity
tabs/teamBallTab.hpp
)
if(CMAKE_TOOLCHAIN_FILE)
list(APPEND OFFNAO_CXX_SRCS tabs/cameraTab.cpp)
list(APPEND OFFNAO_MOC tabs/cameraTab.hpp)
endif(CMAKE_TOOLCHAIN_FILE)
SET(OFFNAO_UI
visualiser.ui
ConnectionBar.ui
tabs/LogTab.ui
tabs/LogsTab.ui
)
SET(OFFNAO_RES
resources/visualiser_resources.qrc
)
# build cxx files for resources
QT4_ADD_RESOURCES(OFFNAO_RES_SRCS ${OFFNAO_RES})
# build ui_XXX files from the XML-style .ui files
QT4_WRAP_UI(OFFNAO_UI_SRCS ${OFFNAO_UI})
# this moc's the above variable and appends to the cxx sources
QT4_WRAP_CPP(OFFNAO_MOC_SRCS ${OFFNAO_MOC})
ADD_EXECUTABLE(offnao.bin ${OFFNAO_CXX_SRCS} ${OFFNAO_RES_SRCS} ${OFFNAO_MOC_SRCS} ${OFFNAO_UI_SRCS})
cotire(offnao.bin)
set_source_files_properties(
tabs/graphTab.cpp
tabs/plots.cpp
tabs/walkTab.cpp
tabs/zmpTab.cpp
main.cpp
visualiser.cpp
${OFFNAO_MOC_SRCS} #too lazy to split and list them
PROPERTIES COMPILE_FLAGS "-I${QWT_INCLUDE_DIR}")
find_library ( QGLVIEWER_LIBRARY NAMES QGLViewer qglviewer-qt4 )
find_package ( OpenGL REQUIRED )
find_package ( PNG REQUIRED )
TARGET_LINK_LIBRARIES(
offnao.bin
${QT_LIBRARIES}
${QWT_LIBRARY}
${QGLVIEWER_LIBRARY}
此外,声明构建它的README相当模糊,实际上并没有说明从哪个文件夹运行这些命令。它声明:
Welcome to Off-Nao, the rUNSWift debugging toolsuite.
To build this project, either:
You get lucky and bin/build_setup.sh just works :D
(verified under Ubuntu 14.04.1 LTS both natively and in VMs;
but builds successfully then segfaults at runtime in libGL.so.1
under fresh download of 14.04.3 LTS @ 15/9/2015
according to gdb - so much for Ubuntu being stable).
---OR---
You need Qt4 and probably a bunch of other things like QGLViewer to build it natively:
$ mkdir build
$ cd build
$ cmake ..
$ make
$ ./offnao
Once you have performed the steps above once, in future you only need to:
$ make
$ ./offnao
In the 'build' directory
我确实得到了LibGL.so.1自述文件中提到的段错误,所以我试图按照下面的说明进行操作。我只能得到“cmake ..”阶段,这就是我得到错误的地方。
答案 0 :(得分:2)
重新制定我以前的评论作为答案:
要使用宏QT4_ADD_RESOURCES,QT4_WRAP_UI,QT4_WRAP_CPP等,您需要先在CMakeLists.txt中调用find_package(Qt4 REQUIRED)
。请参阅FindQt4.cmake模块(https://cmake.org/cmake/help/v3.0/module/FindQt4.html)的文档。