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

User avatar
By Pawel Ka
#12023 Thx, it's work. I haven't run global constructors manually. That was my problem ;-)
User avatar
By krimpsok
#12512 I noticed that os_delay_us is not working on the C++ compiler

Code: Select allDescription   Resource   Path   Location   Type
'ets_delay_us' was not declared in this scope   RemoteTransmitter.cpp   /Switcher/user   line 96   C/C++ Problem
'ets_delay_us' was not declared in this scope   RemoteTransmitter.cpp   /Switcher/user   line 155   C/C++ Problem
mingw32-make.exe: *** [build/user/RemoteTransmitter.o] Error 1   Switcher          C/C++ Problem
recipe for target 'build/user/RemoteTransmitter.o' failed   Makefile   /Switcher   line 322   C/C++ Problem


When compiling with the C compiler everything is fine.
User avatar
By Alex_S
#12534 Unfortunately not all the function prototypes are declared in SDKs headers. C allows to compile without such declarations, assuming int(int), but C++ requires prompt delcarations.
So just add the declarations of the used SDK functions and it will be compiled and linked correctly.
Note: don't forget 'extern "C"' for this declarations.
User avatar
By krimpsok
#12564 I used extern "C" to declare my missing ets_delay_us(int us) but now I'm getting a weird error on multiple lines.

Code: Select allDescription   Resource   Path   Location   Type
mingw32-make.exe: *** [build/app.out] Error 1   Switcher          C/C++ Problem
more undefined references to `gpio_output_set(unsigned int, unsigned int, unsigned int, unsigned int)' follow   RemoteTransmitter.cpp   /Switcher/user   line 98   C/C++ Problem
recipe for target 'build/app.out' failed   Makefile   /Switcher   line 219   C/C++ Problem
undefined reference to `gpio_output_set(unsigned int, unsigned int, unsigned int, unsigned int)'   RemoteTransmitter.cpp   /Switcher/user   line 54   C/C++ Problem
undefined reference to `gpio_output_set(unsigned int, unsigned int, unsigned int, unsigned int)'   RemoteTransmitter.cpp   /Switcher/user   line 86   C/C++ Problem
undefined reference to `gpio_output_set(unsigned int, unsigned int, unsigned int, unsigned int)'   RemoteTransmitter.cpp   /Switcher/user   line 87   C/C++ Problem
undefined reference to `gpio_output_set(unsigned int, unsigned int, unsigned int, unsigned int)'   RemoteTransmitter.cpp   /Switcher/user   line 90   C/C++ Problem
undefined reference to `gpio_output_set(unsigned int, unsigned int, unsigned int, unsigned int)'   RemoteTransmitter.cpp   /Switcher/user   line 107   C/C++ Problem


The weird part about this error is that gpio_output_set IS defined in gpio.h which I include. I'll post a pastebin link to the code I've been working on so far. http://pastebin.com/xKmDRxRZ. It's an Arduino library which I'm converting for use with the ESP8266.

EDIT::
I fixed my problem by including the gpio.h via the extern "C" method.