SDL library couldn't be found in cmake
SDL library couldn't be found in cmake
I am trying to write a cmake.I will use OpenGL, SDL and OpenCV together. The things is cmake operation is done properly but if I enter make command, it says that "No such file or directory" for SDL/SDL.h
my cmake is like this:
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
)
In the source code my includes are:
#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>
as last, my directory structure for the project is:
CMakeCache.txt Makefile camera_calibration.cpp paths.cmake
CMakeLists.txt README.md cmake_install.cmake src
./src:
arucoDetect.cpp
and paths.cmake as a guidance, I took it from my friend for the same project(but complex one):
# 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")
I am just starting to use cmake so I couldn't find anything to use properly. Thanks everyone!
SDL/SDL.h
$SDL2_INCLUDE_DIRS
I think I got what you mean. I changed to library to SDL to SDL2 and it worked. With additional errors. I think I have sdl2 but not sdl1. And I am trying to use the second one while coding with first version. Thanks for the starting point.
– aliyasineser
Aug 30 at 7:16
1 Answer
1
Thanks to @Marco A. I found the problem. I use SDL for the code and I tried to include SDL2. I installed sdl1.2 and added SDL binding. To install SDL:
sudo apt-get install libsdl1.2-dev
and new cmake is:
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
)
Required, but never shown
Required, but never shown
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Perhaps the most obvious question first: Is there a file such as
SDL/SDL.h
under$SDL2_INCLUDE_DIRS
?– Botje
Aug 30 at 7:11