我正在尝试编写cmake。我将同时使用OpenGL,SDL和OpenCV。事情是cmake操作正确完成,但是如果我输入make命令,它说SDL / SDL.h“没有这样的文件或目录”。
我的cmake是这样的:
cmake_minimum_required (VERSION 3.2)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_AUTOMOC ON)
project (VisionTest)
# compiler version checking does not work if CMAKE_CXX_COMPILER is not set
if (CMAKE_CXX_COMPILER)
execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion
OUTPUT_VARIABLE GCC_VERSION)
message("GCC version: ${GCC_VERSION}")
if (GCC_VERSION VERSION_GREATER "5.0.0" OR GCC_VERSION VERSION_EQUAL "5.0.0")
message(STATUS "GCC version >= 5.0, use CXX11_ABI=1")
else()
add_definitions(-D_GLIBCXX_USE_CXX11_ABI=0)
endif()
endif()
find_package(OpenCV)
find_package(SDL2 REQUIRED)
find_package(OpenGL REQUIRED)
find_package(GLEW REQUIRED)
include_directories(
${GLEW_INCLUDE_DIR}
${OPENGL_INCLUDE_DIR}
${SDL2_INCLUDE_DIRS}
)
add_executable(
VisionTest
src/arucoDetect.cpp
)
target_link_libraries(VisionTest ${OpenCV_LIBS}
${SDL2_LIBRARY}
${GLEW_LIBRARIES}
${OPENGL_LIBRARIES}
)
在源代码中,我包括:
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/calib3d/calib3d.hpp"
#include "opencv2/core.hpp"
#include "opencv2/shape.hpp"
#include <opencv2/aruco.hpp>
#include <iostream>
#include <fstream>
#include <string>
#include <cstdlib>
#include <stdlib.h>
#include <stdio.h>
#include <sstream>
#include <vector>
#include <cmath>
#include <list>
#include <SDL/SDL.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/freeglut.h>
#include <GL/glut.h>
#include <algorithm>
#include <math.h>
#include <iostream>
最后,我的项目目录结构为:
CMakeCache.txt Makefile camera_calibration.cpp paths.cmake
CMakeLists.txt README.md cmake_install.cmake src
./src:
arucoDetect.cpp
和paths.cmake作为指导,我从我的朋友那里拿到了同一项目(但很复杂):
# define platform specific paths in this file
SET(TOOLCHAIN_DIR "/opt" CACHE STRING "")
include(cmake/TargetArch.cmake)
target_architecture(ARCH)
MESSAGE("TOOLCHAIN_DIR is set to: ${TOOLCHAIN_DIR}")
MESSAGE("BUILDING FOR: ${ARCH}")
#include target specific linker and include_directories
IF(${ARCH} MATCHES "aarch64")
set(QT5_DIR ${TOOLCHAIN_DIR}/qt5-odroid)
set(ZEROMQ_INCLUDE_PATH ${TOOLCHAIN_DIR}/zeromq-odroid/include)
set(ZEROMQ_LIB_PATH ${TOOLCHAIN_DIR}/zeromq-odroid/lib)
set(PROTOBUF_INCLUDE_PATH ${TOOLCHAIN_DIR}/protobuf-odroid/include)
set(PROTOBUF_LIB_PATH ${TOOLCHAIN_DIR}/protobuf-odroid/lib)
set(PROTOBUF_PROTOC ${TOOLCHAIN_DIR}/protobuf-host/bin/protoc)
set(LIBSODIUM_LIB_PATH ${TOOLCHAIN_DIR}/libsodium-odroid/lib)
set(OpenCV_DIR ${TOOLCHAIN_DIR}/opencv-odroid/share/OpenCV/)
ELSEIF(${ARCH} MATCHES "x86_64")
set(QT5_DIR ${TOOLCHAIN_DIR}/qt5-host)
set(ZEROMQ_INCLUDE_PATH ${TOOLCHAIN_DIR}/zeromq-host/include)
set(ZEROMQ_LIB_PATH ${TOOLCHAIN_DIR}/zeromq-host/lib)
set(PROTOBUF_INCLUDE_PATH ${TOOLCHAIN_DIR}/protobuf-host/include)
set(PROTOBUF_LIB_PATH ${TOOLCHAIN_DIR}/protobuf-host/lib)
set(PROTOBUF_PROTOC ${TOOLCHAIN_DIR}/protobuf-host/bin/protoc)
set(LIBSODIUM_LIB_PATH ${TOOLCHAIN_DIR}/libsodium-host/lib)
set(OpenCV_DIR ${TOOLCHAIN_DIR}/opencv-host/share/OpenCV/)
ENDIF(${ARCH} MATCHES "aarch64")
# set Qt CMake paths
set(CMAKE_PREFIX_PATH ${QT5_DIR}/lib/cmake)
set(Qt5Core_DIR ${QT5_DIR}/lib/cmake/Qt5Core)
set(Qt5Scxml_DIR ${QT5_DIR}/lib/cmake/Qt5Scxml)
set(Qt5Qml_DIR ${QT5_DIR}/lib/cmake/Qt5Qml)
set(Qt5Network_DIR ${QT5_DIR}/lib/cmake/Qt5Network)
set(Qt5Test_DIR ${QT5_DIR}/lib/cmake/Qt5Test)
MESSAGE("CMAKE_PREFIX_PATH is set to: ${CMAKE_PREFIX_PATH}")
MESSAGE("Qt5Core_DIR is set to: ${Qt5Core_DIR}")
MESSAGE("Qt5Scxml_DIR is set to: ${Qt5Scxml_DIR}")
MESSAGE("Qt5Qml_DIR is set to: ${Qt5Qml_DIR}")
MESSAGE("Qt5Network_DIR is set to: ${Qt5Network_DIR}")
MESSAGE("Qt5Test_DIR is set to: ${Qt5Test_DIR}")
我刚刚开始使用cmake,所以找不到任何可以正确使用的东西。谢谢大家!
答案 0 :(得分:0)
感谢@MarcoA。我发现了问题。我使用SDL编写代码,并尝试包含SDL2。我安装了sdl1.2并添加了SDL绑定。要安装SDL:
sudo apt-get install libsdl1.2-dev
新的cmake是:
cmake_minimum_required (VERSION 3.2)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_AUTOMOC ON)
project (VisionTest)
# compiler version checking does not work if CMAKE_CXX_COMPILER is not set
if (CMAKE_CXX_COMPILER)
execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion
OUTPUT_VARIABLE GCC_VERSION)
message("GCC version: ${GCC_VERSION}")
if (GCC_VERSION VERSION_GREATER "5.0.0" OR GCC_VERSION VERSION_EQUAL "5.0.0")
message(STATUS "GCC version >= 5.0, use CXX11_ABI=1")
else()
add_definitions(-D_GLIBCXX_USE_CXX11_ABI=0)
endif()
endif()
find_package(OpenCV)
find_package(SDL2 REQUIRED)
find_package(SDL REQUIRED)
find_package(OpenGL REQUIRED)
find_package(GLEW REQUIRED)
include_directories(
${GLEW_INCLUDE_DIR}
${OPENGL_INCLUDE_DIR}
${SDL2_INCLUDE_DIRS}
)
add_executable(
VisionTest
src/arucoDetect.cpp
)
target_link_libraries(VisionTest ${OpenCV_LIBS}
${SDL2_LIBRARY}
${SDL_LIBRARY}
${GLEW_LIBRARIES}
${OPENGL_LIBRARIES}
)