我正在使用一个拥有自己的库的开发板。我已经在上面安装了 ROS,现在我需要通过将其库包含到包的 CMakeLists.txt 中来使用发布/订阅。我还必须注意,我使用 Eclipse 进行编译,所以 CMakeLists.txt 就是这种形式。这是我想在 CMakeLists.txt 中使用的硬件库的 Makefile:
DIR=$(shell pwd)/../
INCS = -I.\
-I$(DIR) \
-I$(DIR)/hardware \
-I$(DIR)/hardware/environment \
-I$(DIR)/hardware/environment/cores \
-I$(DIR)/hardware/environment/cores/environment \
-I$(DIR)/hardware/environment/variants \
-I$(DIR)/hardware/environment/variants/sunxi \
-I$(DIR)/libraries \
-I$(DIR)/libraries/Serial \
-I$(DIR)/libraries/SPI \
-I$(DIR)/libraries/Wire \
-I$(DIR)/libraries/LiquidCrystal \
-I$(DIR)/Basibos/include LIBS=../libenvironment.a TARGET=../output/test
OBJS = BasibosAnaProgram
all:
@mkdir -p $(TARGET)
for i in $(OBJS); do echo "$(CXX) $(INCS) $$i.cpp -o $(TARGET)/$$i $(LIBS)"; done
@for i in $(OBJS); do $(CXX) $(INCS) $$i.cpp -o $(TARGET)/$$i $(LIBS); done
clean:
@for i in $(OBJS); do rm -f $(TARGET)/$$i; done
以下是 Makefile 应包含的示例 CMakeLists.txt:
cmake_minimum_required(VERSION 2.4.6)
include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake)
rosbuild_init()
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)
rosbuild_add_library(${PROJECT_NAME} src/Basibos.cpp)
rosbuild_add_library(${PROJECT_NAME} src/HedefeGitme.cpp)
rosbuild_add_library(${PROJECT_NAME} src/Konum.cpp)
rosbuild_add_library(${PROJECT_NAME} src/Robot.cpp)
rosbuild_add_library(${PROJECT_NAME} src/Sonar.cpp)
rosbuild_add_library(${PROJECT_NAME} src/Zaman.cpp)
rosbuild_add_library(${PROJECT_NAME} src/XMLAyiklayici.cpp)
rosbuild_add_executable(srctest RobotKontrol.cpp)
target_link_libraries(srctest ${PROJECT_NAME})
我被困住了,没有帮助就无法前进。任何帮助将不胜感激。提前致谢