-->
Page 1 of 7

C++

PostPosted: Mon Nov 03, 2014 11:02 am
by karcheng
Hi all,

Can someone give me some hints on how to compile c++ code for this device please? Is C++ compiler included in the GCC toolchain for the lx106 core?

Thanks in advance,
Kar

Re: C++

PostPosted: Mon Nov 03, 2014 1:31 pm
by jcmvbkbc
Hi,

Normally g++ should be accompanied by its standard library, libstdc++, and building that requires libc.
I've put together draft newlib port for xtensa here: https://github.com/jcmvbkbc/newlib-xten ... its/xtensa
I've also added those patches to the crosstool-NG and enabled newlib and g++ in lx106 configuration,
in the lx106-g++ branch here: https://github.com/jcmvbkbc/crosstool-N ... 06-g%2B%2B

With these modifications g++ and target libstdc++ can be built, but that's all I currently know about it (:
If you want to give it a try -- please go ahead and let us know of any issues you encounter.

The compiler bootstrapping steps are almost the same as described in https://github.com/esp8266/esp8266-wiki/wiki/Toolchain
the only difference is that you need to check out another branch: git clone -b lx106-g++ git://github.com/jcmvbkbc/crosstool-NG.git

Re: C++

PostPosted: Mon Nov 03, 2014 3:55 pm
by karcheng
thanks, I will test it and let you know.

Re: C++

PostPosted: Tue Nov 04, 2014 7:07 pm
by karcheng
Unable to find headers when I compile

#include <iostream>

#include "ets_sys.h"
#include "osapi.h"
#include "gpio.h"
#include "os_type.h"

extern "C" void ICACHE_FLASH_ATTR user_init();

void ICACHE_FLASH_ATTR
user_init()
{
// std::cout << "Hello World!" << std::endl;
//os_printf("In User_init()\n");
//return 0;
}

--------------------------------
/opt/Espressif/xtensa-lx106-elf/bin/xtensa-lx106-elf-g++ -I/opt/Espressif/xtensa-lx106-elf/xtensa-lx106-elf/include/c++/4.8.2 -Idriver -Iuser -I/opt/Espressif/esp_iot_sdk/include -I/opt/Espressif/esp_iot_sdk/include/json -c -g -Wall -c user/user_main.cpp -o build/user/user_main.o
In file included from /opt/Espressif/xtensa-lx106-elf/xtensa-lx106-elf/include/c++/4.8.2/bits/postypes.h:40:0,
from /opt/Espressif/xtensa-lx106-elf/xtensa-lx106-elf/include/c++/4.8.2/iosfwd:40,
from /opt/Espressif/xtensa-lx106-elf/xtensa-lx106-elf/include/c++/4.8.2/ios:38,
from /opt/Espressif/xtensa-lx106-elf/xtensa-lx106-elf/include/c++/4.8.2/ostream:38,
from /opt/Espressif/xtensa-lx106-elf/xtensa-lx106-elf/include/c++/4.8.2/iostream:39,
from user/user_main.cpp:1:
/opt/Espressif/xtensa-lx106-elf/xtensa-lx106-elf/include/c++/4.8.2/cwchar:142:11: error: '::fgetwc' has not been declared
using ::fgetwc;
^
/opt/Espressif/xtensa-lx106-elf/xtensa-lx106-elf/include/c++/4.8.2/cwchar:143:11: error: '::fgetws' has not been declared
using ::fgetws;
... etc