cancel
Showing results for 
Search instead for 
Did you mean: 

Cubeide standard c++ library

Sofia
Associate II

Hi everyone

I have a problem with cubeide 

I developed my project on visual studio and insert vector library in my project know when i want compile with cubeide the error is "no such file or directory".how can i fix this problem.

Also i create c++ project in cubeide.

7 REPLIES 7
TDK
Guru

Locate the file it's looking for and ensure it's in the project path by moving it or adding its path to the project include directories.

If you feel a post has answered your question, please click "Accept as Solution".
Sofia
Associate II

That file is from the Visual Studio libraries and I think it is part of the standard C++ libraries. include <vector> Whatever I searched on the internet, I could not find it. If you have the library, please send it to me.

 

TDK
Guru

Sounds like you might be trying to include <vector> within a .c file, which isn't going to work. vectors are a C++ thing.

Perhaps show the full error message, or a screenshot. Hard to troubleshoot when you're only being given fragments of info.

 

If you feel a post has answered your question, please click "Accept as Solution".
Sofia
Associate II

Capture.PNG

Capture1.PNG

  

I have put two pictures, one of which I am trying to include the vector library, the error is obvious, and the other one, without including the library, I directly called its functions in the program, but it still gave an error.

thanks for regarding dear

Bob S
Principal

Back to what @TDK said - your main source file is "main.c" (based on the messages in the 2nd image).  It must be .cpp in order to use C++ classes.  Move your C++ code into a separate .cpp file, then call that function from main().  Some people try renaming "main.c" to "main.cpp" - that is OK if you never want to re-generate your code from CubeMX.  But I recommend against it if you ever think you will run CubeMX again on this project.

The function in your .cpp file will need to be declared as 'extern "C"' in order to be called from main.c.

Also, you have:

#include "vector.h"

that should be:

#include <vector>

 

Sofia
Associate II

thank you for your help dear, my problem is solved. but now i have another problem that when i call varient library and want to define it , it give me an error that 

error: 'variant' is not a member of 'std'

please pay attention to the attached file.

Capture.PNG

thanks for regarding


 

Rim LANDOLSI
ST Employee

Hello @Sofia ,

 

The variant member of std is only available from C++17. So, under Properties -> C/C++ Build -> MCU G++ Compiler -> General , try to change the language standards to GNU++17 then rebuild the index.

I hope this helps !

Thanks,

Rim