Skip to content

Linking errors with Arduino IoT Cloud #20

@maxgerhardt

Description

@maxgerhardt

Consider the platformio.ini

[env:portenta_c33]
platform = renesas-ra
board = portenta_c33
framework = arduino
lib_ldf_mode = deep+
lib_deps =
	arduino-libraries/ArduinoIoTCloud@^1.13.0

with src/* files from https://github.com/arduino-libraries/ArduinoIoTCloud/tree/1.13.0/examples/ArduinoIoTCloud-Basic.

Compilation will go through, but linking will fail, complaining about double-defined symbols with libnosys.a and the "Storage" library, which also wants to implement _write, _read, et cetera.

.pio/build/portenta_c33/libbf8/libStorage.a(storage_retarget.cpp.o): In function `_close':
storage_retarget.cpp:(.text._close+0x0): multiple definition of `_close'
/home/zak/.platformio/packages/[email protected]/bin/../lib/gcc/arm-none-eabi/7.2.1/../../../../arm-none-eabi/lib/thumb/v8-m.main/fpv5-sp/hard/libnosys.a(close.o):close.c:(.text._close+0x0): first defined here
.pio/build/portenta_c33/libbf8/libStorage.a(storage_retarget.cpp.o): In function `_write':
storage_retarget.cpp:(.text._write+0x0): multiple definition of `_write'
/home/zak/.platformio/packages/[email protected]/bin/../lib/gcc/arm-none-eabi/7.2.1/../../../../arm-none-eabi/lib/thumb/v8-m.main/fpv5-sp/hard/libnosys.a(write.o):write.c:(.text._write+0x0): first defined here
.pio/build/portenta_c33/libbf8/libStorage.a(storage_retarget.cpp.o): In function `_read':
storage_retarget.cpp:(.text._read+0x0): multiple definition of `_read'
/home/zak/.platformio/packages/[email protected]/bin/../lib/gcc/arm-none-eabi/7.2.1/../../../../arm-none-eabi/lib/thumb/v8-m.main/fpv5-sp/hard/libnosys.a(read.o):read.c:(.text._read+0x0): first defined here
.pio/build/portenta_c33/libbf8/libStorage.a(storage_retarget.cpp.o): In function `_lseek':
storage_retarget.cpp:(.text._lseek+0x0): multiple definition of `_lseek'
/home/zak/.platformio/packages/[email protected]/bin/../lib/gcc/arm-none-eabi/7.2.1/../../../../arm-none-eabi/lib/thumb/v8-m.main/fpv5-sp/hard/libnosys.a(lseek.o):lseek.c:(.text._lseek+0x0): first defined here

While it does compile just fine in the Arduino IDE.

I've recorded the Arduino IDE linker commands here. Noticable differences:

  • no --specs=nano.specs in Arduino IDE`, but PIO has it
  • missing -nostdlib in PIO during C/C++ files compilation but present during linking
  • missing -Wl,--whole-archive -Wl,--start-group [..] -Wl,--no-whole-archive -Wl,--end-group missing in PIO

Trying to patch that in, especially with

env.Prepend(_LIBFLAGS="-Wl,--whole-archive  -Wl,--start-group ")
env.Append(_LIBFLAGS=" -Wl,--no-whole-archive -lfsp -lstdc++ -lsupc++ -lm -lc -lgcc -lnosys -Wl,--end-group ")

in the arduino.py scirpt results.. in diferent kind of linking errors, in lwip.

Linking .pio\build\portenta_c33\firmware.elf
C:\Users\Max\.platformio\packages\framework-arduinorenesas-portenta\libraries\lwIpWrapper\src\cortex-m33\liblwIP.a(fsdata.o):(.rodata.file__index_html+0x0): multiple definition of `file__index_html'
C:\Users\Max\.platformio\packages\framework-arduinorenesas-portenta\libraries\lwIpWrapper\src\cortex-m33\liblwIP.a(fs.o):(.rodata.file__index_html+0x0): first defined here
C:\Users\Max\.platformio\packages\framework-arduinorenesas-portenta\libraries\lwIpWrapper\src\cortex-m33\liblwIP.a(fsdata.o):(.rodata.file__404_html+0x0): multiple definition of `file__404_html'
C:\Users\Max\.platformio\packages\framework-arduinorenesas-portenta\libraries\lwIpWrapper\src\cortex-m33\liblwIP.a(fs.o):(.rodata.file__404_html+0x0): first defined here
C:\Users\Max\.platformio\packages\framework-arduinorenesas-portenta\libraries\lwIpWrapper\src\cortex-m33\liblwIP.a(fsdata.o):(.rodata.file__img_sics_gif+0x0): multiple definition 
of `file__img_sics_gif'
C:\Users\Max\.platformio\packages\framework-arduinorenesas-portenta\libraries\lwIpWrapper\src\cortex-m33\liblwIP.a(fs.o):(.rodata.file__img_sics_gif+0x0): first defined here      
c:/users/max/.platformio/packages/[email protected]/bin/../lib/gcc/arm-none-eabi/7.2.1/../../../../arm-none-eabi/lib/thumb/v8-m.main/fpv5-sp/hard\libc.a(lib_a-fini.o): In function `__libc_fini_array':
fini.c:(.text.__libc_fini_array+0x26): undefined reference to `_fini'
collect2.exe: error: ld returned 1 exit status

whatever the case may be, something is causing this to not build correctly in PIO while it does work in the Arduino IDE.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions