Discuss here different C compiler set ups, and compiling executables for the ESP8266

User avatar
By sake402
#55889 So I have this ESP8266 application in eclipse using the Cross GCC with one main file I named main.c.

All compiler and linker flags were manually setup and I have a successful compilation and linking.

But then depending on the order of my linkage, my application runs or not.

If I link with the below command, the application runs perfectly

Code: Select allxtensa-lx106-elf-gcc -L"C:\ESP8266\esp8266-bsp\RTOS-SDK\lib" -L"C:\ESP8266\HAL" -nostdlib -u call_user_start -Wl,-static -TC:/ESP8266/esp8266-bsp/RTOS-SDK/ld/eagle.app.v6.ld -Wl,--gc-sections -o "RGBDisplay" -Wl,--start-group -lminic -lmirom -lcirom -lm -lgcc -lhal -lphy -lpp -lnet80211 -lwpa -lcrypto -lmain -lfreertos -llwip -lssc -lspiffs -Wl,--end-group  ./main.o


But you see the linking order is wrong as main.o should appear before all the SDK libraries. If I eventually reference some library code from my main.o, I get error 'undefined references to xxx'.

So I had to order my linkage as

Code: Select allxtensa-lx106-elf-gcc -L"C:\ESP8266\esp8266-bsp\RTOS-SDK\lib" -L"C:\ESP8266\HAL" -nostdlib -u call_user_start -Wl,-static -TC:/ESP8266/esp8266-bsp/RTOS-SDK/ld/eagle.app.v6.ld -Wl,--gc-sections -o "RGBDisplay" -Wl,--start-group ./main.o -lminic -lmirom -lcirom -lm -lgcc -lhal -lphy -lpp -lnet80211 -lwpa -lcrypto -lmain -lfreertos -llwip -lssc -lspiffs -Wl,--end-group


Compilation and linkage is still successful, but then it wont run on the target ESP8266.

I also tried

Code: Select allxtensa-lx106-elf-gcc -L"C:\ESP8266\esp8266-bsp\RTOS-SDK\lib" -L"C:\ESP8266\HAL" -nostdlib -u call_user_start -Wl,-static -TC:/ESP8266/esp8266-bsp/RTOS-SDK/ld/eagle.app.v6.ld -Wl,--gc-sections -o "RGBDisplay"  ./main.o -Wl,--start-group -lminic -lmirom -lcirom -lm -lgcc -lhal -lphy -lpp -lnet80211 -lwpa -lcrypto -lmain -lfreertos -llwip -lssc -lspiffs -Wl,--end-group


And it wont run either.

I am certainly missing something. Right?

Thanks for your response.
User avatar
By jcmvbkbc
#55920
sake402 wrote:If I link with the below command, the application runs perfectly

Code: Select allxtensa-lx106-elf-gcc -L"C:\ESP8266\esp8266-bsp\RTOS-SDK\lib" -L"C:\ESP8266\HAL" -nostdlib -u call_user_start -Wl,-static -TC:/ESP8266/esp8266-bsp/RTOS-SDK/ld/eagle.app.v6.ld -Wl,--gc-sections -o "RGBDisplay" -Wl,--start-group -lminic -lmirom -lcirom -lm -lgcc -lhal -lphy -lpp -lnet80211 -lwpa -lcrypto -lmain -lfreertos -llwip -lssc -lspiffs -Wl,--end-group  ./main.o


But you see the linking order is wrong as main.o should appear before all the SDK libraries. If I eventually reference some library code from my main.o, I get error 'undefined references to xxx'.

So I had to order my linkage as

Code: Select allxtensa-lx106-elf-gcc -L"C:\ESP8266\esp8266-bsp\RTOS-SDK\lib" -L"C:\ESP8266\HAL" -nostdlib -u call_user_start -Wl,-static -TC:/ESP8266/esp8266-bsp/RTOS-SDK/ld/eagle.app.v6.ld -Wl,--gc-sections -o "RGBDisplay" -Wl,--start-group ./main.o -lminic -lmirom -lcirom -lm -lgcc -lhal -lphy -lpp -lnet80211 -lwpa -lcrypto -lmain -lfreertos -llwip -lssc -lspiffs -Wl,--end-group


Compilation and linkage is still successful, but then it wont run on the target ESP8266.

I also tried

Code: Select allxtensa-lx106-elf-gcc -L"C:\ESP8266\esp8266-bsp\RTOS-SDK\lib" -L"C:\ESP8266\HAL" -nostdlib -u call_user_start -Wl,-static -TC:/ESP8266/esp8266-bsp/RTOS-SDK/ld/eagle.app.v6.ld -Wl,--gc-sections -o "RGBDisplay"  ./main.o -Wl,--start-group -lminic -lmirom -lcirom -lm -lgcc -lhal -lphy -lpp -lnet80211 -lwpa -lcrypto -lmain -lfreertos -llwip -lssc -lspiffs -Wl,--end-group


And it wont run either.

Can you add -Wl,-Map=RGBDisplay.map to each of these command lines and share the resulting maps?
I'd expect your second and third command lines to work, it's a bit surprising that they don't.