First of all, the error log:
-- Boost version: 1.59.0
-- Success!
-- Could NOT find Freetype (missing: FREETYPE_LIBRARY) (found version "2.6.3")
-- LOADING OS --Windows--
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/Gianluca/.CLion2016.2/system/cmake/generated/mcdu-57fe38f9/57fe38f9/Debug
[ 1%] Automatic moc for target untitled
[ 1%] Built target untitled_automoc
[ 2%] Building CXX object CMakeFiles/untitled.dir/main.cpp.obj
[ 3%] Building CXX object CMakeFiles/untitled.dir/mainwindow.cpp.obj
[ 4%] Building CXX object CMakeFiles/untitled.dir/gldisplay.cpp.obj
[ 7%] Building CXX object CMakeFiles/untitled.dir/svg/svg.cpp.obj
[ 7%] Building CXX object CMakeFiles/untitled.dir/svg/svgfont.cpp.obj
[ 8%] Building CXX object CMakeFiles/untitled.dir/svg/svgstring.cpp.obj
[ 11%] Building CXX object CMakeFiles/untitled.dir/ht1000scriptmanager.cpp.obj
[ 11%] Building CXX object CMakeFiles/untitled.dir/ht1000widgetfactory.cpp.obj
CMakeFiles\untitled.dir\build.make:149: recipe for target 'CMakeFiles/untitled.dir/svg/svg.cpp.obj' failed
In file included from C:\Work\PolitecProductions\mcdu\svg\svg.cpp:1:0:
C:\Work\PolitecProductions\mcdu\svg\svg.h:14:48: fatal error: boost/algorithm/string/predicate.hpp: No such file or directory
#include <boost/algorithm/string/predicate.hpp>
^
compilation terminated.
In file included from C:\Work\PolitecProductions\mcdu\svg\svgstring.cpp:3:0:
C:\Work\PolitecProductions\mcdu\svg\./svg.h:14:48: fatal error: boost/algorithm/string/predicate.hpp: No such file or directory
#include <boost/algorithm/string/predicate.hpp>
^
compilation terminated.
mingw32-make.exe[2]: *** [CMakeFiles/untitled.dir/svg/svg.cpp.obj] Error 1
mingw32-make.exe[2]: *** Waiting for unfinished jobs....
In file included from C:\Work\PolitecProductions\mcdu\svg\svgfont.cpp:2:0:
C:\Work\PolitecProductions\mcdu\svg\./svg.h:14:48: fatal error: boost/algorithm/string/predicate.hpp: No such file or directory
#include <boost/algorithm/string/predicate.hpp>
^
compilation terminated.
CMakeFiles\untitled.dir\build.make:199: recipe for target 'CMakeFiles/untitled.dir/svg/svgstring.cpp.obj' failed
mingw32-make.exe[2]: *** [CMakeFiles/untitled.dir/svg/svgstring.cpp.obj] Error 1
CMakeFiles\untitled.dir\build.make:174: recipe for target 'CMakeFiles/untitled.dir/svg/svgfont.cpp.obj' failed
mingw32-make.exe[2]: *** [CMakeFiles/untitled.dir/svg/svgfont.cpp.obj] Error 1
CMakeFiles\untitled.dir\build.make:249: recipe for target 'CMakeFiles/untitled.dir/ht1000widgetfactory.cpp.obj' failed
In file included from C:\Work\PolitecProductions\mcdu\ht1000widgetfactory.cpp:1:0:
C:\Work\PolitecProductions\mcdu\./ht1000widgetfactory.h:5:25: fatal error: QScriptEngine: No such file or directory
#include <QScriptEngine>
^
compilation terminated.
more http://pastebin.com/72ySYdVd
This is my actual CMakeLists
cmake_minimum_required(VERSION 3.6)
project(mcdu)
#### Boost Check Version
find_package(Boost REQUIRED)
if(Boost_FOUND)
message(STATUS "Success!")
endif()
#### Qt5
find_package(Qt5Core REQUIRED)
find_package(Qt5Gui REQUIRED)
find_package(Qt5Script REQUIRED)
find_package(Qt5Widgets REQUIRED)
find_package(Qt5OpenGL REQUIRED)
find_package(FREETYPE)
set(QT_LIBRARIES Qt5::Widgets Qt5::Core Qt5::OpenGL Qt5::Core Qt5::Script)
set( CMAKE_AUTOMOC ON )
ADD_DEFINITIONS(${QT_DEFINITIONS})
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(CMAKE_CXX_FLAGS_COVERAGE "${CMAKE_CXX_FLAGS_RELEASE} -fprofile-arcs -ftest-coverage ")
add_definitions("-std=c++11")
# Find includes in corresponding build directories
include_directories(
${BOOST}
${FREETYPE}
${Qt5Widgets_INCLUDE_DIRS}
-lopengl32 -lglu32 -luser32
)
if (WIN32)
message(STATUS "LOADING OS --Windows--")
include_directories(
${BOOST}/lib32-msvc-14.0 -libboost_timer-vc140-mt-gd-1_59 -libboost_log-vc140-mt-gd-1_59 -libboost_log_setup-vc140-mt-gd-1_59
${FREETYPE}/objs/vc2010/Win32/ -lfreetype263d
)
endif ()
#Source Files
set(SOURCE_FILES
src files. Cut to be short
#Header Files
set(HEADER_FILES
header files. Cut to be short
)
#Add Forms
QT5_WRAP_UI(FORM_FILES
.ui files
)
add_executable(untitled ${SOURCE_FILES} ${HEADER_FILES} ${FORM_FILES})
more http://pastebin.com/uGf3SHUn
So under svg.h the include is as it follows:
#include <boost/algorithm/string/predicate.hpp>
I've MSVC2015 and BOOST + FREETYPE env. variables are added to the system AND Clion. If I build that from QT I only get predicate.hpp error.
Here is the QT PRO file
QT += core gui script opengl
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = mcdu
TEMPLATE = app
DEFINES += WIN
DEFINES += OGLFT_NO_SOLID
DEFINES += OGLFT_NO_QT
DEFINES += TEST
INCLUDEPATH += $$(BOOST)
INCLUDEPATH += $$(FREETYPE)/include
INCLUDEPATH += status
INCLUDEPATH += systems
INCLUDEPATH += svg
INCLUDEPATH += displays
CONFIG += debug
win32 {
DEFINES += WINDOWS
LIBS += -lopengl32 -lglu32 -luser32
LIBS += -L$$(BOOST)/lib32-msvc-14.0 -libboost_timer-vc140-mt-gd-1_59 -libboost_log-vc140-mt-gd-1_59 -libboost_log_setup-vc140-mt-gd-1_59
LIBS += -L$$(FREETYPE)/objs/vc2010/Win32/ -lfreetype263d
}
linux {
message("Build for Linux")
DEFINES += LINUX
DEFINES += BOOST_LOG_DYN_LINK
LIBS += -lGLU
LIBS += -lfreetype
LIBS += -L/home/RINF/rogosz/source/boost_1_59_0/stage/lib -lboost_timer -lboost_log -lboost_log_setup -lboost_system -lboost_thread -lboost_filesystem
}
SOURCES += src files: cut to be short
HEADERS += header files. cut to be short
FORMS += form files. cut to be short
find_package(Boost REQUIRED)
# ...
# Find includes in corresponding build directories
include_directories(
${BOOST}
${FREETYPE}
${Qt5Widgets_INCLUDE_DIRS}
-lopengl32 -lglu32 -luser32
)
The variable set by the find_package( Boost ... ), containing the path to the Boost header files, is named Boost_INCLUDE_DIRS, not BOOST.
And unless FREETYPE is breaking the pattern, that should be FREETYPE_INCLUDE_DIRS as well.
And what are the linker directives (-lopengl32 -lglu32 -luser32) doing in there?
if (WIN32)
message(STATUS "LOADING OS --Windows--")
include_directories(
${BOOST}/lib32-msvc-14.0 -libboost_timer-vc140-mt-gd-1_59 -libboost_log-vc140-mt-gd-1_59 -libboost_log_setup-vc140-mt-gd-1_59
${FREETYPE}/objs/vc2010/Win32/ -lfreetype263d
)
endif ()
I am quite confused. What is this even meant to achieve? You use the command include_directories(), but it looks as if you are trying to give linker instructions here? Adding link dependencies is done via target_link_libraries()...
And even if you would be using the correct command, you would not give linker instructions (-lfreetype263d), but list link targets, preferably those provided by the various find_package() calls, i.e. ${Boost_LIBRARIES} (not ${BOOST}), and ${FREETYPE_LIBRARIES} (not ${FREETYPE}).
Further:
set(CMAKE_CXX_FLAGS_COVERAGE "${CMAKE_CXX_FLAGS_RELEASE} -fprofile-arcs -ftest-coverage ")
add_definitions("-std=c++11")
These are compiler-specific options that won't float your boat if you are working with Visual Studio. Use if ( MSVC ) and if ( CMAKE_COMPILER_IS_GNUCC ) to check what compiler you are working with.
Related
this is the first time I use an external c++ library aside from OpenCV. In the code I use quite a lot of ROS functionality, but I believe my issue is not related to ROS. I want to build a project with the GTSAM library.
Therefore I cloned the repository into my /usr/lib folder and installed it as instructed.
I then wrote the CMakeLists.txt,added two includes into my - otherwise functioning .h file - and tried to compile.
The beginning of my .h file, the compile error and my CMakeLists.txt are shown below. Interestingly, if I comment out the second include and just include Pose2.h, compilation works. That should mean that the compiler at least finds some headers from the library, ergo it is correctly installed. The part of my cmake code which is supposed to link the library is extracted from an example project given here. Any help is appreciated.
car_lib.h:
#ifndef CAR_LIB_H
#define CAR_LIB_H
// GTSAM headers
#include <gtsam/geometry/Pose2.h>
#include <gtsam/nonlinear/NonlinearFactorGraph.h>
using namespace gtsam;
// rest of file follows....
When compiling, I get the following error:
...
[100%] Linking CXX executable /home/marc/catkin_ws/devel/lib/car/car_node
[100%] Linking CXX shared library /home/marc/catkin_ws/devel/lib/libcar_lib.so
[100%] Built target car_lib
CMakeFiles/car_node.dir/src/car_node.cpp.o: In function `__static_initialization_and_destruction_0(int, int)':
/usr/local/include/gtsam/inference/Key.h:41: undefined reference to `gtsam::_defaultKeyFormatter[abi:cxx11](unsigned long)'
/usr/local/include/gtsam/inference/Key.h:52: undefined reference to `gtsam::_multirobotKeyFormatter[abi:cxx11](unsigned long)'
collect2: error: ld returned 1 exit status
car/CMakeFiles/car_node.dir/build.make:113: recipe for target '/home/marc/catkin_ws/devel/lib/car/car_node' failed
make[2]: *** [/home/marc/catkin_ws/devel/lib/car/car_node] Error 1
CMakeFiles/Makefile2:384: recipe for target 'car/CMakeFiles/car_node.dir/all' failed
make[1]: *** [car/CMakeFiles/car_node.dir/all] Error 2
Makefile:138: recipe for target 'all' failed
make: *** [all] Error 2
Invoking "make -j4 -l4" failed
My CMakeLists.txt:
cmake_minimum_required(VERSION 2.8.3)
project(car)
## Compile as C++11, supported in ROS Kinetic and newer
add_compile_options(-std=c++11)
find_package(catkin REQUIRED COMPONENTS
geometry_msgs
message_generation
nav_msgs
roscpp
sensor_msgs
std_msgs
)
###### GTSAM STUFF STARTS HERE
# Include GTSAM CMake tools
find_package(GTSAMCMakeTools)
#include(GtsamBuildTypes) # Load build type flags and default to Debug mode
#include(GtsamTesting) # Easy functions for creating unit tests and scripts
#include(GtsamMatlabWrap) # Automatic MATLAB wrapper generation
# Ensure that local folder is searched before library folders
#include_directories(BEFORE "${PROJECT_SOURCE_DIR}")
###################################################################################
# Find GTSAM components
find_package(GTSAM REQUIRED) # Uses installed package
include_directories(${GTSAM_INCLUDE_DIR})
###################################################################################
# Build static library from common sources
#set(CONVENIENCE_LIB_NAME ${PROJECT_NAME})
#add_library(${CONVENIENCE_LIB_NAME} STATIC include/car/car_lib.h src/car_lib.cpp)
#target_link_libraries(${CONVENIENCE_LIB_NAME} gtsam)
###### GTSAM STUFF ENDS HER
catkin_package(
INCLUDE_DIRS include
LIBRARIES car_lib
CATKIN_DEPENDS
geometry_msgs
message_runtime
nav_msgs
roscpp
sensor_msgs
std_msgs
)
include_directories(
include
${catkin_INCLUDE_DIRS}
)
## Declare a C++ library
add_library(car_lib
include/${PROJECT_NAME}/car_lib.h
src/car_lib.cpp
)
add_executable(car_node src/car_node)
target_link_libraries(car_node ${catkin_LIBRARIES})
target_link_libraries(car_lib
${catkin_LIBRARIES}
)
Try replacing the bit under ## Declare a C++ library with
## Declare a C++ library
add_library(car_lib src/car_lib.cpp)
target_link_libraries(car_lib
gtsam
${catkin_LIBRARIES}
)
add_executable(car_node src/car_node)
target_link_libraries(car_node
car_lib
gtsam
${catkin_LIBRARIES}
)
For those who are trying to do the same thing using makefile, Here is the solution. [ note this is for simple c++ program without ROS ].
all: main.cpp
#g++ main.cpp \
-std=c++11 \
-I /usr/include/eigen3 \
-lboost_system -lboost_filesystem \
-lgtsam \
-o main
clear:
#rm -rf main
Im trying to build a project which uses the Myo SDK and the LeapMotion SDK on Windows 7 with CMake, Qt Creator and MinGW 4.9.2 32bit as compiler.
The MyoSDK ist working fine but I have some problems with linking the LeapMotion SDK in CMake. I found an existing sample CMake file which says that the Windows part is not finished.
Here is my CMakeLists.txt:
cmake_minimum_required (VERSION 2.6)
project (MyoLeapController)
#set(THALMICLABSMYO_ROOT_DIR "C:/myo-sdk-win-0.9.0")
################## MYO
if(WIN32)
set(THALMICLABSMYO_ROOT_DIR
"${THALMICLABSMYO_ROOT_DIR}"
CACHE
PATH
"Directory to search for the Thalmic Labs Myo SDK")
if(CMAKE_SIZEOF_VOID_P MATCHES "8")
set(_ARCH x86_64)
else()
set(_ARCH x86_32)
endif()
set(_SDKDIR Windows)
find_path(THALMICLABSMYO_INCLUDE_DIR
NAMES myo/libmyo.h
PATHS "${THALMICLABSMYO_ROOT_DIR}/include")
include(FindPackageHandleStandardArgs)
if(CMAKE_SIZEOF_VOID_P MATCHES "8")
find_library(THALMICLABSMYO_LIBRARY
NAMES myo64
PATHS "${THALMICLABSMYO_ROOT_DIR}/lib"
PATH_SUFFIXES "${_SDKDIR}/${_ARCH}")
else()
find_library(THALMICLABSMYO_LIBRARY
NAMES myo32
PATHS "${THALMICLABSMYO_ROOT_DIR}/lib"
PATH_SUFFIXES "${_SDKDIR}/${_ARCH}")
endif()
find_package_handle_standard_args(ThalmicLabsMyo
DEFAULT_MSG
THALMICLABSMYO_LIBRARY
THALMICLABSMYO_INCLUDE_DIR
${_deps_check})
if(THALMICLABSMYO_FOUND)
set(THALMICLABSMYO_LIBRARIES "${THALMICLABSMYO_LIBRARY}")
set(THALMICLABSMYO_INCLUDE_DIRS "${THALMICLABSMYO_INCLUDE_DIR}")
mark_as_advanced(THALMICLABSMYO_ROOT_DIR)
endif()
mark_as_advanced(THALMICLABSMYO_INCLUDE_DIR THALMICLABSMYO_LIBRARY)
endif()
################## LEAP
IF(LEAP_INCLUDE_DIR AND LEAP_LIBRARY)
SET(LEAP_FIND_QUIETLY TRUE)
ENDIF(LEAP_INCLUDE_DIR AND LEAP_LIBRARY)
# Set locations to search
IF(UNIX)
SET(LEAP_INCLUDE_SEARCH_DIRS
/usr/include
/usr/local/include
/opt/leap/include
/opt/leap_sdk/include
/opt/include INTERNAL)
SET(LEAP_LIBRARY_SEARCH_DIRS
/usr/lib
/usr/lib64
/usr/local/lib
/usr/local/lib64
/opt/leap/lib
/opt/leap/lib64
/opt/leap_sdk/lib
/opt/leap_sdk/lib64 INTERNAL)
SET(LEAP_INC_DIR_SUFFIXES PATH_SUFFIXES leap)
ELSE(UNIX)
#WIN32
SET(LEAP_INC_DIR_SUFFIXES PATH_SUFFIXES inc)
SET(LEAP_LIB_DIR_SUFFIXES PATH_SUFFIXES lib)
ENDIF(UNIX)
# Set name of the Leap library to use
IF(APPLE)
SET(LEAP_LIBRARY_NAME libLeap.dylib)
ELSE(APPLE)
IF(UNIX)
SET(LEAP_LIBRARY_NAME libLeap.so)
ELSE(UNIX)
# TODO Different libraries are provided for compile and runtime
SET(LEAP_LIBRARY_NAME libLeap.lib)
ENDIF(UNIX)
ENDIF(APPLE)
IF(NOT LEAP_FIND_QUIETLY)
MESSAGE(STATUS "Checking for Leap")
ENDIF(NOT LEAP_FIND_QUIETLY)
# Search for header files
FIND_PATH(LEAP_INCLUDE_DIR Leap.h
PATHS ${LEAP_INCLUDE_SEARCH_PATHS}
PATH_SUFFIXES ${LEAP_INC_DIR_SUFFIXES})
# Search for library
FIND_LIBRARY(LEAP_LIBRARY ${LEAP_LIBRARY_NAME}
PATHS ${LEAP_LIBRARY_SEARCH_DIRS}
PATH_SUFFIXES ${LEAP_LIB_DIR_SUFFIXES})
SET(LEAP_INCLUDE_DIR ${LEAP_INCLUDE_DIR} CACHE STRING
"Directory containing LEAP header files")
SET(LEAP_LIBRARY ${LEAP_LIBRARY} CACHE STRING "Library name of Leap library")
SET(LEAP_INCLUDE_DIRS ${LEAP_INCLUDE_DIR} )
SET(LEAP_LIBRARIES ${LEAP_LIBRARY} )
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Leap DEFAULT_MSG LEAP_LIBRARY LEAP_INCLUDE_DIR)
MARK_AS_ADVANCED(LEAP_INCLUDE_DIR LEAP_LIBRARY)
##################
message(${LEAP_LIBRARY})
INCLUDE_DIRECTORIES(${THALMICLABSMYO_INCLUDE_DIR} ${LEAP_INCLUDE_DIRS})
add_executable(MyoLeapController main.cpp)
target_link_libraries(MyoLeapController ${THALMICLABSMYO_LIBRARY} ${LEAP_LIBRARY})
My CMake output is:
C:/LeapSDK/lib/x86/Leap.dll
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/riecker/Documents/Masterthesis/MyoLeapController-bin
I link the found Leap library exactly the same like the Myo but I get some Linker errors.
My C++ program for testing:
#include <iostream>
#include <myo/myo.hpp>
#include <Leap.h>
int main (int argc, char *argv[])
{
//myo::Hub hub("MyoLeapController");
Leap::Controller controller;
std::cout << "hi" << std::endl;
return 0;
}
The Error Message:
[ 50%] Linking CXX executable MyoLeapController.exe
CMakeFiles\MyoLeapController.dir/objects.a(main.cpp.obj):main.cpp:(.text+0x1d): undefined reference to `Leap::Controller::Controller()'
CMakeFiles\MyoLeapController.dir/objects.a(main.cpp.obj):main.cpp:(.text+0x51): undefined reference to `Leap::Controller::~Controller()'
CMakeFiles\MyoLeapController.dir\build.make:98: recipe for target 'MyoLeapController.exe' failed
CMakeFiles\MyoLeapController.dir/objects.a(main.cpp.obj):main.cpp:(.text+0x61): undefined reference to `Leap::Controller::~Controller()'
CMakeFiles\Makefile2:66: recipe for target 'CMakeFiles/MyoLeapController.dir/all' failed
makefile:82: recipe for target 'all' failed
C:/Qt/Tools/mingw492_32/bin/../lib/gcc/i686-w64-mingw32/4.9.2/../../../../i686-w64-mingw32/bin/ld.exe: CMakeFiles\MyoLeapController.dir/objects.a(main.cpp.obj): bad reloc address 0x0 in section `.ctors'
collect2.exe: error: ld returned 1 exit status
mingw32-make[2]: *** [MyoLeapController.exe] Error 1
mingw32-make[1]: *** [CMakeFiles/MyoLeapController.dir/all] Error 2
mingw32-make: *** [all] Error 2
10:56:32: Der Prozess "C:\Qt\Tools\mingw492_32\bin\mingw32-make.exe" wurde mit dem Rückgabewert 2 beendet.
Fehler beim Erstellen/Deployment des Projekts MyoLeapController (Kit: Desktop Qt 5.6.0 MinGW 32bit)
Bei der Ausführung von Schritt "Make"
The include of the Leap SDK is working because it can find the header files only during linking I get the problem. For including and linking I am doing the same like with the Myo SDK which is working.
Can anybody help me or have an idea about this? Thank you
Leap Motion library does not support MinGW, so the library that you are trying to link is incompatible.
However, you can try the dll in this package. It comes from this thread. It seems to be only for 32-bit, but that's apparently what you are trying to build.
From the build directory where you got the error, first see if this command line works, then you can proceed to make it work within your cmake project:
C:\Qt\Tools\mingw492_32\bin\g++.exe -Wl,--whole-archive
CMakeFiles\MyoLeapController.dir/objects.a -Wl,--no-whole-archive -o
MyoLeapController.exe -Wl,--out-implib,libMyoLeapController.dll.a
-Wl,--major-image-version,0,--minor-image-version,0 -LC:/myo-sdk-win-0.9.0/lib/ -LpathToTheLeapDll -lLeap -lmyo32 -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32
If it works, when you try the executable make sure the libLeap.dll is available in your path or in your execution directory.
I'm trying to cross compile my project to arm to use it on a raspberry pi but it can't find dbus. Which was easily find when I was compiling classically.
I'm using cmake I've added dbus-1 to target link library and I'm using arm-linux-gnueabihf to cross compile.
Any idea?
EDIT: add my CMakeLists.txt :
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")
FIND_PACKAGE(glib2) # bluetooth
include_directories(${GLIB2_INCLUDE_DIRS}) # bluetooth
include_directories(${CMAKE_SOURCE_DIR}/../bluez/gdbus)
include_directories(${CMAKE_SOURCE_DIR}/../bluez/attrib)
include_directories(${CMAKE_SOURCE_DIR}/../bluez/src)
include_directories(${CMAKE_SOURCE_DIR}/../bluez/src/shared)
include_directories(${CMAKE_SOURCE_DIR}/../bluez/btio)
include_directories(${CMAKE_SOURCE_DIR}/../bluez/lib)
include_directories(${CMAKE_SOURCE_DIR}/../bluez/client)
include_directories(${CMAKE_SOURCE_DIR}/../bluez/emulator)
include_directories(${CMAKE_SOURCE_DIR}/../bluez/monitor)
include_directories(${CMAKE_SOURCE_DIR}/../bluez)
include_directories(/usr/include/dbus)
set( CMAKE_CXX_FLAGS "-fpermissive" )
# Search every source files
aux_source_directory(. SRC_LIST)
include_directories (/usr)
aux_source_directory(${CMAKE_SOURCE_DIR}/../bluez/gdbus SRC_BLUEZ_GDBUS)
aux_source_directory(${CMAKE_SOURCE_DIR}/../bluez/client SRC_BLUEZ_CLIENT)
aux_source_directory(${CMAKE_SOURCE_DIR}/../bluez/btio SRC_BLUEZ_BTIO_LIST)
aux_source_directory(${CMAKE_SOURCE_DIR}/../bluez/attrib SRC_BLUEZ_ATTRIB_LIST)
aux_source_directory(${CMAKE_SOURCE_DIR}/../bluez/emulator SRC_BLUEZ_EMULATOR)
aux_source_directory(${CMAKE_SOURCE_DIR}/../bluez/lib SRC_BLUEZ_LIB)
aux_source_directory(${CMAKE_SOURCE_DIR}/../bluez/monitor SRC_BLUEZ_MONITOR)
aux_source_directory(${CMAKE_SOURCE_DIR}/../bluez/src SRC_BLUEZ_SRC)
aux_source_directory(${CMAKE_SOURCE_DIR}/../bluez/src/shared SRC_BLUEZ_SRC_SHARED)
add_executable(${PROJECT_NAME} ${SRC_LIST})
# Library used in test
add_library(${PROJECT_NAME}-lib
Thread.cpp
NetworkThread.cpp
UdpSocket.cpp)
add_library(MyBluezLib-lib
${SRC_BLUEZ_SRC} ${SRC_BLUEZ_LIB}
${SRC_BLUEZ_GDBUS} ${SRC_BLUEZ_CLIENT} ${SRC_BLUEZ_BTIO_LIST} ${SRC_BLUEZ_ATTRIB_LIST} ${SRC_BLUEZ_EMULATOR}
${SRC_BLUEZ_SRC_SHARED} ${SRC_BLUEZ_MONITOR})
# Link libraries
TARGET_LINK_LIBRARIES (${PROJECT_NAME}
pthread
glog
bluetooth
${GLIB2_LIBRARIES} #bluetooth
readline
expat
dbus-1
dl
MyBluezLib-lib
)
And this is my make call and his answear :
Scanning dependencies of target MyBluezLib-lib
[ 1%] Building C object src/CMakeFiles/MyBluezLib-lib.dir/home/grosalex/job/stageING3/bluez/src/rfkill.c.obj
In file included from /home/grosalex/job/stageING3/bluez/src/rfkill.c:39:0:
/home/grosalex/job/stageING3/bluez/src/adapter.h:29:23: erreur fatale: dbus/dbus.h: Aucun fichier ou dossier de ce type
#include <dbus/dbus.h>
^
compilation terminée.
As far as I can see, you have wrong include directory for dbus. You have include_directories(/usr/include/dbus) and in my host Linux I have following include flags, if I issue pkg-config --cflags dbus-glib-1:
-pthread -I/usr/include/dbus-1.0 -I/usr/lib64/dbus-1.0/include -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include
Try to configure this include:
include_directories(/usr/include/dbus-1.0)
I'm trying to compile a program that uses the URG (Laser scanner) library along with PCL. URG uses make to build but PCL uses cmake. I've been trying to use cmake for both but i've been having issues.
I found FindURG.cmake and put it in the modules folder here: https://github.com/wicron/vlidar/blob/master/cmake/FindURG.cmake
My CMakeLists is:
cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
project(MY_GRAND_PROJECT)
find_package(PCL 1.3 REQUIRED COMPONENTS common io)
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})
find_package(URG REQUIRED)
include_directories(${URG_INCLUDE_DIR})
link_directories(${URG_LIBRARY})
#add_executable(pcd_write_test pcd_write.cpp)
add_executable(urg_read_test gdScanSample.cpp)
#target_link_libraries(pcd_write_test ${PCL_COMMON_LIBRARIES} ${PCL_IO_LIBRARIES})
target_link_libraries(urg_read_test ${URG_LIBRARY})
SET(CMAKE_C_FLAGS "-I/usr/local/include/urg")
#SET(CMAKE_CXX_FLAGS "-I/usr/local/include/urg")
PCL is found fine, URG is also found as shown below. The directories look fine too.
root#CCSL02:/home/marwan/pcl_sample# cmake CMakeLists.txt
-- looking for PCL_COMMON
-- looking for PCL_OCTREE
-- looking for PCL_IO
-- Found c_urg libraries. /usr/local/lib/libc_urg_system.so/usr/local/lib/libc_urg.so/usr/local/lib/libc_urg_connection.so/usr/lib/liburg.so/usr/lib/liburg_connection.so/usr/lib/liburg_system.so/usr/lib/liburg_common.so/usr/lib/liburg_coordinate.so/usr/lib/liburg_geometry.so
-- Configuring done
-- Generating done
-- Build files have been written to: /home/marwan/pcl_sample
But as soon as I run make, here's what I get:
root#CCSL02:/home/marwan/pcl_sample# make
[100%] Building CXX object CMakeFiles/urg_read_test.dir/gdScanSample.cpp.o
/home/marwan/pcl_sample/gdScanSample.cpp:10:21: fatal error: UrgCtrl.h: No such file or directory compilation terminated.
make[2]: *** [CMakeFiles/urg_read_test.dir/gdScanSample.cpp.o] Error 1
make[1]: *** [CMakeFiles/urg_read_test.dir/all] Error 2
make: *** [all] Error 2
I've tried to play with the CMakeLists in which I tried added the CXX flags but no luck
It should be noted that the following makefile compiles the urg program normally
# Makefile for urg_sample
# Satofumi KAMIMURA
# $Id: Makefile 1997 2012-10-30 02:57:51Z satofumi $
CXXFLAGS = -g -O0 -Wall -Werror `urg-config --cflags` `sdl-config --cflags`
LDFLAGS =
LDLIBS = `urg-config --libs` `sdl-config --libs` -lc
TARGET = gdScanSample
all : $(TARGET)
clean :
$(RM) *.o $(TARGET)
.PHONY : all clean
You need to verify that SET(CMAKE_C_FLAGS "-I/usr/local/include/urg") points to the directory where all the h files are. Maybe you will need to add more than one location.
Solved thanks to ComicSansMS
Here's a working CMakeLists.txt:
cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
project(MY_GRAND_PROJECT)
find_package(PCL 1.3 REQUIRED)#COMPONENTS common io)
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})
find_package(URG REQUIRED)
include_directories(${URG_INCLUDE_DIR}/urg)
link_directories(${URG_LIBRARIES})
add_executable(pcd_write_test pcd_write.cpp)
target_link_libraries(pcd_write_test ${PCL_LIBRARIES} ${URG_LIBRARIES})
I was able to successfully configure and generate the build folder (KinectSLAM6D/build.). However, when I try to build it using make, I got an error saying gsl is not found. I am pretty sure this is just a configuration issue as I have gsl installed (they're in usr/local), but I am unable to configure it. I have tried adding the following lines to CMakeList:
include_directories(${GSL_INCLUDE_DIRS} ${GSLCBLAS_INCLUDE_DIRS})
set(LIBS ${LIBS} ${GSL_LIBRARIES} ${GSLCBLAS_LIBRARIES})
I have copied the pertinent output below. I have found a couple of answers to compiling with gsl (adding -lgsl). However, I have no clue where to put that in CMakeLists or the generated MakeList and MakeList2 files.
Here's the generated output.
....
[ 44%] Building CXX object CMakeFiles/Kinect6DSLAM.dir/src/GraphOptimizer_G2O.cpp.o
[ 45%] Building CXX object CMakeFiles/Kinect6DSLAM.dir/src/CKinect2DRawlog.cpp.o
Linking CXX executable Kinect6DSLAM
/usr/bin/ld: warning: libopencv_core.so.2.3, needed by /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../lib/libmrpt-base.so, may conflict with libopencv_core.so.2.4
/usr/bin/ld: warning: libopencv_imgproc.so.2.3, needed by /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../lib/libmrpt-base.so, may conflict with libopencv_imgproc.so.2.4
/usr/bin/ld: warning: libopencv_highgui.so.2.3, needed by /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../lib/libmrpt-base.so, may conflict with libopencv_highgui.so.2.4
../gicp/libgicp.a(gicp.o): In function `dgc::gicp::GICPPointSet::ComputeMatrices()':
gicp.cpp:(.text+0x462): undefined reference to `gsl_vector_alloc'
gicp.cpp:(.text+0x470): undefined reference to `gsl_vector_alloc'
... a bunch more undefined references to gsl
collect2: ld returned 1 exit status
make[2]: *** [Kinect6DSLAM] Error 1
make[1]: *** [CMakeFiles/Kinect6DSLAM.dir/all] Error 2
make: *** [all] Error 2
This if the full CMakeList.txt. I am trying to run Miguel Algaba's SLAM project.
PROJECT(KinectSLAM6D)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8 FATAL_ERROR)
if(COMMAND cmake_policy)
cmake_policy(SET CMP0003 NEW) # Required by CMake 2.7+
endif(COMMAND cmake_policy)
# Set the output directory for the build executables
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/build)
#Add here your project dependencies
FIND_PACKAGE(MRPT REQUIRED hwdrivers maps graphslam) #Add here your project dependencies
FIND_PACKAGE(PCL REQUIRED)
FIND_PACKAGE(OpenCV REQUIRED )
INCLUDE_DIRECTORIES(${PCL_INCLUDE_DIRS})
LINK_DIRECTORIES(${PCL_LIBRARY_DIRS})
ADD_DEFINITIONS(${PCL_DEFINITIONS})
# Required by StanfordGICP
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
FIND_PACKAGE(GSL REQUIRED)
include_directories(${GSL_INCLUDE_DIRS} ${GSLCBLAS_INCLUDE_DIRS})
set(LIBS ${LIBS} ${GSL_LIBRARIES} ${GSLCBLAS_LIBRARIES})
FIND_PACKAGE(Boost COMPONENTS system program_options REQUIRED)
include_directories(${PROJECT_SOURCE_DIR}/gicp)
include_directories(${PROJECT_SOURCE_DIR}/gicp/ann_1.1.1/include/ANN)
# G2O library
# Set up the top-level include directories
SET( G2O_INCLUDE ${PROJECT_SOURCE_DIR}/EXTERNAL/g2o CACHE PATH "Directory of G2O")
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR} ${G2O_INCLUDE})
# Add g2o lib dir
LINK_DIRECTORIES( ${LINK_DIRECTORIES} "${G2O_INCLUDE}/lib" )
#Generate config.h
configure_file(g2o/trunk/config.h.in ${PROJECT_BINARY_DIR}/g2o/config.h)
include_directories(${PROJECT_BINARY_DIR})
INSTALL(FILES ${PROJECT_BINARY_DIR}/g2o/config.h DESTINATION ${CMAKE_INSTALL_PREFIX}/include/g2o)
# Include the subdirectories
ADD_SUBDIRECTORY(g2o/trunk)
INCLUDE_DIRECTORIES(${CSPARSE_INCLUDE_DIR}) #You can use CPARSE or CHOLMOD
INCLUDE_DIRECTORIES(${CHOLMOD_INCLUDE_DIR})
set(G2O_DIR ${PROJECT_SOURCE_DIR}/g2o/trunk)
include_directories(${G2O_DIR})
link_directories(${G2O_DIR}/lib)
# Declare the target (an executable)
ADD_EXECUTABLE(Kinect6DSLAM kinect6DSLAM.cpp
./include/KinectGrabber.h
./include/KinectGrabber_OpenNI.h
./src/KinectGrabber_OpenNI.cpp
./include/KinectGrabber_Rawlog.h
./src/KinectGrabber_Rawlog.cpp
./include/KinectGrabber_Rawlog2.h
./src/KinectGrabber_Rawlog2.cpp
./include/KinectGrabber_MRPT.h
./src/KinectGrabber_MRPT.cpp
./include/VisualFeatureDescriptorExtractor.h
./include/VisualFeatureDescriptorExtractor_SURF_GPU.h
./include/VisualFeatureDescriptorExtractor_Generic.h
./include/VisualFeatureDescriptorExtractor_ORB.h
./include/VisualFeatureMatcher.h
./include/VisualFeatureMatcher_Generic.h
./include/PointCloudViewer.h
./include/PointCloudViewer_MRPT.h
./src/VisualFeatureDescriptorExtractor_SURF_GPU.cpp
./src/VisualFeatureDescriptorExtractor_Generic.cpp
./src/VisualFeatureDescriptorExtractor_ORB.cpp
./src/VisualFeatureMatcher_Generic.cpp
./src/PointCloudViewer_MRPT.cpp
./include/Visual3DRigidTransformationEstimator.h
./include/Visual3DRigidTransformationEstimator_SVD.h
./src/Visual3DRigidTransformationEstimator_SVD.cpp
./include/Visual3DRigidTransformationEstimator_RANSAC.h
./src/Visual3DRigidTransformationEstimator_RANSAC.cpp
./include/ICPPoseRefiner.h
./include/ICPPoseRefiner_PCL.h
./src/ICPPoseRefiner_PCL.cpp
./include/ICPPoseRefiner_StanfordGICP.h
./src/ICPPoseRefiner_StanfordGICP.cpp
./include/Miscellaneous.h
./src/Miscellaneous.cpp
./include/FrameRGBD.h
./src/FrameRGBD.cpp
./include/PointCloudDownsampler.h
./src/PointCloudDownsampler.cpp
./include/KeyframeLoopDetector.h
./src/KeyframeLoopDetector.cpp
./include/GraphOptimizer.h
./include/GraphOptimizer_MRPT.h
./src/GraphOptimizer_MRPT.cpp
./include/GraphOptimizer_G2O.h
./src/GraphOptimizer_G2O.cpp
./include/CKinect2DRawlog.h
./src/CKinect2DRawlog.cpp
)
TARGET_LINK_LIBRARIES(Kinect6DSLAM ${MRPT_LIBS}
${PCL_LIBRARIES}
${OpenCV_LIBS}
${Boost_LIBRARIES}
#GICP
${GSL_LIBRARIES}
${PROJECT_SOURCE_DIR}/gicp/ann_1.1.1/lib/libANN.a
${PROJECT_SOURCE_DIR}/gicp/libgicp.a
#G2O
core math_groups types_slam3d
solver_csparse #You can use CPARSE or CHOLMOD
solver_cholmod ${CHOLMOD_LIBRARIES}
)
# Declare the target (an executable)
ADD_EXECUTABLE(PairwiseAlignmentSteps PairwiseAlignmentSteps.cpp
./include/KinectGrabber.h
./include/KinectGrabber_OpenNI.h
./src/KinectGrabber_OpenNI.cpp
./include/KinectGrabber_Rawlog.h
./src/KinectGrabber_Rawlog.cpp
./include/KinectGrabber_MRPT.h
./src/KinectGrabber_MRPT.cpp
./include/VisualFeatureDescriptorExtractor.h
./include/VisualFeatureDescriptorExtractor_SURF_GPU.h
./include/VisualFeatureDescriptorExtractor_Generic.h
./include/VisualFeatureDescriptorExtractor_ORB.h
./include/VisualFeatureMatcher.h
./include/VisualFeatureMatcher_Generic.h
./include/PointCloudViewer.h
./include/PointCloudViewer_MRPT.h
./src/VisualFeatureDescriptorExtractor_SURF_GPU.cpp
./src/VisualFeatureDescriptorExtractor_Generic.cpp
./src/VisualFeatureDescriptorExtractor_ORB.cpp
./src/VisualFeatureMatcher_Generic.cpp
./src/PointCloudViewer_MRPT.cpp
./include/Visual3DRigidTransformationEstimator.h
./include/Visual3DRigidTransformationEstimator_SVD.h
./src/Visual3DRigidTransformationEstimator_SVD.cpp
./include/Visual3DRigidTransformationEstimator_RANSAC.h
./src/Visual3DRigidTransformationEstimator_RANSAC.cpp
./include/ICPPoseRefiner.h
./include/ICPPoseRefiner_PCL.h
./src/ICPPoseRefiner_PCL.cpp
./include/ICPPoseRefiner_StanfordGICP.h
./src/ICPPoseRefiner_StanfordGICP.cpp
./include/Miscellaneous.h
./src/Miscellaneous.cpp
./include/FrameRGBD.h
./src/FrameRGBD.cpp
./include/PointCloudDownsampler.h
./src/PointCloudDownsampler.cpp
)
TARGET_LINK_LIBRARIES(PairwiseAlignmentSteps ${MRPT_LIBS}
${PCL_LIBRARIES}
${OpenCV_LIBS}
${Boost_LIBRARIES}
#GICP
${GSL_LIBRARIES}
${PROJECT_SOURCE_DIR}/gicp/ann_1.1.1/lib/libANN.a
${PROJECT_SOURCE_DIR}/gicp/libgicp.a
)
# Set optimized building:
IF(CMAKE_COMPILER_IS_GNUCXX AND NOT CMAKE_BUILD_TYPE MATCHES "Debug")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -mtune=native")
ENDIF(CMAKE_COMPILER_IS_GNUCXX AND NOT CMAKE_BUILD_TYPE MATCHES "Debug")
target_link_libraries(Kinect6DSLAM ${LIBS})
Something tells me, that adding target_link_libraries(Kinect6DSLAM ${LIBS}) will help you.
Also, instead of constructs like
set(VAR ${VAR} somethingelse)
you can use this:
list(APPEND VAR somethingelse)