Skip to main content
parth kothiya
Associate III
Jan 5, 2019 11:28 AM UTC
Solved

How to convert C code to C++ in True Studio?

file-> new-> convert C/C++ nature then build it gives error main.h no such fie or directory

This topic has been closed for replies.
Markus GIRDLAND
Markus GIRDLANDBest answer
ST Employee
Jan 7, 2019 1:49 PM UTC

There's a risk that you get a lot of errors after converting a project to c++. The first is, as you mentioned, that you need a main.cpp file. Also, I gave this explanation in another thread:

Includes and Symbols are not copied from C to C++ compiler automatically, it will require manual work.

Easiest way of doing this is by going here:

C/C++ Build > Settings > Tool Settings > C Compiler > Symbols.

Copy all lines to the corresponding C++ Compiler > Symbols.

Do the same batch copy for the Include paths.

4 replies

S.Ma
Principal
Jan 6, 2019 7:47 AM UTC

Generally speaking, when a file exist and it can't be found by the compiler or tool means the search path in the project setting is incomplete. Most of the time, the location of the project file is the default "." current directory,

parth kothiya
Associate III
Jan 6, 2019 2:46 PM UTC

as per your answer after converting in code to C++ in file path i need to change

main.c to main.cpp

location of my project file is default

Markus GIRDLAND
Markus GIRDLANDBest answer
ST Employee
Jan 7, 2019 1:49 PM UTC

There's a risk that you get a lot of errors after converting a project to c++. The first is, as you mentioned, that you need a main.cpp file. Also, I gave this explanation in another thread:

Includes and Symbols are not copied from C to C++ compiler automatically, it will require manual work.

Easiest way of doing this is by going here:

C/C++ Build > Settings > Tool Settings > C Compiler > Symbols.

Copy all lines to the corresponding C++ Compiler > Symbols.

Do the same batch copy for the Include paths.

parth kothiya
Associate III
Jan 10, 2019 3:27 AM UTC

Thanks Markus for your support..

i had include all symbols and includes as you said above but still true studio not finding some header files ,files already present in directory i'm using software v9.0.0 hope it is fixed in v9.2.0