undefined reference to ' ' - Sensor Library bsec.h

Hey,
I have tried to solve this problem and had no success.
I am using an Arduino Mega and a BME680 sensor for measuring the temperature, humidity, AQI and so on..
Communicating through I2c
Happy for any Help

Build options changed, rebuilding all
xxxxxxxxxxxx\AppData\Local\Temp\ccovOwvy.ltrans0.ltrans.o: In function `main':

:(.text.startup+0x212): undefined reference to `bsec_init'

:(.text.startup+0x222): undefined reference to `bsec_get_version'

:(.text.startup+0x556): undefined reference to `bsec_update_subscription'

:(.text.startup+0x81a): undefined reference to `bsec_sensor_control'

:(.text.startup+0x1986): undefined reference to `bsec_do_steps'

collect2.exe: error: ld returned 1 exit status

exit status 1
Error compiling for board Arduino/Genuino Mega or Mega 2560.

LGProjekt.ino (3.67 KB)

LGProjekt.txt (3.62 KB)

Usually these sorts of errors mean that you installed only the header file of the library (bsec.h) and didn't also install the other source files of the library.

Please post a link (using the chain links icon on the forum toolbar to make it clickable) to where you downloaded the bsec library from. Or if you installed it using Library Manger (Sketch > Include Library > Manage Libraries in the Arduino IDE or Libraries > Library Manager in the Arduino Web Editor) then say so and state the full name of the library.

Thanks for your reply,

Thats the github link where i downloaded the library as ZIP file and included it.

OK, I was wrong about the cause of the error. It turns out this library is pretty complicated to use, as documented here:

To make matters worse, they provide specific instructions for SAMD and ESP8266, but not for the AVR architecture of your Arduino Mega. Here's what you need to do:

File > Examples > SPI > BarometricPressureSensor (or any other SPI example sketch)

Sketch > Show Sketch Folder

Move up folder levels until you reach the one that contains platform.txt

Open platform.txt in a text editor.

Change line 68 from:

recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" {compiler.c.elf.flags} -mmcu={build.mcu} {compiler.c.elf.extra_flags} -o "{build.path}/{build.project_name}.elf" {object_files} "{build.path}/{archive_file}" "-L{build.path}" -lm

to:

recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" {compiler.c.elf.flags} -mmcu={build.mcu} {compiler.c.elf.extra_flags} -o "{build.path}/{build.project_name}.elf" {object_files} "{build.path}/{archive_file}" {compiler.libraries.ldflags} "-L{build.path}" -lm

Save the file.

Close all Arduino IDE windows and then start the Arduino IDE.

After doing that, the sketch should now compile without errors.

I should mention that you will need to redo this every time you update to a new version of Arduino AVR Boards or the error when using the bsec library will come back.

Thank you it works now.

Changing it every update will be rough but thanks for telling me.
:slight_smile:

You're welcome. I'm glad to hear it's working now. I agree that having to make the modification on every update is annoying. Someone did submit a pull request a while back to make this change in Arduino AVR Boards (and I believe the other official Arduino cores too) so hopefully that will get merged eventually:

Until then, you can make the update a little easier by defining the customized recipe.c.combine.pattern in a file named platform.local.txt that is located in the same folder as platform.txt. The recipes defined in platform.local.txt override the ones in platform.txt. The idea behind this feature is to make it easy for people to customize platform.txt without actually needing to edit the file. Save a copy of your platform.local.txt somewhere safe. That way, after every update of Arduino AVR Boards, you only need to copy platform.local.txt into the folder.

Hi everyone,
I've the same problem with BME680 sensor and BSEC library.
I've followed the instruction of tutorial

I replaced the code in the the platform.txt

recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" {compiler.c.elf.flags} -mmcu={build.mcu} {compiler.c.elf.extra_flags} -o "{build.path}/{build.project_name}.elf" {object_files} "{build.path}/{archive_file}" "-L{build.path}" -lm

with

recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" {compiler.c.elf.flags} -mmcu={build.mcu} {compiler.c.elf.extra_flags} -o "{build.path}/{build.project_name}.elf" {object_files} "{build.path}/{archive_file}" {compiler.libraries.ldflags} "-L{build.path}" -lm

I Saved and restart Arduini IDE (ver 1.8.12)
I compiled Basic.ino but nothing
The output's compiler was

c:/users/......./arduino 1/arduino-1.8.11-windows/arduino-1.8.11/hardware/tools/avr/bin/../lib/gcc/avr/7.3.0/../../../../avr/bin/ld.exe: cannot find**-lalgobsec**

collect2.exe: error: ld returned 1 exit status

exit status 1
Errore durante la compilazione per la scheda Arduino Mega or Mega 2560.

I Download the Arduino IDE ver 1.8.11 and modified the platform.txt file but nothing else, i recieve the same complier's error.

Where i'm wrong?
Best Regardt