Skip to main content
johannes_hellbeck
Associate
May 5, 2017 6:10 PM UTC
Question

stmcubemx convert c to c++

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.#
    This topic has been closed for replies.

    15 replies

    ST Technical Moderator
    May 8, 2017 2:17 PM UTC
    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

    In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Thanks
    AvaTar
    Senior III
    May 9, 2017 6:38 AM UTC
    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
    May 9, 2017 12:12 PM UTC
    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

    AvaTar
    Senior III
    May 9, 2017 3:45 PM UTC
    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
    May 9, 2017 5:30 PM UTC
    AvaTar
    Senior III
    May 9, 2017 7:41 PM UTC
    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
    Associate III
    May 10, 2017 4:50 AM UTC
    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.

    AvaTar
    Senior III
    May 10, 2017 9:31 AM UTC
    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
    May 10, 2017 10:24 AM UTC
    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…

    AvaTar
    Senior III
    May 10, 2017 2:21 PM UTC
    Posted on May 10, 2017 at 14:21

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

    The best solution would be if Cube supported C++ out of the box.

    Everything else would be just a workaround.

    Jeanne Joly
    Associate
    Jan 18, 2018 2:31 PM UTC
    Posted on January 18, 2018 at 15:31

    Hi all,

    For your information, we do understand the need for you to generate C++ project and this need is well known internally.

    However, for the moment, with the success of STM32CubeMX, we have a lot of requests/suggestions to study and many improvements to integrate.

    And the C++ generation project item is not yet under study currently.

    Sorry, for the inconvenience it may cause.

    BR. Jeanne