You can chat about native SDK questions and issues here.

User avatar
By CARPP
#80285 I oriented my project (in terms of overall structure and makefiles) on the example project simple_pair from here: https://github.com/espressif/ESP8266_NO ... r/examples

This is my structure:

Image

I followed this tutorial on how to setup the toolchain (it is in german, I am sorry): https://cutmywire.wordpress.com/2017/05 ... omment-943

Basically all my ESP8266 toolchain stuff is in:

/opt/esp/

The compiler stuff is in:

/opt/esp/crosstool-NG/builds/xtensa-lx106-elf/bin/

The header files (e.g. osapi.h) are in:

/opt/esp/sdk/include/

I added all those directories to my PATH-Variable:

echo $PATH
/opt/esp/sdk/include:/opt/esp/sdk/:/opt/esp/crosstool-NG/builds/xtensa-lx106-elf/bin


I am in my ESP8266 project folder and I am typing this into my console:

Code: Select alltest@Device:/mnt/c/Users/Standardbenutzer/Documents/ESP8266/ESP8266$ make COMPILE=gcc
make[1]: Entering directory '/mnt/c/Users/Standardbenutzer/Documents/ESP8266/ESP8266/user'
DEPEND: xtensa-lx106-elf-gcc -M -Os -g -Wpointer-arith -Wundef -Werror -Wl,-EL -fno-inline-functions -nostdlib -mlongcalls -mtext-section-literals -ffunction-sections -fdata-sections -fno-builtin-printf -DICACHE_FLASH -DSPI_FLASH_SIZE_MAP=0 -I include -I ../include -I ../include/eagle -I ../driver_lib/include user_main.c
user_main.c:1:19: fatal error: osapi.h: No such file or directory
 #include "osapi.h"
                   ^
compilation terminated.
make[2]: Entering directory '/mnt/c/Users/Standardbenutzer/Documents/ESP8266/ESP8266/user'
make[2]: *** user: No such file or directory.  Stop.
make[2]: Leaving directory '/mnt/c/Users/Standardbenutzer/Documents/ESP8266/ESP8266/user'
../Makefile:331: recipe for target '.subdirs' failed
make[1]: *** [.subdirs] Error 2
make[1]: Leaving directory '/mnt/c/Users/Standardbenutzer/Documents/ESP8266/ESP8266/user'
Makefile:331: recipe for target '.subdirs' failed
make: *** [.subdirs] Error 2


So why are the header files not found even though I added the path to $PATH?

I also tried this:

Code: Select all`xtensa-lx106-elf-gcc -print-prog-name=cc1` -v
ignoring nonexistent directory "/opt/esp/crosstool-NG/builds/xtensa-lx106-elf/xtensa-lx106-elf/sysroot/opt/esp/crosstool-NG/builds/xtensa-lx106-elf/xtensa-lx106-elf/sysroot/include"
#include "..." search starts here:
#include <...> search starts here:
 /opt/esp/crosstool-NG/builds/xtensa-lx106-elf/lib/gcc/xtensa-lx106-elf/4.8.2/include
 /opt/esp/crosstool-NG/builds/xtensa-lx106-elf/lib/gcc/xtensa-lx106-elf/4.8.2/include-fixed
 /opt/esp/crosstool-NG/builds/xtensa-lx106-elf/lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/include
 /opt/esp/crosstool-NG/builds/xtensa-lx106-elf/xtensa-lx106-elf/sysroot/usr/include
End of search list.


Please help :oops:
User avatar
By quackmore
#80301 what you add to $PATH will be used to find the executables (compiler and linker)

while you have to tell the compiler where the include files are

"osapi.h" is a sdk include so it's located into <your sdk directory>/include

now look at your makefile, search where the include paths are specified and add the missing one

the result should look like this (not exactly like this)
CCFLAGS:= -I$(TOP_DIR)/src/include -I$(SDK_DIR)/include

most likely you will have a similar problem with the linker finding sdk libraries and you will have to change the linker flags too

should be something like this
LDFLAGS:= -L$(SDK_DIR)/lib -L$(SDK_DIR)/ld $(LDFLAGS)

hope this will help
_______________________________
I've customized my own project structure starting from espressif and nodemcu makefiles so that everytime I create a new project I just have to
1) clone the structure
2) run ./gen_env.sh to generate the project environment
3) run . env.sh to setup the environment
and start to code ...
you can have a look at the empty structure here: https://github.com/quackmore/esp8266_SDK_structure