Rosserial arduino CMake unable to link libraries

asked 2021-05-15 20:59:49 -0600

Wes G gravatar image

I've had an extremely difficult time compiling my Arduino code using CMake after changing sensor libraries. The problem seems to be the linking of libraries that reference each other. Specifically I am using the Adafruit library for the INA260 current sensor. This library has a dependency on the Adafruit BusIO library but if I simply included both in the folder, nothing would link. I modified the import statements to change from <> to "" but that didn't help either. I read the Arduino-CMake wiki and added dedicated library entries to the CMakeList file but that also didn't work. I've attached the the CMakeLists file for my project below. The firmware "robot" is my main file and the others are libraries I tried to make it work. The most frustrating part is that my previous sensor worked (INA219) and now when I fix one thing, another item breaks in the same way.

link_directories(/usr/share/arduino/libraries) <-- I added this for debugging

    BOARD mega2560
    SRCS libraries/Adafruit_BusIO/Adafruit_I2CDevice.cpp libraries/Adafruit_BusIO/Adafruit_SPIDevice.cpp libraries/Adafruit_BusIO/Adafruit_BusIO_Register.cpp
    LIBS Wire

    BOARD mega2560
    SRCS libraries/Adafruit_INA260/Adafruit_INA260.cpp
    LIBS Adafruit_BusIO

  SRCS robot.cpp ${ROS_LIB_DIR}/time.cpp
  BOARD mega2560
  PORT /dev/ttyACM0
  LIBS current_sensor

Here is an example of an import statement I've tried in the library but that didn't work either.

#include "Arduino.h"
#include "../Adafruit_BusIO/Adafruit_I2CDevice.h"
#include "../Adafruit_BusIO/Adafruit_I2CRegister.h"
#include <Wire.h>

Any C++ help to get it sorted would be great!

edit retag flag offensive close merge delete