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
有帮助吗?

解决方案 2

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})

其他提示

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top