Skip to main content
Associate
October 23, 2023
Question

Cubeide standard c++ library

  • October 23, 2023
  • 7 replies
  • 4869 views

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.

    This topic has been closed for replies.

    7 replies

    TDK
    October 23, 2023

    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""."
    SofiaAuthor
    Associate
    October 23, 2023

    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
    October 23, 2023

    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""."
    SofiaAuthor
    Associate
    October 24, 2023

    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
    Super User
    October 24, 2023

    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>

     

    SofiaAuthor
    Associate
    October 28, 2023

    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
    October 31, 2023

    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