Migrate from C to C++ project in MCUXpresso Ide

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Migrate from C to C++ project in MCUXpresso Ide

3,848 Views
dillibabug
Contributor I

Dear NXP,

We have project based on IMXRT1050 processor, existing project is based on the C now we want to migrated to C++, for that I have change the library based on the NXP document, then I added some C++ code to it, finally I got error  while compilation, here I attached that document, still I could not fix the compilation error.

kindly let me know how to add C++ toolchain to existing c project.

Thanks and Regards,

0 Kudos
Reply
8 Replies

3,656 Views
converse
Senior Contributor V

How about telling us what the compilation error is? There could be all sorts of issues and without knowing what the problem you are having, nobody can help you!

0 Kudos
Reply

3,656 Views
dillibabug
Contributor I

Dear Con Verse,

Could you tell me the procedure in Mcuxpresso, how to migrate existing c project to cpp project. I am using 10.3.1 version IDE.

Thanks and Regards,

0 Kudos
Reply

3,656 Views
converse
Senior Contributor V

BTW: Have you converted to a C++ project?

File->New->Other...

C/C++

Convert to a C/C++ Project (Adds C/C++Nature)

Next

Finish

This will allow access to both the C and the C++ compilers. To compile with C++ compiler, you file needs a .cpp file extension

0 Kudos
Reply

3,656 Views
dillibabug
Contributor I

Hi,

I got the following error,

c:/nxp/mcuxpressoide_10.3.1_2233/ide/plugins/com.nxp.mcuxpresso.tools.win32_10.3.0.201811011841/tools/bin/../lib/gcc/arm-none-eabi/7.3.1/../../../../arm-none-eabi/lib/thumb/v7e-m/fpv4-sp/hard\libc.a(lib_a-init.o): In function `__libc_init_array':

kindly help us to fix this to error

Thanks & Regards

0 Kudos
Reply

3,656 Views
converse
Senior Contributor V

If you use the IDE to create a new C++ project, it adds a file into your project, and this resolves the problem. I suggest that you create a dummy C++ project, and then copy the file into your project. Sorry, I can’t remember what it’s called, but it’ll be obvious! You can delete the temporary project when you’ve copied the file across

0 Kudos
Reply

3,656 Views
dillibabug
Contributor I

Dear Con Verse,

I have converted C project to C++, as you suggested in above, I can able to create and compile the CPP project, when I create the object in the main function it create error, error is following,

Finished building: ../source/freertos_sbengine.cpp
 
Building target: evkbimxrt1050_freertos_hello_freertos_sbengine.axf
Invoking: MCU C++ Linker
arm-none-eabi-c++ -nostdlib -L"C:\Users\DHANYA SHREE\Downloads\Compressed\arguep-tesla-10800b57cdb1\freertos-mcuxpresso-cortexm7-swrender-DFP-obj\plugins" -L"C:\Users\DHANYA SHREE\Downloads\Compressed\arguep-tesla-10800b57cdb1\freertos-mcuxpresso-cortexm7-swrender-DFP-obj\lib" -Xlinker -Map="evkbimxrt1050_freertos_hello_freertos_sbengine.map" -Xlinker --start-group -Xlinker --gc-sections -Xlinker -print-memory-usage -Xlinker --sort-section=alignment -mcpu=cortex-m7 -mfpu=fpv5-d16 -mfloat-abi=hard -mthumb -T MIMXRT1052xxxxx_flexspi_nor_sb_fram5.ld -L ../linker -o "evkbimxrt1050_freertos_hello_freertos_sbengine.axf"  ./xip/evkbimxrt1050_flexspi_nor_config.o ./xip/evkbimxrt1050_sdram_ini_dcd.o ./xip/fsl_flexspi_nor_boot.o  ./utilities/fsl_assert.o ./utilities/fsl_debug_console.o ./utilities/fsl_io.o ./utilities/fsl_log.o ./utilities/fsl_str.o  ./startup/startup_mimxrt1052.o  ./source/ui_event_handlers/ui_backlight.o ./source/ui_event_handlers/ui_nfc.o ./source/ui_event_handlers/ui_prox.o ./source/ui_event_handlers/ui_rvc_DB100.o ./source/ui_event_handlers/ui_rvc_DB200.o ./source/ui_event_handlers/ui_rvc_ags.o ./source/ui_event_handlers/ui_rvc_air_conditioner_heatpump.o ./source/ui_event_handlers/ui_rvc_autofill.o ./source/ui_event_handlers/ui_rvc_awning.o ./source/ui_event_handlers/ui_rvc_charger.o ./source/ui_event_handlers/ui_rvc_chassis_motion.o ./source/ui_event_handlers/ui_rvc_core.o ./source/ui_event_handlers/ui_rvc_date_time.o ./source/ui_event_handlers/ui_rvc_dc_dimmer.o ./source/ui_event_handlers/ui_rvc_dc_disconnect.o ./source/ui_event_handlers/ui_rvc_dc_load.o ./source/ui_event_handlers/ui_rvc_dc_motor.o ./source/ui_event_handlers/ui_rvc_dc_source.o ./source/ui_event_handlers/ui_rvc_furnace.o ./source/ui_event_handlers/ui_rvc_generator.o ./source/ui_event_handlers/ui_rvc_inverter.o ./source/ui_event_handlers/ui_rvc_lithionics_bms.o ./source/ui_event_handlers/ui_rvc_locks.o ./source/ui_event_handlers/ui_rvc_slideout.o ./source/ui_event_handlers/ui_rvc_tanks.o ./source/ui_event_handlers/ui_rvc_thermostat.o ./source/ui_event_handlers/ui_rvc_tm180.o ./source/ui_event_handlers/ui_rvc_tm2020.o ./source/ui_event_handlers/ui_rvc_vent_fan.o ./source/ui_event_handlers/ui_rvc_waste_dump.o ./source/ui_event_handlers/ui_rvc_water_heater.o ./source/ui_event_handlers/ui_rvc_water_pump.o ./source/ui_event_handlers/ui_rvc_window_shade.o ./source/ui_event_handlers/ui_rvc_xantrex_fxc.o ./source/ui_event_handlers/ui_sounds.o  ./source/rvc/rvc_DB100.o ./source/rvc/rvc_DB200.o ./source/rvc/rvc_ac_point.o ./source/rvc/rvc_address.o ./source/rvc/rvc_ags.o ./source/rvc/rvc_air_conditioner_heatpump.o ./source/rvc/rvc_autofill.o ./source/rvc/rvc_awning.o ./source/rvc/rvc_charger.o ./source/rvc/rvc_chassis_motion.o ./source/rvc/rvc_core.o ./source/rvc/rvc_crc16.o ./source/rvc/rvc_date_time.o ./source/rvc/rvc_dc_dimmer.o ./source/rvc/rvc_dc_disconnect.o ./source/rvc/rvc_dc_load.o ./source/rvc/rvc_dc_motor.o ./source/rvc/rvc_dc_source.o ./source/rvc/rvc_dm_rv.o ./source/rvc/rvc_furnace.o ./source/rvc/rvc_generator.o ./source/rvc/rvc_inverter.o ./source/rvc/rvc_lithionics_bms.o ./source/rvc/rvc_locks.o ./source/rvc/rvc_multipacket.o ./source/rvc/rvc_product_id.o ./source/rvc/rvc_proprietary.o ./source/rvc/rvc_request_ack.o ./source/rvc/rvc_slideout.o ./source/rvc/rvc_tanks.o ./source/rvc/rvc_tasks.o ./source/rvc/rvc_thermostat.o ./source/rvc/rvc_tm180.o ./source/rvc/rvc_tm2020.o ./source/rvc/rvc_vent_fan.o ./source/rvc/rvc_waste_dump.o ./source/rvc/rvc_water_heater.o ./source/rvc/rvc_water_pump.o ./source/rvc/rvc_window_shade.o ./source/rvc/rvc_xantrex_fxc.o  ./source/pubsub/pubsub.o  ./source/datamodel/datamodel_core.o ./source/datamodel/modelcore.o ./source/datamodel/testclass.o ./source/datamodel/water_heater.o ./source/datamodel/water_heater_factory.o  ./source/ci_bus/cib_water_heater.o  ./source/ST7796.o ./source/audio.o ./source/backlight.o ./source/bme280.o ./source/button.o ./source/flexcan.o ./source/flexio_i2s.o ./source/freertos_sbengine.o ./source/ft7401_rt.o ./source/i2c.o ./source/lcd.o ./source/log.o ./source/nfc.o ./source/prox.o ./source/rtc_date_time.o ./source/rvc_setup.o ./source/sbengine_task.o ./source/semihost_hardfault.o ./source/sensor_task.o ./source/sounds.o ./source/spi.o ./source/touch.o ./source/ui_events.o ./source/vcnl4200.o ./source/version.o ./source/watchdog.o  ./drivers/freertos/fsl_lpi2c_freertos.o ./drivers/freertos/fsl_lpspi_freertos.o  ./drivers/fsl_cache.o ./drivers/fsl_clock.o ./drivers/fsl_common.o ./drivers/fsl_dmamux.o ./drivers/fsl_edma.o ./drivers/fsl_elcdif.o ./drivers/fsl_flexcan.o ./drivers/fsl_flexio.o ./drivers/fsl_flexio_i2s.o ./drivers/fsl_flexio_i2s_edma.o ./drivers/fsl_ft5406_rt.o ./drivers/fsl_gpio.o ./drivers/fsl_lpi2c.o ./drivers/fsl_lpspi.o ./drivers/fsl_lpuart.o ./drivers/fsl_ocotp.o ./drivers/fsl_pit.o ./drivers/fsl_pwm.o ./drivers/fsl_pxp.o ./drivers/fsl_snvs_hp.o ./drivers/fsl_snvs_lp.o ./drivers/fsl_wdog.o ./drivers/fsl_xbara.o  ./board/src/board.o ./board/src/clock_config.o  ./board/fsl_flexio_i2s_peripheral.o ./board/peripherals.o ./board/pin_mux.o  ./amazon-freertos/portable/fsl_tickless_systick.o  ./amazon-freertos/logging/aws_logging_task_dynamic_buffers.o  ./amazon-freertos/FreeRTOS/portable/heap_useNewlib.o ./amazon-freertos/FreeRTOS/portable/port.o  ./amazon-freertos/FreeRTOS/event_groups.o ./amazon-freertos/FreeRTOS/list.o ./amazon-freertos/FreeRTOS/queue.o ./amazon-freertos/FreeRTOS/stream_buffer.o ./amazon-freertos/FreeRTOS/tasks.o ./amazon-freertos/FreeRTOS/timers.o  ./CMSIS/system_MIMXRT1052.o   -lgre -lgreal -lsbfreetype -lgreio -lsblua -lswrender -lsbimage -lsbvfs -lgre-plugin-animation -lgre-plugin-poly -lgre-plugin-circle -lgre-plugin-screen-path -lgre-plugin-greio -lgre-plugin-timer -lgre-plugin-logger -lrender-plugin-swrender -lgre-plugin-lua -lgre-plugin-rtext
./source/freertos_sbengine.o: In function `__static_initialization_and_destruction_0(int, int)':
c:\nxp\mcuxpressoide_10.3.1_2233\ide\plugins\com.nxp.mcuxpresso.tools.win32_10.3.0.201811011841\tools\arm-none-eabi\include\c++\7.3.1/iostream:74: undefined reference to `std::ios_base::Init::Init()'
./source/freertos_sbengine.o: In function `__static_initialization_and_destruction_0(int, int)':
C:\Users\DHANYA SHREE\Downloads\Compressed\arguep-tesla-10800b57cdb1\XIP_Debug_v1/../source/freertos_sbengine.cpp:206: undefined reference to `__dso_handle'
C:\Users\DHANYA SHREE\Downloads\Compressed\arguep-tesla-10800b57cdb1\XIP_Debug_v1/../source/freertos_sbengine.cpp:206: undefined reference to `std::ios_base::Init::~Init()'
c:/nxp/mcuxpressoide_10.3.1_2233/ide/plugins/com.nxp.mcuxpresso.tools.win32_10.3.0.201811011841/tools/bin/../lib/gcc/arm-none-eabi/7.3.1/../../../../arm-none-eabi/bin/ld.exe: evkbimxrt1050_freertos_hello_freertos_sbengine.axf: hidden symbol `__dso_handle' isn't defined
c:/nxp/mcuxpressoide_10.3.1_2233/ide/plugins/com.nxp.mcuxpresso.tools.win32_10.3.0.201811011841/tools/bin/../lib/gcc/arm-none-eabi/7.3.1/../../../../arm-none-eabi/bin/ld.exe: final link failed: Bad value
collect2.exe: error: ld returned 1 exit status
make[1]: *** [makefile:69: evkbimxrt1050_freertos_hello_freertos_sbengine.axf] Error 1
make: *** [makefile:60: all] Error 2
12:58:10 Build Finished (took 1s.904ms)

 

I think it still invoking gcc compiler instead of the g++ could you help to fix this error.

Thanks &  Regards

0 Kudos
Reply

3,655 Views
converse
Senior Contributor V

It doesn’t look like you have added the cr_cpp_config.cpp file that I said you needed in my 3rd reply above. Also, can you attach the 3 ‘ld ‘ files generated in you Debug directory?

EDIT: I've attached the cr_cpp_config.cpp file to save you having to create it yourself

0 Kudos
Reply

3,655 Views
converse
Senior Contributor V

It looks like you have found a document that helps.8 ask again, what are the errors you are getting?

0 Kudos
Reply