-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
libxx "C++ Example using CMake" guide "No thread API" error #5530
Comments
Small update on this error: /path/to/hellocpp/nuttx-export-10.1.0/include/libcxx/__config:1142:6: error: #error "No thread API"
1142 | # error "No thread API"
| ^~~~~ It is caused because there is no definition of For the purpostes of getting rid of it, I have hardcoded the definition in the HelloWord.h of said guide. But I am quite sure this is not how it is supposed to be done. So, if anyone has any input, specially considering updating the guide, it'd be highly appreciated. |
Now to the next error: In file included from /path/to/hellocpp/nuttx-export-10.2.0/include/libcxx/cstddef:44,
from /path/to/hellocpp/nuttx-export-10.2.0/include/libcxx/initializer_list:46,
from /path/to/hellocpp/nuttx-export-10.2.0/include/libcxx/algorithm:649,
from /path/to/hellocpp/nuttx-export-10.2.0/include/libcxx/__string:57,
from /path/to/hellocpp/nuttx-export-10.2.0/include/libcxx/string_view:179,
from /path/to/hellocpp/nuttx-export-10.2.0/include/libcxx/string:511,
from /path/to/hellocpp/src/HelloWorld.cpp:4:
/usr/lib/gcc/arm-none-eabi/9.2.1/include/stddef.h:426:3: error: conflicting declaration 'typedef struct max_align_t max_align_t'
426 | } max_align_t;
| ^~~~~~~~~~~
In file included from /path/to/hellocpp/nuttx-export-10.2.0/include/string.h:30,
from /path/to/hellocpp/nuttx-export-10.2.0/include/strings.h:30,
from /path/to/hellocpp/nuttx-export-10.2.0/include/sched.h:33,
from /path/to/hellocpp/nuttx-export-10.2.0/include/nuttx/sched.h:33,
from /path/to/hellocpp/nuttx-export-10.2.0/include/stdio.h:35,
from /path/to/hellocpp/nuttx-export-10.2.0/include/libcxx/cstdio:99,
from /path/to/hellocpp/src/HelloWorld.cpp:3:
/path/to/hellocpp/nuttx-export-10.2.0/include/stddef.h:83:3: note: previous declaration as 'typedef struct max_align_t max_align_t'
83 | } max_align_t;
| ^~~~~~~~~~~ The // Don't include our own <stddef.h>; we don't want to declare ::nullptr_t.
#include_next <stddef.h>
#include <__nullptr> The Onto the next.... make
Scanning dependencies of target hellocpp
[ 33%] Building CXX object src/CMakeFiles/hellocpp.dir/HelloWorld.cpp.obj
[ 66%] Building CXX object src/CMakeFiles/hellocpp.dir/main.cpp.obj
[100%] Linking CXX executable hellocpp
/usr/bin/arm-none-eabi-ld: cannot find -lsupc++
make[2]: *** [src/CMakeFiles/hellocpp.dir/build.make:99: src/hellocpp] Error 1
make[1]: *** [CMakeFiles/Makefile2:94: src/CMakeFiles/hellocpp.dir/all] Error 2
make: *** [Makefile:84: all] Error 2 |
I've made some changes based at what you mentioned and the discussion at the link. First I added the #define NuttX at the CMakeLists.txt here: This solves the question about error: #error "No thread API". After this, I had an error about the lsupc++ lib. Looking at NuttX repository for this lib, I found out there is a config LIBSUPCXX to enable this lib. So I enabled this config using: With this config enabled I ran: Following the steps mentioned at the example guide, new error appeared: I don't know why hellocpp.elf is generated inside src folder, but after copying from src to build folder I have the following result:
The final result at build folder:
|
Thanks @flavioipiranga for your help! About the .elf file, changing line 16 from /src/CMaleLists.txt saves you from having to copy the file. The updated line that fixed it for me was:
And, likewise, here changing from "LLVM low level C++ Library" to "GNU low level libsupc++" does compile. I personally wanted to use LLVM, but that is my issue, not an issue with the guide. |
If we are talking about an example. In the "hellocpp/CMakeLists.txt" try to change the order of paths for including from:
to
It should work like this. |
kind of off-topic. But how do you guys flash |
pyocd might be better |
how do you do it? |
i have fixed the build |
I think it might be interesting for you guys as well. Check out the following PR #10398. It automatically generates a cmake toolchainfile that you can use to build cpp applications. It would be great if we have different projects/people that test it that way we can modify it to make it as generic as possible. |
I am new to NuttX and I have been trying to use the "C++ Example using CMake" guide available in the official documentation. No changes whatsoever to code. That is:
cd nuttx ./tools/configure.sh stm32f4discovery:testlibcxx
Set RTOS Features -> Tasks and Scheduling -> Application entry point to ‘hellocpp_main’
make export
And in the hellocpp/ main folder:
mkdir build cd build cmake .. make
I have tested Nuttx 10.0.1, 10.1.0 and 10.2.0. The first one does not export. The other two appear to be OK while doing
cmake ..
(edited just folder names due to NDAs):However,
make
ends in the same error for both :I have found this link as a person that had a similar problem, but I could not pinpoint in the discussion what should I do to make it work. I also understood that #1592 should have fixed the issue. What am I missing?
The text was updated successfully, but these errors were encountered: