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

User avatar
By lilzz
#49000 how it can locate the library and linker script?
I compile it and it worked after I export the path
export PATH=/home/lilzz/esp-open-sdk/xtensa-lx106-elf/bin:$PATH

but the makefile doesn't have path to library and linker script. so how does it find them?

Code: Select allCC = xtensa-lx106-elf-gcc
CFLAGS = -I. -mlongcalls
LDLIBS = -nostdlib -Wl,--start-group -lmain -lnet80211 -lwpa -llwip -lpp -lphy -Wl,--end-group -lgcc
LDFLAGS = -Teagle.app.v6.ld

blinky-0x00000.bin: blinky
   esptool.py elf2image $^

blinky: blinky.o

blinky.o: blinky.c

flash: blinky-0x00000.bin
   esptool.py write_flash 0 blinky-0x00000.bin 0x40000 blinky-0x40000.bin

clean:
   rm -f blinky blinky.o blinky-0x00000.bin blinky-0x40000.bin
User avatar
By jcmvbkbc
#49004
lilzz wrote:how it can locate the library and linker script?
I compile it and it worked after I export the path
export PATH=/home/lilzz/esp-open-sdk/xtensa-lx106-elf/bin:$PATH

but the makefile doesn't have path to library and linker script. so how does it find them?

They are in one of the locations searched by default. You can instruct the linker to print where it gets libraries by adding -Wl,-t to the compiler command line.
You'd see something like that:

Code: Select allxtensa-lx106-elf-gcc -Teagle.app.v6.ld -Wl,-t  blinky.o  -nostdlib -Wl,--start-group -lmain -lnet80211 -lwpa -llwip -lpp -lphy -Wl,--end-group -lgcc -o blinky
/home/jcmvbkbc/tmp/esp/esp-open-sdk/xtensa-lx106-elf/lib/gcc/xtensa-lx106-elf/4.8.5/../../../../xtensa-lx106-elf/bin/ld: mode elf32xtensa                                                                                       
blinky.o                                                                                                                                                                                                                         
(/home/jcmvbkbc/tmp/esp/esp-open-sdk/xtensa-lx106-elf/xtensa-lx106-elf/sysroot/usr/lib/libmain.a)ets_timer.o                                                                                                                     
(/home/jcmvbkbc/tmp/esp/esp-open-sdk/xtensa-lx106-elf/xtensa-lx106-elf/sysroot/usr/lib/libmain.a)user_interface.o
...
(/home/jcmvbkbc/tmp/esp/esp-open-sdk/xtensa-lx106-elf/xtensa-lx106-elf/sysroot/usr/lib/libnet80211.a)ieee80211.o
...
(/home/jcmvbkbc/tmp/esp/esp-open-sdk/xtensa-lx106-elf/xtensa-lx106-elf/sysroot/usr/lib/libwpa.a)ap_config.o
...
(/home/jcmvbkbc/tmp/esp/esp-open-sdk/xtensa-lx106-elf/xtensa-lx106-elf/sysroot/usr/lib/liblwip.a)dhcp.o
...
(/home/jcmvbkbc/tmp/esp/esp-open-sdk/xtensa-lx106-elf/xtensa-lx106-elf/sysroot/usr/lib/libpp.a)esf_buf.o
...
(/home/jcmvbkbc/tmp/esp/esp-open-sdk/xtensa-lx106-elf/xtensa-lx106-elf/sysroot/usr/lib/libphy.a)phy.o
...
(/home/jcmvbkbc/tmp/esp/esp-open-sdk/xtensa-lx106-elf/lib/gcc/xtensa-lx106-elf/4.8.5/libgcc.a)_divsi3.o
...

Here libgcc comes from the compiler installation, other libraries come from the sysroot directory.
User avatar
By lilzz
#49029
jcmvbkbc wrote:Here libgcc comes from the compiler installation, other libraries come from the sysroot directory.


OK, I print out the default library path.
/home/lilzz/esp-open-sdk/xtensa-lx106-elf/xtensa-lx106-elf/sysroot/usr/lib/

but how about the path to linker script?
-Teagle.app.v6.ld where is its default path for linker script?
User avatar
By jcmvbkbc
#49048
lilzz wrote:but how about the path to linker script?
-Teagle.app.v6.ld where is its default path for linker script?

The linker searches the script in the directories passed to it with -L options, and the compiler driver passes all its default paths to the linker in that manner. You can see it if you add -v to the compiler command line. In open-esp-sdk it's in the sysroot/usr/lib.