I've found if I #include ev3dev stuff in separate compilation units then I get errors like this:
/usr/bin/ld: BoB/modules/robots/ev3/BoB/third_party/ev3dev-lang-cpp/libev3dev.a(ev3dev.cpp.o):(.rodata+0x370): multiple definition of `ev3dev::gyro_sensor::mode_gyro_ang'; BoB/modules/robots/ev3/libbob_robots__ev3.a(mindstorms_imu.cc.o):(.rodata._ZN6ev3dev11gyro_sensor13mode_gyro_angE[_ZN6ev3dev11gyro_sensor13mode_gyro_angE]+0x0): first defined here
/usr/bin/ld: BoB/modules/robots/ev3/BoB/third_party/ev3dev-lang-cpp/libev3dev.a(ev3dev.cpp.o):(.rodata+0x380): multiple definition of `ev3dev::gyro_sensor::mode_gyro_rate'; BoB/modules/robots/ev3/libbob_robots__ev3.a(mindstorms_imu.cc.o):(.rodata._ZN6ev3dev11gyro_sensor14mode_gyro_rateE[_ZN6ev3dev11gyro_sensor14mode_gyro_rateE]+0x0): first defined here
/usr/bin/ld: BoB/modules/robots/ev3/BoB/third_party/ev3dev-lang-cpp/libev3dev.a(ev3dev.cpp.o):(.rodata+0x3a0): multiple definition of `ev3dev::gyro_sensor::mode_gyro_g_a'; BoB/modules/robots/ev3/libbob_robots__ev3.a(mindstorms_imu.cc.o):(.rodata._ZN6ev3dev11gyro_sensor13mode_gyro_g_aE[_ZN6ev3dev11gyro_sensor13mode_gyro_g_aE]+0x0): first defined here
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/mindstorms_imu.dir/build.make:103: mindstorms_imu] Error 1
make[1]: *** [CMakeFiles/Makefile2:209: CMakeFiles/mindstorms_imu.dir/all] Error 2
make: *** [Makefile:91: all] Error 2
This can be worked around by passing --allow-multiple-definition to the linker, but this is a hack. I suspect the real problem lies in some symbols not properly being marked inline (or their definitions being put separately into a .cpp file).
I've found if I
#include
ev3dev stuff in separate compilation units then I get errors like this:This can be worked around by passing
--allow-multiple-definition
to the linker, but this is a hack. I suspect the real problem lies in some symbols not properly being markedinline
(or their definitions being put separately into a .cpp file).I'm using gcc v11 on Arch Linux.