Error compiling for Teensy 3.1


I finally got my Teensy 3.1 project mostly compiling, however it runs into an ld error at the end:

/Users/tenkai/.platformio/packages/toolchain-gccarmnoneeabi/bin/…/lib/gcc/arm-none-eabi/4.8.4/…/…/…/…/arm-none-eabi/lib/armv7e-m/libc_s.a(lib_a-openr.o): In function _open_r': openr.c:(.text._open_r+0x10): undefined reference to _open’
/Users/tenkai/.platformio/packages/toolchain-gccarmnoneeabi/bin/…/lib/gcc/arm-none-eabi/4.8.4/…/…/…/…/arm-none-eabi/lib/armv7e-m/libc_s.a(lib_a-gettimeofdayr.o): In function _gettimeofday_r': gettimeofdayr.c:(.text._gettimeofday_r+0xe): undefined reference to _gettimeofday’
collect2: error: ld returned 1 exit status
scons: *** [.pioenvs/teensy31/firmware.elf] Error 1

I am kind of at a loss at how to troubleshoot this one. I followed the reccomendations here: teensy arduino linking problem after upgrade to PIO2.0 · Issue #214 · platformio/platformio-core · GitHub
my mk20dx256.ld file is present, and I deleted appstate.json and ran platformio run to reinstall the teensy framework. Still get the same error.

Could you provide test source code to reproduce this issue?

Privately, yes. It is a big project. It is on github, i think i can share it with you

I just added you as a collaborator. the project is called FLXS1. I am working with the displaymods branch.

Please keep this code from being distributed. Thank you

I didn’t receive access to your private repository and I don’t need it. Thanks.

I’ve asked above to provide simple demo sketch to reproduce this issue. Looks, like need to add something like build_flags = -lrt to platformio.ini.

Does it work with Teensyduino?

It did compile before I began to change where all the libraries are located, now it isn’t working anymore and gives me the following error.

/var/folders/hn/ch6s89_14b1fvg7y7pb4qlyr0000gn/T/build73ee6d51daddc2da18e650e5964de0c3.tmp/sketch/lib/Audio/analyze_fft1024.cpp:28:26: fatal error: sqrt_integer.h: No such file or directory
#include “sqrt_integer.h”
Error compiling for board Teensy 3.2 / 3.1.

sqrt_integer.h is exactly where it was prior to using PlatformIO, so I am not sure why it is not finding it now.

When I added -lrt to build flags, I get the following error:

/Users/tenkai/.platformio/packages/toolchain-gccarmnoneeabi/bin/…/lib/gcc/arm-none-eabi/4.8.4/…/…/…/…/arm-none-eabi/bin/ld: cannot find -lrt

I got it working! I removed all project files and created a blank template with just a setup() and loop() and attempted to compile, which tested all the libraries I had in my lib folder. I still had errors so I removed the library in question and it began to compile properly.

Thank you!

ah, i think one of the issues with my installation was that the Audio library that comes with the framework-arduinoteensy is malformed. It has an src folder that contains incompatible source and it is missing most of the actual Audio library files, which can be found in the Teensyduino install.

even then, I had to delete the extras/wav2sketch folder because it would not compile (even though it wasn’t linked)

Looks like some library contains Linux-based code. Please use PlatformIO Library Manager.