Gcc link failed

By facotl , 26 January 2016

Hello,
I use a MPU9250 with a nRF52 (cortex M4F), GCC ARM is in version 5.2

I added this in my Makefile (used, i tried with a false lib name => error), liblibmplmpu.a is the one for GCC/Cortex M4F
LDFLAGS += -L ./mpu
LDFLAGS += -llibmplmpu

I get theses errors during build, it looks like if link ignored the lib. Any idea please ?
_build/mpu9250.o: In function `mpu9250_init':
H:/Git/XXX/XXX/6_Sources/EmbeddedApplication/mpu/mpu9250.c:144: undefined reference to `inv_enable_quaternion'
H:/Git/XXX/XXX/6_Sources/EmbeddedApplication/mpu/mpu9250.c:145: undefined reference to `inv_enable_9x_sensor_fusion'
H:/Git/XXX/XXX/6_Sources/EmbeddedApplication/mpu/mpu9250.c:161: undefined reference to `inv_enable_fast_nomot'
H:/Git/XXX/XXX/6_Sources/EmbeddedApplication/mpu/mpu9250.c:166: undefined reference to `inv_enable_gyro_tc'
H:/Git/XXX/XXX/6_Sources/EmbeddedApplication/mpu/mpu9250.c:177: undefined reference to `inv_enable_vector_compass_cal'
H:/Git/XXX/XXX/6_Sources/EmbeddedApplication/mpu/mpu9250.c:178: undefined reference to `inv_enable_magnetic_disturbance'

Thank you

facotl

10 years 1 month ago

Solved

found here from David Wheeler
http://stackoverflow.com/questions/1517138/trying-to-include-a-library-but-keep-getting-undefined-reference-to-messages

"The trick here is to put the library AFTER the module you are compiling. The problem is a reference thing. The linker resolves references in order, so when the library is BEFORE the module being compiled, the linker gets confused and does not think that any of the functions in the library are needed. By putting the library AFTER the module, the references to the library in the module are resolved by the linker."

phpbb Post ID
33005
phpbb Topic ID
32969