I am new to CubeIDE and have created a c++ project. I had the system generate the code and renamed main.c to main.cpp. I then put a #include <string> in the main and I get a fatal error during the build: "string: no such file or directory."
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-02-23 6:56 PM
This is running on Linux and I created a test program with the same include and compiled it with g++ without issue.
I think I need to tell CudeIDE where the standard libraries are located? If that is so, Where do I find them?
Thanks!!
Solved! Go to Solution.
- Labels:
-
STM32CubeIDE
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-02-23 9:47 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-02-23 9:47 PM
#include <string.h>
JW
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-02-24 6:57 AM
CubeIDE uses GCC under the hood. Show the full error message. Perhaps you're not in a C++ source file. How are you creating the project?
<string> is the correct library. Or rather, it is a C++ library which is separate from the C library string.h.
https://www.cplusplus.com/reference/string/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-02-24 9:48 AM
The project was created with the language of C++ in CubeIDE.
Here is the complete dump of the errors that occur during the build. Only the first two are interesting. I have corrected the warnings.
Description Resource Path Location Type
fatal error: string: No such file or directory main.cpp /Slave-SPI/Application/User/Core line 31 C/C++ Problem
make: *** [Application/User/Core/subdir.mk:55: Application/User/Core/main.o] Error 1 Slave-SPI C/C++ Problem
comparison of integer expressions of different signedness: 'int' and 'unsigned int' [-Wsign-compare] main.cpp /STM32-SPI-Slave/Core/Src line 209 C/C++ Problem
ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings] main.cpp /STM32-SPI-Slave/Core/Src line 161 C/C++ Problem
ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings] main.cpp /STM32-SPI-Slave/Core/Src line 202 C/C++ Problem
ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings] main.cpp /STM32-SPI-Slave/Core/Src line 226 C/C++ Problem
ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings] main.cpp /STM32-SPI-Slave/Core/Src line 232 C/C++ Problem
ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings] main.cpp /STM32-SPI-Slave/Core/Src line 238 C/C++ Problem
ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings] main.cpp /STM32-SPI-Slave/Core/Src line 244 C/C++ Problem
ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings] main.cpp /STM32-SPI-Slave/Core/Src line 250 C/C++ Problem
ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings] main.cpp /STM32-SPI-Slave/Core/Src line 256 C/C++ Problem
ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings] main.cpp /STM32-SPI-Slave/Core/Src line 273 C/C++ Problem
ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings] main.cpp /STM32-SPI-Slave/Core/Src line 339 C/C++ Problem
ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings] main.cpp /STM32-SPI-Slave/Core/Src line 350 C/C++ Problem
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-02-24 10:12 AM
Thank you sir! That did the trick. Why do I need the .h? When I write C++ outside this environment and compile it with g++ I don't need the .h on the includes.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-02-24 10:30 AM
Question: Why does #include <string> require me to add the .h but #include <cstdio> chokes if I add the .h?
