Compile with c++11 in modus toolbox

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
echonng
Employee
Employee
5 questions asked 25 sign-ins First solution authored

hi, i am new to modus toolbox. How can i  do the setting to compile my code in c++11 ? Does modus toolbox support it?

0 Likes
1 Solution
AlenAn14
Moderator
Moderator
Moderator
500 replies posted 100 solutions authored 250 replies posted

Hi @echonng ,

I tried this setting in CXXFLAGS = -std=c++11 in ModusToolbox and tried the #include <vector> in main.cpp and the same build for me without any errors .
I am using
ModusToolbox 2.4 which uses GCC version 10.3 by default, hence it supports c++ standards 11, 14 and 17 and you can specify the same in CXXFLAGS macro to use.

Can you please let me know which version of ModusToolbox you are using?

Also, if possible, can you please share your project as a zip file here so I can test the same on my side?

Warm Regards
Alen

 

View solution in original post

0 Likes
7 Replies
AlenAn14
Moderator
Moderator
Moderator
500 replies posted 100 solutions authored 250 replies posted

Hi @echonng ,

You can create a c++ project in ModusToolbox .
Can you try following the solution in this thread to do the same.

Let me know if you face any difficulty in the same.

Warm Regards
Alen

0 Likes
echonng
Employee
Employee
5 questions asked 25 sign-ins First solution authored

hi, i am still not able to compile the codes.. it shows me error message below:

fatal error: vector: No such file or directory
26 | #include <vector>

The codes need to be compiled in c++ 11...

1) i have included in the makefile. but still have error above..

CXXFLAGS += -std=c++11                         # Use C++11 standard

2) How to check if the modus toolbox compiler supports c++ 11 ?

3) Any alternative IDE for PSOC which supports c++ 11 ?

 

0 Likes
AlenAn14
Moderator
Moderator
Moderator
500 replies posted 100 solutions authored 250 replies posted

Hi @echonng ,

I tried this setting in CXXFLAGS = -std=c++11 in ModusToolbox and tried the #include <vector> in main.cpp and the same build for me without any errors .
I am using
ModusToolbox 2.4 which uses GCC version 10.3 by default, hence it supports c++ standards 11, 14 and 17 and you can specify the same in CXXFLAGS macro to use.

Can you please let me know which version of ModusToolbox you are using?

Also, if possible, can you please share your project as a zip file here so I can test the same on my side?

Warm Regards
Alen

 

0 Likes
echonng
Employee
Employee
5 questions asked 25 sign-ins First solution authored

hi Alen,

Thanks for the confirmation. I am currently using ModusToolbox 2.4. 

I found the issue of the compiler not locating the vector file happens when the e.g  #include <vector> declared/used in the  .hpp file (C++ header file). It's not an issue if #include <vector> is used in .cpp.

Is there a quick fix to this ?

 

0 Likes
AlenAn14
Moderator
Moderator
Moderator
500 replies posted 100 solutions authored 250 replies posted

Hi @echonng ,

I tried creating the .hpp header file as you mentioned and it's building successfully for me.

AlenAn14_0-1644406415982.png

The main.hpp is included in the main.cpp file.

Can you please let me know if you are doing anything else different or share your project with me if you are still facing this issue so I can check it out on my side?

Warm Regards
Alen

0 Likes
echonng
Employee
Employee
5 questions asked 25 sign-ins First solution authored

hi Alen,

Thanks for the verification. I re-installed the modustoolbox.

I've managed to get the codes compiled now.

Thanks for your support!

 

0 Likes
AlenAn14
Moderator
Moderator
Moderator
500 replies posted 100 solutions authored 250 replies posted

Hi @echonng ,

Glad your query is resolved.
Please feel free to post any queries or issues you may have on Infineon products in the community and we will be happy to help.

Warm Regards
Alen

 

0 Likes