ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
Step 1: add
target_link_libraries(${PROJECT_NAME}
i2c
)
To your CMakeList.txt
.
Step 2: Declare the headers as "C",
extern "C"
{
#include<linux/i2c-dev.h>
#include <i2c/smbus.h>
}
Because libi2c.so
is a dynamic library compiled with gcc
.
If you does not declare it explicitly, the compiler of ROS , which is g++
, will generate different function names in the symbol table thus the ld
command cannot find any match in the i2c
library.
Referece: https://en.wikipedia.org/wiki/Name_mangling