0

NB, C++ beginner here, but I have reasonable experience coding in other languages (and significantly less sophisticated development environments).

I am working in visual studio using visual micro to work on an arduino project. The details of the project are not important, as, at this point, I am encountering the error in a completely empty .ino/.cpp file:

fatal error: string: No such file or directory #include <string>
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ^~~~~~~~ compilation terminated

An error was encountered during the 'Deep Search' library discovery process. Build failed for project 'CylinderPrinter'

#include <string>

// the setup function runs once when you press reset or power the board
void setup() {
    string h = "";
}

// the loop function runs over and over again until power down or reset
void loop() {
  
}

I have tried a number of things so far, as this seems to be a somewhat common error:

  1. Most permutations of: #include "string"; #include "string.h"; #include ; #include ; #include <string.h>; using namespace std (which is apparently bad practice); etc.
  2. Including both the "string" and "string.h" dependencies within my project, rather than referencing them as external dependencies (in this case, the compiler marks 'string is undefined in this scope')
  3. Calling string as std::string to avoid namespace issues (compiler states 'string is not a member of std')
  4. Altering the target paths in the compiler window (admittedly I have no idea what I am doing here, so I could probably use some advice...)
  5. Reinstalling the Visual C++ redistributable (I have tried x86 and x64...)
  6. Restarting my code in a new project
  7. Restarting my code in the arduino development environment (same error, which I imagine suggests a systemic problem).

As far as I can tell, I have made no meaningful progress. Here are some additional screenshots that could possibly be helpful:

Please let me know if there's additional information that could prove helpful.

... . . . ...

1

1 Answer 1

1

so, the standard library is provided by the compiler. For the most popular ones, like gcc, clang, or msvc, the provided library is 99% standard compliant. But some micro controller compilers might not have STL support. Check the Arduino STL support for your compiler. And as far as I know, there's an official Arduino IDE, try using that

Sign up to request clarification or add additional context in comments.

11 Comments

Hmm, I did try the Arduino IDE, same problem there.
then check for the STL support on the official site. But as far as i know, Arduino IDE has a c++11 compiler.
So if I understand correctly, arduino does not support STL. I believe that I have pulled my visual studio compiler down to a c++11 standard now, and I am still encountering the same problem.
if you would try implementing ur own string class, then you should see this generic container guide for c++ this would help you making an efficient string class a lot
and this is a guide to move semantics, might also be useful
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.