Esp-idf: [TW#16749] linker failing on macOS (IDFGH-1619)

Created on 29 Nov 2017  Â·  7Comments  Â·  Source: espressif/esp-idf

I've followed the instructions here https://esp-idf.readthedocs.io/en/latest/get-started/macos-setup.html and http://esp-idf.readthedocs.io/en/latest/get-started/index.html#get-esp-idf making sure to recursively clone and also setting PATH and IDF_PATH variables (and restarting my shell to pick them up), but I get the following linker errors building the hello_world project. I've repeated the same steps (but with the linux build tools) on Ubuntu and not encountered this issue.

/Users/matthew/esp/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/../../../../xtensa-esp32-elf/bin/ld: cannot find crt1-sim.o: No such file or directory
/Users/matthew/esp/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/../../../../xtensa-esp32-elf/bin/ld: cannot find _vectors.o: No such file or directory
/Users/matthew/esp/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/../../../../xtensa-esp32-elf/bin/ld: cannot find -lsim
/Users/matthew/esp/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/../../../../xtensa-esp32-elf/bin/ld: cannot find -lhandlers-sim
/Users/matthew/esp/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/../../../../xtensa-esp32-elf/bin/ld: cannot find -lhal
collect2: error: ld returned 1 exit status
make[1]: *** [/Users/matthew/esp/hello_world/build/bootloader/bootloader.elf] Error 1
make: *** [/Users/matthew/esp/hello_world/build/bootloader/bootloader.bin] Error 2

Most helpful comment

It looks like some compiler flags are being overridden from the environment. Could you please check if printenv | grep -i FLAGS contains any of LDFLAGS, CFLAGS, CPPFLAGS, CXXFLAGS?

All 7 comments

It looks like some compiler flags are being overridden from the environment. Could you please check if printenv | grep -i FLAGS contains any of LDFLAGS, CFLAGS, CPPFLAGS, CXXFLAGS?

Ah, that's it. I had LDFLAGS being set separately through a really old shell startup script line I'd forgotten about. Problem solved, thanks!

exact same error here. No results on printenv | grep -i FLAGS.

Any other ideas?

Building file: ../main/main.c
Invoking: Cross GCC Compiler
xtensa-esp32-elf-gcc -I/home/andi/esp/esp-idf/components/esp32/include -I/home/andi/esp/esp-idf/components/freertos/include -I/home/andi/esp/esp-idf/components/driver/include -I/home/andi/esp/esp-idf/components/nvs_flash/include -I/home/andi/esp/esp-idf/components/wpa_supplicant/include -I/home/andi/eclipse-workspace/template/build/include -I/home/andi/esp/esp-idf/components/soc/esp32/include -I/home/andi/esp/esp-idf/components/heap/include -I/home/andi/esp/esp-idf/components/soc/include -I/home/andi/esp/esp-idf/components/tcpip_adapter/include -I/home/andi/esp/esp-idf/components/lwip/include/lwip -I/home/andi/esp/esp-idf/components/lwip/include/lwip/port -I/home/andi/esp/esp-idf/components/vfs/include -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"main/main.d" -MT"main/main.o" -o "main/main.o" "../main/main.c"
Finished building: ../main/main.c

Building target: template
Invoking: Cross G++ Linker
xtensa-esp32-elf-g++  -o "template"  ./main/main.o   
/home/andi/esp/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/../../../../xtensa-esp32-elf/bin/ld: cannot find crt1-sim.o: No such file or directory
/home/andi/esp/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/../../../../xtensa-esp32-elf/bin/ld: cannot find _vectors.o: No such file or directory
/home/andi/esp/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/../../../../xtensa-esp32-elf/bin/ld: cannot find -lsim
/home/andi/esp/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/../../../../xtensa-esp32-elf/bin/ld: cannot find -lhandlers-sim
/home/andi/esp/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/../../../../xtensa-esp32-elf/bin/ld: cannot find -lhal
collect2: error: ld returned 1 exit status
makefile:165: recipe for target 'template' failed
make: *** [template] Error 1

Maybe you’ve got a LD_LIBRARY_PATH or other compiler / linker env var set?

Sent from my iPhone

On 29 Dec 2017, at 09:50, Harter Horst <[email protected]notifications@github.com> wrote:

exact same error here. No results on printenv | grep -i FLAGS.

Any other ideas?

`andi@strech:~/eclipse-workspace/template/Debug$ make
Building file: ../main/main.c
Invoking: Cross GCC Compiler
xtensa-esp32-elf-gcc -I/home/andi/esp/esp-idf/components/esp32/include -I/home/andi/esp/esp-idf/components/freertos/include -I/home/andi/esp/esp-idf/components/driver/include -I/home/andi/esp/esp-idf/components/nvs_flash/include -I/home/andi/esp/esp-idf/components/wpa_supplicant/include -I/home/andi/eclipse-workspace/template/build/include -I/home/andi/esp/esp-idf/components/soc/esp32/include -I/home/andi/esp/esp-idf/components/heap/include -I/home/andi/esp/esp-idf/components/soc/include -I/home/andi/esp/esp-idf/components/tcpip_adapter/include -I/home/andi/esp/esp-idf/components/lwip/include/lwip -I/home/andi/esp/esp-idf/components/lwip/include/lwip/port -I/home/andi/esp/esp-idf/components/vfs/include -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"main/main.d" -MT"main/main.o" -o "main/main.o" "../main/main.c"
Finished building: ../main/main.c

Building target: template
Invoking: Cross G++ Linker
xtensa-esp32-elf-g++ -o "template" ./main/main.o
/home/andi/esp/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/../../../../xtensa-esp32-elf/bin/ld: cannot find crt1-sim.o: No such file or directory
/home/andi/esp/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/../../../../xtensa-esp32-elf/bin/ld: cannot find _vectors.o: No such file or directory
/home/andi/esp/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/../../../../xtensa-esp32-elf/bin/ld: cannot find -lsim
/home/andi/esp/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/../../../../xtensa-esp32-elf/bin/ld: cannot find -lhandlers-sim
/home/andi/esp/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/../../../../xtensa-esp32-elf/bin/ld: cannot find -lhal
collect2: error: ld returned 1 exit status
makefile:165: recipe for target 'template' failed
make: * [template] Error 1
`

—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHubhttps://github.com/espressif/esp-idf/issues/1330#issuecomment-354370055, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ACLqbtNOD8rlld7rhC0Xjh21ZI0xNRPbks5tFBsXgaJpZM4QufNc.

Can't find anything in the environment. I have added the -v options to get more information from the compiler and structured the file a little bit. I have no idea what these files are and if the belong to the build environment of the esp-idf or not.

COLLECT_GCC_OPTIONS='-v' '-o' 'template'
 /home/andi/esp/xtensa-esp32-elf/bin/../libexec/gcc/xtensa-esp32-elf/5.2.0/collect2 
 -plugin /home/andi/esp/xtensa-esp32-elf/bin/../libexec/gcc/xtensa-esp32-elf/5.2.0/liblto_plugin.so 
 -plugin-opt=/home/andi/esp/xtensa-esp32-elf/bin/../libexec/gcc/xtensa-esp32-elf/5.2.0/lto-wrapper 
 -plugin-opt=-fresolution=/tmp/cc928UcH.res 
 -plugin-opt=-pass-through=-lgcc 
 -plugin-opt=-pass-through=-lc 
 -plugin-opt=-pass-through=-lsim 
 -plugin-opt=-pass-through=-lc 
 -plugin-opt=-pass-through=-lhandlers-sim 
 -plugin-opt=-pass-through=-lhal 
 -plugin-opt=-pass-through=-lgcc 

 --sysroot=/home/andi/esp/xtensa-esp32-elf/bin/../xtensa-esp32-elf/sysroot -o template crt1-sim.o 
/home/andi/esp/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/../../../../xtensa-esp32-elf/lib/crt0.o 
/home/andi/esp/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/crti.o 
/home/andi/esp/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/crtbegin.o _vectors.o -L
/home/andi/esp/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/5.2.0 -L
/home/andi/esp/xtensa-esp32-elf/bin/../lib/gcc -L
/home/andi/esp/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/../../../../xtensa-esp32-elf/lib -L
/home/andi/esp/xtensa-esp32-elf/bin/../xtensa-esp32-elf/sysroot/lib -L
/home/andi/esp/xtensa-esp32-elf/bin/../xtensa-esp32-elf/sysroot/usr/lib ./main/main.o -lstdc++ -lm -lgcc -lc -lsim -lc -lhandlers-sim -lhal -lgcc 
/home/andi/esp/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/crtend.o 
/home/andi/esp/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/crtn.o

/home/andi/esp/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/../../../../xtensa-esp32-elf/bin/ld: cannot find crt1-sim.o: No such file or directory
/home/andi/esp/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/../../../../xtensa-esp32-elf/bin/ld: cannot find _vectors.o: No such file or directory
/home/andi/esp/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/../../../../xtensa-esp32-elf/bin/ld: cannot find -lsim
/home/andi/esp/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/../../../../xtensa-esp32-elf/bin/ld: cannot find -lhandlers-sim
/home/andi/esp/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/../../../../xtensa-esp32-elf/bin/ld: cannot find -lhal
collect2: error: ld returned 1 exit status
makefile:165: recipe for target 'template' failed
make: *** [template] Error 1

This also helped me a lot.
I did unset LDFLAGS and the other global environment vars, and it worked like a charm.
Thank you!

Can you explain what exactly to do with this error? I have the same.

/Users/rodrigosene/Documents/Arduino/hardware/espressif/esp32/tools/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/../../../../xtensa-esp32-elf/bin/ld: cannot find -ldriver /Users/rodrigosene/Documents/Arduino/hardware/espressif/esp32/tools/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/../../../../xtensa-esp32-elf/bin/ld: cannot find -lwpa_supplicant /Users/rodrigosene/Documents/Arduino/hardware/espressif/esp32/tools/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/../../../../xtensa-esp32-elf/bin/ld: cannot find -lbt /Users/rodrigosene/Documents/Arduino/hardware/espressif/esp32/tools/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/../../../../xtensa-esp32-elf/bin/ld: cannot find -lc_nano /Users/rodrigosene/Documents/Arduino/hardware/espressif/esp32/tools/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/../../../../xtensa-esp32-elf/bin/ld: cannot find -lc /Users/rodrigosene/Documents/Arduino/hardware/espressif/esp32/tools/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/../../../../xtensa-esp32-elf/bin/ld: cannot find -lmbedtls /Users/rodrigosene/Documents/Arduino/hardware/espressif/esp32/tools/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/../../../../xtensa-esp32-elf/bin/ld: cannot find -llwip /Users/rodrigosene/Documents/Arduino/hardware/espressif/esp32/tools/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/../../../../xtensa-esp32-elf/bin/ld: cannot find -lstdc++ collect2: error: ld returned 1 exit status exit status 1 Error compiling for board DOIT ESP32 DEVKIT V1.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jakkubu picture jakkubu  Â·  4Comments

jakkra picture jakkra  Â·  3Comments

waayst picture waayst  Â·  4Comments

beriberikix picture beriberikix  Â·  3Comments

LosDeiblos picture LosDeiblos  Â·  4Comments