Programming in C++

rosimildo
Posts: 13
Joined: Fri Nov 11, 2016 7:20 pm

Re: Programming in C++

Postby rosimildo » Fri Dec 09, 2016 12:39 am

If I use any std C++ stuff, and I include "stdc++ library, I get this link error:

/opt/esp32/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/4.8.5/../../../../xtensa-esp32-elf/lib/libstdc++.a(vterminate.o):(.literal._ZN9__gnu_cxx27__verbose_terminate_handlerEv+0x8): undefined reference to `_impure_ptr'
collect2: error: ld returned 1 exit status

Does anyone knows how to solve it ?

If I remove the references to "std::string" for example and don't link "stdc++", the program links fine.

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: Programming in C++

Postby kolban » Thu Jan 12, 2017 11:19 pm

bump ... I just ran into the exact same issue.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: Programming in C++

Postby WiFive » Thu Jan 12, 2017 11:26 pm


User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: Programming in C++

Postby kolban » Sun Mar 05, 2017 4:39 pm

Earlier in this thread there was a discussion on the naming conflicts in a C++ application if we try and create methods with the same names as LWIP #defines. For example, if I try and create a method called "connect" or "close" or "send" we fail because those appear to be #defined against the lwip functions. Has anyone found a workaround? Espressif commented back in November that they had an idea as to a way to fix but didn't elaborate on it.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

Beck-Sisyphus
Posts: 14
Joined: Sun Jan 03, 2016 12:15 am

Re: Programming in C++

Postby Beck-Sisyphus » Sun May 14, 2017 1:17 pm

Hi ESP_igrr and kolban,

May I know the current process to support C++11 thread/concurrency library?

I wish to perform matrix operations in ESP32, and C++"Eigen.h" library would be a good fit. Eigen does depends on a C library called LAPACK, but I failed to link the library to my program, and LAPACK wasn't friendly for starters. Does looking forward for a guide to setup the Makefile to compile C++ library in the main project.


Best,

Beck

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: Programming in C++

Postby kolban » Sun May 14, 2017 3:35 pm

While the C++ standard library does provide a "threading model" ... see for example:

http://www.cplusplus.com/reference/thread/thread/

To the best of my knowledge this has not been mapped in the ESP-IDF to the FreeRTOS "task" model. Thus if you have pre-existing (non ESP32 originated code) that leverages the "std::thread" class, it won't work (opinion). In theory, it would be possible to map the C++ threading packages to FreeRTOS but I have no knowledge of whether that is a task to be attempted.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

ESP_igrr
Posts: 2072
Joined: Tue Dec 01, 2015 8:37 am

Re: Programming in C++

Postby ESP_igrr » Mon May 15, 2017 11:10 am

Mapping STL concurrency library to FreeRTOS is possible, and has been done in some other MCU programming environments, but we don't have this feature planned at the moment.

gigijoe
Posts: 21
Joined: Wed Aug 02, 2017 10:16 am

Re: Programming in C++

Postby gigijoe » Fri Aug 04, 2017 10:25 am

Hello

I rename the main.c to main.cpp but the compiler just want main.c ...

$ make
CC main.o
xtensa-esp32-elf-gcc: error: /home/gigijoe/ESP32/SGM9200/main/./main.c: No such file or directory
xtensa-esp32-elf-gcc: fatal error: no input files
compilation terminated.

I'm running with latest SDK, any one have idea ?

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: Programming in C++

Postby kolban » Mon Aug 07, 2017 4:57 am

I have sometimes seen that if one renames a source from X.c to X.cpp but has not issued a "make clean" then the build system seems to somehow "remember" that source was once "X.c". Can you try a "make clean" and then a full re-build and see if that helps?
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

gigijoe
Posts: 21
Joined: Wed Aug 02, 2017 10:16 am

Re: Programming in C++

Postby gigijoe » Mon Aug 07, 2017 11:19 am

Hello kolban

Yes, make clean works

Now the build system compile main.cpp

Thank you

Who is online

Users browsing this forum: Bing [Bot] and 332 guests