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

User avatar
By mog
#6609 Great thanks for your responses.

@alonewolfx2
I wonder one thing. Why you are using iostream class? For filesystem or anything else?


I've added it just to see what happens when you print to sdt::cout. In any case there's the same problem with <vector> include


@igrr

pparently the makefile you are using compiles .c files as C code, and you obviously want C++ if you use vector and iostream.


That's a good point which I didn't think of before. The thing is that i don't have g++ installed with the SDK for some reason. In /opt/Espressif/crosstool-NG/builds/xtensa-lx106-elf/bin I've got xtensa-lx106-elf-cc which points to xtensa-lx106-elf-gcc and xtensa-lx106-elf-gcc-4.8.2. No g++ and I can't find instructions on https://github.com/esp8266/esp8266-wiki/wiki/Toolchain on setting it up. How did you obtain a copy of xtensa-lx106-elf-g++?

@jcmvbkbc

Thank you for linking this makefile. I've tried tweaking which was quite easy but the results are quite the same. One thing which happened after changing the file extension to .cpp and trying to build with...
Code: Select allCXX      := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-gcc

... which i have existing in the /opt/Espressif/crosstool-NG/builds/xtensa-lx106-elf/bin but it fails with a different error:

Code: Select allxtensa-lx106-elf-gcc: error: user/user_main.cpp: C++ compiler not installed on this system


Which is not exactly true since I've got g++ under /usr/bin/g++. After reading your and @igrr replies it seems obvious to me that I'm missing a modified g++ compiler for ESP8266 but I'm not sure what exactly I should do to get it?
User avatar
By igrr
#6610
mog wrote:No g++ and I can't find instructions on https://github.com/esp8266/esp8266-wiki/wiki/Toolchain on setting it up. How did you obtain a copy of xtensa-lx106-elf-g++?

Follow the instructions for setting up the toolchain, but use lx106-g++ branch instead of lx106 when cloning crosstool-NG:
Code: Select allgit clone -b lx106-g++ git://github.com/jcmvbkbc/crosstool-NG.git
User avatar
By mog
#6636 @igrr

Awesome. Thank you! I didn't think that It'd just be in a different branch :)
I did set up the g++ and the code compiiled without a problem! Now it seems that I there's a problem with linking against with libmain.a since the linker fails starting with:

Code: Select all/opt/Espressif/ESP8266_SDK/lib/libmain.a(app_main.o): In function `read_macaddr_from_otp':
(.irom0.text+0x7c): undefined reference to `wDev_ProcessFiq'
/opt/Espressif/ESP8266_SDK/lib/libmain.a(app_main.o): In function `read_macaddr_from_otp':
(.irom0.text+0x84): undefined reference to `lmacInit'


Which seem like a quite critical functions. Do you know if I should look for a different libmain or just try to figure out what other libraries I need to link?

hreintke

I'm using linux mint in a VM to keep it all 1:1 with the toolchain setup.