cancel
Showing results for 
Search instead for 
Did you mean: 

stmcubemx convert c to c++

johannes_hellbeck
Associate II
Posted on May 05, 2017 at 20:10

Hello,

When I compile STM32CubeMX generated C file with my IDE ( OpenSTM32 last version)

to

C is ever think ok.

In the Project Explorer I convert to c++.

But when I change main.c

to main.cpp I get an error message “make: ***

http://www.openstm32.org/Drivers/Hans.o

Error 258�?.

Is there a solution available?

Thanks Johannes
  • OS windows 10

    Version: Mars.2 Release (4.5.2)

    STM32L432KU

    STM32Cube V1.0 Version 4.20.#
15 REPLIES 15
Imen.D
ST Employee
Posted on May 08, 2017 at 16:17

Hi,

Please share your .ioc file and 

I will report this issue internally for checking.

 

Thanks

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
AvaTar
Lead
Posted on May 09, 2017 at 08:38

It would be new to me that Cube supports C++.

In the Project Explorer I convert to c++.

But when I change main.c to main.cpp

I get an error message “make: ***

/external-link.jspa?url=http%3A%2F%2Fwww.openstmorg%2FDrivers%2FHans.o

Error 258�?

Because it is not that easy.

C++ requires a different startup file, a different linker, and has it's own strategy of naming functions ('name mangling').

Thus your linker trouble.

johannes_hellbeck
Associate II
Posted on May 09, 2017 at 14:12

Sorry for my poor description,

I use the openstm32 workbench (IDE).

For my MCU (STM32 L432KU) configuration I use the STMcube (very powerful tool!)

I know that stm32 cube only generate C files, but I use the import function of the IDE.

Convert the file to C++ and rename the main.c to main.cc.

Then the error occurs:

“make: ***

/external-link.jspa?url=http%3A%2F%2Fwww.openstmorg%2FDrivers%2FHans.o

Error 258�?.

Is that a problem from stcube or openstm32 workbench, or is it my

fault?

Thanks Johannes

Posted on May 09, 2017 at 15:45

Then the error occurs:

“make: ***

/external-link.jspa?url=http%3A%2F%2Fwww.openstmorg%2FDrivers%2FHans.o

Error 258�?.

Can you describe/post the actual error message here ?

At least for me, the link does not help. I see no additional information.

AFAIK, openstm32 is Eclipse-based, and thus should give you a full build log.

johannes_hellbeck
Associate II
Posted on May 09, 2017 at 19:41

I bet on

https://en.wikipedia.org/wiki/Name_mangling

.

C:\Users\Papa\Desktop\workbench_test2\test_st_02\Debug/../startup/startup_stm32l432xx.s:116: undefined reference to `main'

Reading build logs & finding and identifying errors is an essential skill ...

valentin
Senior
Posted on May 10, 2017 at 06:50

Try Atollic. Conversion works a treat there. You'd only have to manually copy all includes and symbols etc over from the C compiler settings. That's easy though as it directly support ctrl+c/v.

Posted on May 10, 2017 at 09:31

Adding '

extern 'C'

' to declarations of functions specifically referenced externally would help as well.

One should know what he does before assigning the extension of another programming language to a source file.

johannes_hellbeck
Associate II
Posted on May 10, 2017 at 12:24

Thanks, I'll try it out.

But I’m surprised, that`s not work a little bit “easier� . To make the base configuration for timer , I2c, etc. with stmcube and work further with Atollic or another IDE in c++ must be the �normal� way….

I think , that will be a good thing  ST, Atollic/AC6 work here together and look for a solution…