Linker builder failure

I am trying to include a pre-compiled library in for the build as shown below

[env:nodemcuv2]
platform = espressif8266
board = nodemcuv2
framework = arduino
build_flags = -L~⁨/Documents⁩/⁨PlatformIO⁩/⁨Projects⁩/⁨bme-680-nova-pm-8266⁩/lib/bsec_iot_example ⁩-llibalgobsec.a

But I get the following error

*** [.pio/build/nodemcuv2/firmware.elf] Implicit dependency `/Users/johnsinha/.platformio/platforms/espressif8266/builder/⁩-llibalgobsec.a' not found, needed by target `.pio/build/nodemcuv2/firmware.elf'.

Here is the rest of the output

Processing nodemcuv2 (platform: espressif8266; board: nodemcuv2; framework: arduino)

Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif8266/nodemcuv2.html
PLATFORM: Espressif 8266 2.3.1 > NodeMCU 1.0 (ESP-12E Module)
HARDWARE: ESP8266 80MHz, 80KB RAM, 4MB Flash
PACKAGES: toolchain-xtensa 2.40802.191122 (4.8.2), tool-esptool 1.413.0 (4.13), tool-esptoolpy 1.20800.0 (2.8.0), framework-arduinoespressif8266 2.20602.191128 (2.6.2)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 40 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <bsec_iot_example>
|-- <Wire> 1.0
Building in release mode
Compiling .pio/build/nodemcuv2/src/main.cpp.o
Generating LD script .pio/build/nodemcuv2/ld/local.eagle.app.v6.common.ld
Compiling .pio/build/nodemcuv2/lib6c0/bsec_iot_example/bme680.c.o
Compiling .pio/build/nodemcuv2/lib6c0/bsec_iot_example/bsec_integration.c.o
Compiling .pio/build/nodemcuv2/lib626/Wire/Wire.cpp.o
Archiving .pio/build/nodemcuv2/libFrameworkArduinoVariant.a
lib/bsec_iot_example/src/bsec_integration.c: In function 'bsec_iot_init':
lib/bsec_iot_example/src/bsec_integration.c:161:27: warning: unused variable 'bsec_status' [-Wunused-variable]
     bsec_library_return_t bsec_status = BSEC_OK;
                           ^
lib/bsec_iot_example/src/bsec_integration.c: In function 'bme680_bsec_trigger_measurement':
lib/bsec_iot_example/src/bsec_integration.c:237:12: warning: variable 'bme680_status' set but not used [-Wunused-but-set-variable]
     int8_t bme680_status = BME680_OK;
            ^
lib/bsec_iot_example/src/bsec_integration.c: In function 'bme680_bsec_read_data':
lib/bsec_iot_example/src/bsec_integration.c:297:12: warning: variable 'bme680_status' set but not used [-Wunused-but-set-variable]
     int8_t bme680_status = BME680_OK;

I have checked the .platformio/platforms/espressif8266/builder/⁩-llibalgobsec.a directory and the the libalgobsec.a is present. I know the linker picks up the binary in question since when I comment out the line in the platformio.ini file, I get the following error

/Users/johnsinha/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld: .pio/build/nodemcuv2/lib6c0/libbsec_iot_example.a(bsec_integration.c.o):(.text.bsec_iot_init+0xc): undefined reference to `bsec_init'
 /Users/johnsinha/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld: .pio/build/nodemcuv2/lib6c0/libbsec_iot_example.a(bsec_integration.c.o):(.text.bsec_iot_init+0x10): undefined reference to `bsec_set_configuration'
 /Users/johnsinha/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld: .pio/build/nodemcuv2/lib6c0/libbsec_iot_example.a(bsec_integration.c.o):(.text.bsec_iot_init+0x14): undefined reference to `bsec_set_state'
 /Users/johnsinha/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld: .pio/build/nodemcuv2/lib6c0/libbsec_iot_example.a(bsec_integration.c.o):(.text.bsec_iot_init+0x18): undefined reference to `bsec_update_subscription'
 /Users/johnsinha/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld: .pio/build/nodemcuv2/lib6c0/libbsec_iot_example.a(bsec_integration.c.o): in function `bsec_iot_init':
 bsec_integration.c:(.text.bsec_iot_init+0xb3): undefined reference to `bsec_init'
 /Users/johnsinha/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld: bsec_integration.c:(.text.bsec_iot_init+0xeb): undefined reference to `bsec_set_configuration'
 /Users/johnsinha/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld: bsec_integration.c:(.text.bsec_iot_init+0x11a): undefined reference to `bsec_set_state'
 /Users/johnsinha/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld: bsec_integration.c:(.text.bsec_iot_init+0x174): undefined reference to `bsec_update_subscription'
/Users/johnsinha/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld: .pio/build/nodemcuv2/lib6c0/libbsec_iot_example.a(bsec_integration.c.o):(.text.bsec_iot_loop+0x28): undefined reference to `bsec_sensor_control'
/Users/johnsinha/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld: .pio/build/nodemcuv2/lib6c0/libbsec_iot_example.a(bsec_integration.c.o):(.text.bsec_iot_loop+0x38): undefined reference to `bsec_do_steps'
 /Users/johnsinha/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld: .pio/build/nodemcuv2/lib6c0/libbsec_iot_example.a(bsec_integration.c.o):(.text.bsec_iot_loop+0x3c): undefined reference to `bsec_get_state'
/Users/johnsinha/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld: .pio/build/nodemcuv2/lib6c0/libbsec_iot_example.a(bsec_integration.c.o): in function `bsec_iot_loop':
 bsec_integration.c:(.text.bsec_iot_loop+0x8c): undefined reference to `bsec_sensor_control'
 /Users/johnsinha/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld: bsec_integration.c:(.text.bsec_iot_loop+0x24e): undefined reference to `bsec_do_steps'
/Users/johnsinha/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld: bsec_integration.c:(.text.bsec_iot_loop+0x35b): undefined reference to `bsec_get_state'
collect2: error: ld returned 1 exit status
*** [.pio/build/nodemcuv2/firmware.elf] Error 1

Any idea what could be wrong?

The -l flag needs the name of the library without the lib in the name. So just say -lalgobsec there

2 Likes