我已经安装了 QtCreator 2.7.2 ,但是当我尝试编译包含 QApplication 的代码时,它给了我错误:Error QApplication: no such file or directory。
它可以顺利编译教程代码“notepad”,我可以在/usr/include/qt4/QtGui/QApplication中找到QApplication。
这是我的代码:#include #include "framework/vision_app.h"
int main(int argc, char** argv)
{
QApplication qapp(argc, argv);
VisionApp vapp;
if (vapp.init(argc, argv))
{
return qapp.exec();
}
else
{
return 1;
}
}
多说,我没有任何 .pro 文件。我使用 cmake 来打包我的代码。
这是我的 cmakelist:
cmake_minimum_required(VERSION 2.4.6)
include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake)
# Set the build type. Options are:
# Coverage : w/ debug symbols, w/o optimization, w/ code-coverage
# Debug : w/ debug symbols, w/o optimization
# Release : w/o debug symbols, w/ optimization
# RelWithDebInfo : w/ debug symbols, w/ optimization
# MinSizeRel : w/o debug symbols, w/ optimization, stripped binaries
#set(ROS_BUILD_TYPE RelWithDebInfo)
rosbuild_init()
rosbuild_add_boost_directories()
find_package(OpenCV 2.3 REQUIRED)
if(OpenCV_FOUND)
message(STATUS "OpenCV include: ${OpenCV_INCLUDE_DIRS}")
message(STATUS "OpenCV libs: ${OpenCV_LIBS}")
include_directories(${OpenCV_INCLUDE_DIRS})
else(OpenCV_FOUND)
message(SEND_ERROR "OpenCV not found!!")
endif()
# Qt4 requirements
include_directories(${CMAKE_CURRENT_BINARY_DIR})
set(QT_USE_QTOPENGL TRUE)
find_package(OpenGL REQUIRED)
message (STATUS "OpenGL_found:" ${OPENGL_FOUND})
find_package(Qt4 REQUIRED)
include(${QT_USE_FILE})
add_definitions(${QT_DEFINITIONS})
add_definitions(-DQT_NO_KEYWORDS)
#set the default path for built executables to the "bin" directory
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
#set the default path for built libraries to the "lib" directory
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)
#uncomment if you have defined messages
#rosbuild_genmsg()
#uncomment if you have defined services
#rosbuild_gensrv()
include_directories(${PROJECT_SOURCE_DIR}/src)
include_directories(${PROJECT_SOURCE_DIR}/src/gui)
set(we_vision_HDRS src/framework/vision_app.h
src/gui/main_window.h
)
set(we_vision_SRCS src/vision_node_qt.cpp
src/framework/vision_app.cpp
src/gui/main_window.cpp
)
set(we_vision_UIS res/main_window.ui)
QT4_WRAP_CPP(we_vision_HDRS_MOC ${we_vision_HDRS})
QT4_WRAP_UI(we_vision_UI_HDRS ${we_vision_UIS})
rosbuild_add_executable(vision_node_qt ${we_vision_SRCS}
${we_vision_HDRS_MOC}
${we_vision_UI_HDRS}
)
target_link_libraries(vision_node_qt ${OpenCV_LIBS} ${QT_LIBRARIES} ${OPENGL_LIBRARIES})
rosbuild_link_boost(vision_node_qt thread filesystem system)
有谁能够帮我?