include not found, how to fix with cmake? - linux

there my CMakeLists.txt :
cmake_minimum_required( VERSION 2.8 )
set (CMAKE_VERBOSE_MAKEFILE ON)
project( a.out )
find_package(OpenGL)
find_package(PkgConfig REQUIRED)
pkg_search_module(GLFW REQUIRED glfw3)
pkg_search_module(CEGUI-GL REQUIRED CEGUI-0-OPENGL)
pkg_search_module(CEGUI REQUIRED CEGUI-0)
macro( config_project PROJNAME LIBNAME )
include_directories( ${${LIBNAME}_INCLUDE_DIR} )
target_link_libraries( ${PROJNAME} ${${LIBNAME}_LIBRARIES} )
endmacro()
add_definitions(-std=c++11)
add_executable(a.out src/ConsoleWindow.cc src/camera.cc src/main.cc)
config_project(a.out OPENGL)
config_project(a.out GLFW)
config_project(a.out CEGUI-GL)
config_project(a.out CEGUI)
so, there is PkgConfig for CEGUI-0-OPENGL and CEGUI-0. In CEGUI-0.pc there is:
prefix=/usr
exec_prefix=${prefix}
libdir=${prefix}/lib
includedir=${prefix}/include/cegui-0
moduledir=${prefix}/lib/cegui-0.8
datafiles=${prefix}/share/cegui-0
Name: CEGUI-0
Description: The free GUI library for games and multi-media development.
Version: 0.8.2
Libs: -L${libdir} -lCEGUIBase-0
Cflags: -I${includedir} -I${includedir}/cegui
when I run cmake . everything is fine, but in one of my .cc I have :
#include <CEGUI/CEGUI.h>
and when I compil the file I got an error like no such file found... but locate return :
/usr/include/cegui-0/CEGUI/CEGUI.h
what I'm doing wrong ?

I had the same problem, and did not find a clean solution. I solved like this:
include_directories(${CEGUI_INCLUDE_DIR}/../)
which is probably not the best solution, but enough for me...

some months later...
I think I solved this problem, I changed the line
include_directories( ${${LIBNAME}_INCLUDE_DIR} )
by
include_directories( ${${LIBNAME}_INCLUDEDIR} )
after noticing how includedir is typed in CEGUI-0.pc ...
includedir=${prefix}/include/cegui-0
I don't get the "no file found error" for #include <CEGUI/CEGUI.h> anymore. I will try to do a hell-o world with CEGUI in my program next days. If you have any comment plz do.

Related

Incorrect Dynamic Libraries linking after explicit set in Cmake

I've got a very frustrating issue a the moment. I'm attempting to build an executable that uses ROS and a compiled Matlab .so file. Due to what I believe is a boost conflict, I'm trying to build this exe using an earlier version of boost. Now, I've set up the cmakelist file, ran catkin_make (as its a ros project) and everything compiles, and the correct boost version is seen.
However, when running a ldd on the compiled exe, it still seems to be linking to the more recent version. Its rather annoying. I've posted the cmakelists file, and the ldd outcome. My system is Ubuntu 14.04 with ROS Indigo.
Any help would be really good, as I'm pulling my hair out trying to figure out what is wrong!
Many thanks in advance!
##CMAKE FILE
cmake_minimum_required(VERSION 2.8.3)
project(testmatlabdll)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wfatal-errors -O4 -march=native")
add_definitions(-std=c++11)
find_package(catkin REQUIRED)
find_package(PCL 1.7 REQUIRED)
link_directories(${PCL_LIBRARY_DIRS})
include_directories(${PCL_INCLUDE_DIRS})
add_definitions(${PCL_DEFINITIONS})
set(Boost_NO_SYSTEM_PATHS ON)
set(BOOST_ROOT /home/devbot/Downloads/boost_1_50_0)
set(BOOST_DIR /home/devbot/Downloads/boost_1_50_0)
set(Boost_INCLUDE_DIR /home/devbot/Downloads/boost_1_50_0)
set(BOOST_INCLUDEDIR /home/devbot/Downloads/boost_1_50_0)
set(Boost_USE_STATIC_LIBS OFF)
set(Boost_USE_MULTITHREADED ON)
message(STATUS "BOOST_ROOT = ${BOOST_ROOT}")
message(STATUS "Boost_VERSION = ${Boost_VERSION}")
message(STATUS "Boost_LIB_VERSION = ${Boost_LIB_VERSION}")
message(STATUS "Boost_MAJOR_VERSION = ${Boost_MAJOR_VERSION}")
message(STATUS "Boost_MINOR_VERSION = ${Boost_MINOR_VERSION}")
message(STATUS "Boost_LIBRARIES = ${Boost_LIBRARIES}")
message(STATUS "Boost_INCLUDE_DIRS = ${Boost_INCLUDE_DIRS}")
message(STATUS "Boost_LIBRARY_DIRS = ${Boost_LIBRARY_DIRS}")
find_package(Boost COMPONENTS REQUIRED
system filesystem thread date_time iostreams serialization chrono)
find_package(catkin REQUIRED COMPONENTS roscpp rospy std_msgs message_generation image_transport cv_bridge)
find_package(OpenCV REQUIRED)
catkin_package(CATKIN_DEPENDS roscpp
std_msgs
pcl_ros
sensor_msgs
cv_bridge
message_runtime
LIBRARIES ${PROJECT_NAME}
DEPENDS system_lib)
include_directories(include ${catkin_INCLUDE_DIRS})
include_directories(${OpenCV_INCLUDE_DIRS})
include_directories(/usr/local/MATLAB/R2013b/extern/include/)
include_directories(/opt/matlab/extern/include)
include_directories(/home/devbot/catkin_ws/src/testmatlabdll/src)
link_directories(/home/devbot/catkin_ws/src/testmatlabdll/src)
add_library(mwmc SHARED IMPORTED)
set_property(TARGET mwmc PROPERTY IMPORTED_LOCATION /usr/local/MATLAB/MATLAB_Compiler_Runtime/v82/runtime/glnxa64/libmwmclmcrrt.so)
add_executable(testMatlab src/testMatlab.cpp)
target_link_libraries(testMatlab ${Boost_LIBRARIES} ${catkin_LIBRARIES} ${PCL_LIBRARIES} ${OpenCV_LIBRARIES})
target_link_libraries(testMatlab roughlib mwmc)
OUTPUT FROM LDD
ldd testMatlab | grep boost
libboost_system.so.1.50.0 => /home/devbot/Downloads/boost_1_50_0/stage/lib/libboost_system.so.1.50.0 (0x00007f7456f8a000)
libboost_system.so.1.54.0 => /usr/lib/x86_64-linux-gnu/libboost_system.so.1.54.0 (0x00007f7454662000)
libboost_thread.so.1.54.0 => /usr/lib/x86_64-linux-gnu/libboost_thread.so.1.54.0 (0x00007f745444c000)
libboost_filesystem.so.1.54.0 => /usr/lib/x86_64-linux-gnu/libboost_filesystem.so.1.54.0 (0x00007f7454018000)
libboost_regex.so.1.54.0 => /usr/lib/x86_64-linux-gnu/libboost_regex.so.1.54.0 (0x00007f744d5d8000)

Linux opencv independent installation : not found in CMake

I am creating an object tracking program which rely on OpenCV. Thus I want to be able to test it with different versions of OpenCV but I have linking errors.
I installed the last version of OpenCV (a69b435c928f422fb5f99c02cf2dcae57dcf820a) in the following folder : /usr/local/opencv/opencv-trunk instead of the usual /usr/local.
Then I followed also the official tutorial to use OpenCV with CMake in Linux, but I had the following "normal" error :
CMake Error at CMakeLists.txt:11 (find_package):
By not providing "FindOpenCV.cmake" in CMAKE_MODULE_PATH this project has asked CMake to find a package configuration file provided by "OpenCV", but CMake did not find one.
Could not find a package configuration file provided by "OpenCV" with any of the following names:
OpenCVConfig.cmake
opencv-config.cmake
Add the installation prefix of "OpenCV" to CMAKE_PREFIX_PATH or set "OpenCV_DIR" to a directory containing one of the above files. If "OpenCV" provides a separate development package or SDK, be sure it has been installed.
-- Configuring incomplete, errors occurred!
So I did what was suggested and added the following line in my CMakeLists.txt :
# Find independently installed OpenCV libraries
set(OpenCV_DIR "/usr/local/opencv/opencv-trunk/share/OpenCV")
This is the complete CMakeLists.txt file :
# Find independently installed OpenCV libraries
set(OpenCV_DIR "/usr/local/opencv/opencv-trunk/share/OpenCV")
cmake_minimum_required(VERSION 2.8)
project( DisplayImage )
add_executable( DisplayImage DisplayImage.cpp )
find_package( OpenCV REQUIRED )
include_directories( ${OpenCV_INCLUDE_DIRS} )
target_link_libraries( DisplayImage ${OpenCV_LIBS} )
Now I have the following error and I don't find how to deal with it.
CMake Error at CMakeLists.txt:12 (find_package):
Found package configuration file:
/usr/local/opencv/opencv-trunk/share/OpenCV/OpenCVConfig.cmake
but it set OpenCV_FOUND to FALSE so package "OpenCV" is considered to be NOT FOUND.
-- Configuring incomplete, errors occurred!
If you have already faced that issue in such context your solutions are welcomed ;)
If you are running IntelliJ or any other IDE, just try re-building CMake cache (or just remove your build directory and run cmake utility again).
I believe this is not the best practice - to set the configuration variable like OpenCV_DIR hard-coded in the CMakeLists.txt. Try setting it manually, as an environment variable to the cmake utility:
OpenCV_DIR=/usr/local/Cellar/opencv3/3.1.0_2/share/OpenCV/ cmake ..
or set your IDE to make this for you:

How to include SimpleAudioEngine to Linux build in cocos2d-x v3.3 project?

I'm trying use SimpleAudioEngine in my project. I include the SimpleAudiEngine header to AppDelegate.
#include "SimpleAudioEngine.h"
When I build my project for Android everything compiles and build is fine. SimpleAudioEngine working is correct.
If run build for Linux, I get an error message:
fatal error: SimpleAudioEngine.h: No such file or directory
#include "SimpleAudioEngine.h"
I tried include SimpleAudioEngine to CMake file - result remains the previous.
I solved the problem by adding this line of code to CMakeLists.txt (in cocos2D version 3.4 project):
${COCOS2D_ROOT}/cocos/audio/include
So CMakeLists.txt is somthing like this now:
...
include_directories(
/usr/local/include/GLFW
...
${COCOS2D_ROOT}/cocos/audio/include
)
hope this help.

Qt5 / Eclipse / Linux Problems with conversion from Qt4 to Qt5

I tried to convert a project from Qt4 to Qt5. Until now stackoverflow search and Google helped me, but now i'm stuck.
I have rewritten the cmake files and all includes to the new Qt header are placed. Also the library should be added correctly. In my eclipse project all header are found but for some objects eclipse underlines in red with following comment:
Symbol XXX could not be resolved
XXX is for example:
QMainWindow
QWidget
QGroupBox
other objects like QPushButton, QLineEdit are not underlined.
To be honest above the switch from Qt4 to Qt5, I switched from Win/VS10 to Linux/Eclipse.
So anyone can give me a hint ?
Would really appreciate it.
Thanks
Edit: How I add Qt in cmake:
find_package(Qt5Widgets)
if (Qt5Widgets_FOUND)
message(STATUS "Qt5Widgets found.")
else (Qt5Widgets_FOUND)
message(STATUS "Qt5Widgets not found!")
endif (Qt5Widgets_FOUND)
find_package(Qt5OpenGL)
if (Qt5OpenGL_FOUND)
message(STATUS "QtOpenGl found.")
else (Qt5OpenGL_FOUND)
message(STATUS "QtOpenGL not found!")
endif (Qt5OpenGL_FOUND)
...
include_directories( ${Qt5Widgets_INCLUDES} ${Qt5OpenGL_INCLUDES})
add_executable(exp_test_qtTemplate ${files} )
target_link_libraries( exp_test_qtTemplate ${OPENGL_LIBRARIES} ${Boost_LIBRARIES} ${Qt5Widgets_LIBRARIES} ${Qt5OpenGL_LIBRARIES})
And this is somth strange in the qt generated moc File
#include <QtCore/qbytearray.h>
#include <QtCore/qmetatype.h>
#if !defined(Q_MOC_OUTPUT_REVISION)
#error "The header file 'GlViewer.h' doesn't include <QObject>."
#elif Q_MOC_OUTPUT_REVISION != 67
#error "This file was generated using the moc from 5.0.1. It"
#error "cannot be used with the include files from this version of Qt."
#error "(The moc has changed too much.)"
#endif
looks like a failed installation of Qt.

qplatformdefs.h with cmake

I'm trying to compile my Qt program with cmake but I've got an arror when compiling qzip.cpp :
qzip.cpp:57:27: error fatal: qplatformdefs.h: No such file or directory
I've added these lines in CMakeLists.txt but it didn't work :
IF (QT_LIBRARY_DIR AND NOT QT_MKSPECS_DIR OR QT_QMAKE_CHANGED)
EXEC_PROGRAM( ${QT_QMAKE_EXECUTABLE}
ARGS "-query QMAKE_MKSPECS"
OUTPUT_VARIABLE qt_mkspecs_dirs )
# do not replace : on windows as it might be a drive letter
# and windows should already use ; as a separator
IF(UNIX)
STRING(REPLACE ":" ";" qt_mkspecs_dirs "${qt_mkspecs_dirs}")
ENDIF(UNIX)
SET(QT_MKSPECS_DIR NOTFOUND)
FIND_PATH(QT_MKSPECS_DIR qconfig.pri PATHS ${qt_mkspecs_dirs}
DOC "The location of the Qt mkspecs containing qconfig.pri"
NO_DEFAULT_PATH )
ENDIF (QT_LIBRARY_DIR AND NOT QT_MKSPECS_DIR OR QT_QMAKE_CHANGED)
SET( QT_INCLUDES ${QT_QT_INCLUDE_DIR} ${QT_MKSPECS_DIR}/default ${QT_INCLUDE_DIR} )
So, how can I add a link to qplatformdefs.h in my CMakeLists.cpp?
Thanks a lot.
P.S.: I'm on Ubuntu 12.04 32bits
You can try to add this to your CMakeLists.txt:
include_directories(${QT_MKSPECS_DIR}/default)
You may have already found the answer, but in case you have not found it here is the thing:
In my Fedora, this file is located in /usr/lib64/qt4/mkspecs/linux-g++-64.
Assuming that its the same location in Ubuntu, you should add this dir to the include_directories();
include_directories( lots_of_dirs "/usr/lib64/qt4/mkspecs/linux-g++-64/")
I hope I have helped.

Resources