Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple definitions of symbols when linking #66

Open
alexdewar opened this issue Nov 8, 2021 · 1 comment
Open

Multiple definitions of symbols when linking #66

alexdewar opened this issue Nov 8, 2021 · 1 comment

Comments

@alexdewar
Copy link
Contributor

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'm using gcc v11 on Arch Linux.

ddemidov added a commit that referenced this issue Nov 8, 2021
@ddemidov
Copy link
Owner

ddemidov commented Nov 8, 2021

Would b8a4c90 solve this for you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants