Linker problem with Teensy makefile

Status
Not open for further replies.

eliasrobs

New member
Hello everybody,

I'm trying to build a project that is based on a Teensy 3.6 from a makefile but I have problems with the linker. It used to work but then I added the MPU9250 Arduino library to the project and the issues begun.
I basically have an obj of my project depending on MPU9250 lib, which depends on the Wire and SPI library. The problem is that I can't get the MPU lib linked to the Wire lib (at least that's the point where it fails, so don't know about SPI).
I read that in recent g++ versions the libraries should be given to the linker in order of dependece and I did that but it didn't solve the issue, so I guess it has to be something else but I can't find it.

The call to the linker is the following:
Code:
/home/elias/arduino-1.8.10/hardware/tools/arm/bin/arm-none-eabi-gcc -Os -Wl,--gc-sections,--defsym=__rtc_localtime=0 --specs=nano.specs -mcpu=cortex-m4 -mthumb -T/home/elias/arduino-1.8.10/hardware/teensy/avr/cores/teensy3/mk66fx1m0.ld -o orazio.elf [B]orazio.o[/B] ... [B]MPU9250_orazio.o[/B] [B]MPU9250.o[/B] MadgwickAHRS.o Encoder.o [B]Wire.o[/B] SPI.o usb_mouse.o serial3.o usb_dev.o usb_keyboard.o keylayouts.o usb_midi.o usb_mtp.o ser_print.o pins_teensy.o serial6_lpuart.o usb_touch.o usb_rawhid.o nonstd.o eeprom.o usb_mem.o math_helper.o usb_desc.o analog.o serial5.o mk20dx128.o serial6.o touch.o serial2.o serial4.o serial1.o usb_seremu.o usb_joystick.o usb_serial.o IPAddress.o new.o AudioStream.o HardwareSerial3.o Tone.o DMAChannel.o HardwareSerial4.o Print.o usb_inst.o Stream.o IntervalTimer.o avr_emulation.o yield.o usb_flightsim.o HardwareSerial6.o HardwareSerial1.o WMath.o usb_audio.o HardwareSerial2.o EventResponder.o WString.o HardwareSerial5.o -lm
The dependence chain is orazio.o -> MPU9250_orazio.o -> MPU9250.o -> Wire.o.
The error message I get is:
Code:
MPU9250.o: In function `MPU9250::readRegisters(unsigned char, unsigned char, unsigned char*)':
/home/elias/arduino-1.8.10/libraries/MPU9250/src/MPU9250.cpp:1025: undefined reference to `TwoWire::endTransmission(unsigned char)'
MPU9250.o: In function `TwoWire::requestFrom(unsigned char, unsigned char)':
/home/elias/arduino-1.8.10/hardware/teensy/avr/libraries/Wire/WireKinetis.h:120: undefined reference to `TwoWire::requestFrom(unsigned char, unsigned char, unsigned char)'
MPU9250.o: In function `TwoWire::endTransmission()':
/home/elias/arduino-1.8.10/hardware/teensy/avr/libraries/Wire/WireKinetis.h:116: undefined reference to `TwoWire::endTransmission(unsigned char)'
MPU9250.o: In function `MPU9250::begin()':
/home/elias/arduino-1.8.10/libraries/MPU9250/src/MPU9250.cpp:54: undefined reference to `TwoWire::begin()'
/home/elias/arduino-1.8.10/libraries/MPU9250/src/MPU9250.cpp:56: undefined reference to `TwoWire::setClock(unsigned long)'
collect2: error: ld returned 1 exit status
Makefile:311: recipe for target 'orazio.elf' failed
make: *** [orazio.elf] Error 1

A simple Arduino sketch in the IDE using MPU9250 works without problems.
Hope anyone here has a clue about what it could be! Thanks for taking the time to read through this

Edit: There are no compiler errors, and the wire object file lies in the current dir. I also tried removing all dependencies from wire (using SPI) and it links without any errors.

Cheers
Elias
 
Last edited:
I have no experience with wire at all, but looking at wire.h I guess you should compile & link WireKinetis.cpp or WireIMXRT.cpp (T4) somewhere? Might be completely wrong of course...
 
Status
Not open for further replies.
Back
Top