-->
Page 1 of 1

Blinky Makefile doesn't have SDK path, how it can locate ..

PostPosted: Sat Jun 11, 2016 11:30 am
by lilzz
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

Re: Blinky Makefile doesn't have SDK path, how it can locate

PostPosted: Sat Jun 11, 2016 11:55 am
by jcmvbkbc
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.

Re: Blinky Makefile doesn't have SDK path, how it can locate

PostPosted: Sat Jun 11, 2016 7:16 pm
by lilzz
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?

Re: Blinky Makefile doesn't have SDK path, how it can locate

PostPosted: Sun Jun 12, 2016 2:37 am
by jcmvbkbc
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.