arm-none-eabi conflicting with mqx: multiple definitions of stdio.h and others causing compiler problems.

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

arm-none-eabi conflicting with mqx: multiple definitions of stdio.h and others causing compiler problems.

Jump to solution
5,218 Views
ironsean
Contributor V

I'm working with KDS 1.1.0 and KSDK 2.0.0, trying to port a previous project from MQX 4.1.0 and CodeWarrior 10.6. I'm using C on a Freescale FRDM-K64F board.

I followed the guide at https://community.freescale.com/message/506434 to make a new KDS project running and compiling. Then I tried to emulate the steps to add the RTCS and MFS projects. After copying over some of my own code and adding some of the library includes I need (mqx.h, lqmsgq.h, mfs.h) and then I get errors for Multiple definition of __dso_handle, _init,_fini in comp.c.

D:/Development/13214-ELMU/trunk/Freescale/KSDK_1.1.0/rtos/mqx/lib/frdmk64f.kds/debug/mqx/lib_mqx.a(comp.o): In function `_exit':

D:/Development/13214-ELMU/trunk/Freescale/KSDK_1.1.0/rtos/mqx/mqx/source/psp/cortex_m/compiler/gcc_arm/comp.c:65: multiple definition of `__dso_handle'

d:/freescale/kds_2.0.0/toolchain/bin/../lib/gcc/arm-none-eabi/4.8.0/m4/fp/v4-sp-d16/crtbegin.o:(.data.__dso_handle+0x0): first defined here

D:/Development/13214-ELMU/trunk/Freescale/KSDK_1.1.0/rtos/mqx/lib/frdmk64f.kds/debug/mqx/lib_mqx.a(comp.o): In function `toolchain_startup':

D:/Development/13214-ELMU/trunk/Freescale/KSDK_1.1.0/rtos/mqx/mqx/source/psp/cortex_m/compiler/gcc_arm/comp.c:75: multiple definition of `_init'

d:/freescale/kds_2.0.0/toolchain/bin/../lib/gcc/arm-none-eabi/4.8.0/m4/fp/v4-sp-d16/crti.o:(.init+0x0): first defined here

D:/Development/13214-ELMU/trunk/Freescale/KSDK_1.1.0/rtos/mqx/lib/frdmk64f.kds/debug/mqx/lib_mqx.a(comp.o): In function `_fini':

D:/Development/13214-ELMU/trunk/Freescale/KSDK_1.1.0/rtos/mqx/mqx/source/psp/cortex_m/compiler/gcc_arm/comp.c:85: multiple definition of `_fini'

d:/freescale/kds_2.0.0/toolchain/bin/../lib/gcc/arm-none-eabi/4.8.0/m4/fp/v4-sp-d16/crti.o:(.fini+0x0): first defined here

collect2.exe: error: ld returned 1 exit status

It looks like some of the standard library definitions in the PSP code are conflicting with the definitions in the arm-none-eabi code.ns,

As well, when I go to find stdio.h, I can find two versions, one in KSDK_1.1.0\rtos\mqx\mqx_stdlib\source\include\stdio.h, and the other in KDS_2.0.0\toolchain\arm-none-eabi\include\stdio.h.

This thread about C++ support(EWL C++ in MQX.), and a similar conflict with EWL and C++ shows that a lot of the MQX functions need to be redefined to MQX specific versions where conflicts arise. Is this the same situation now? I seem to remember that MQX had all MQX specific functions and structures in the previous MQX 4.1.0 and CW implementation. Has this changed? Do I need to modify the sources in the MQX libraries to remove the conflicts? Is there something I'm doing wrong in my project settings or compile process that might be leading to these conflicts?

Thanks,

Sean

1 Solution
3,633 Views
Martin_
NXP Employee
NXP Employee

Do you have "-z muldefs" for the gcc linker? Seems the multiple definitions needs to be allowed as some standard C library (toolchain lib) functions are overloaded.

View solution in original post

0 Kudos
3 Replies
3,634 Views
Martin_
NXP Employee
NXP Employee

Do you have "-z muldefs" for the gcc linker? Seems the multiple definitions needs to be allowed as some standard C library (toolchain lib) functions are overloaded.

0 Kudos
3,633 Views
ironsean
Contributor V

Adding "-z muldefs" to the "other linker flags" section of the Properties->C/C++ Build->Settings->Tool Settings->Cross ARM C++ Linker->Miscellaneous->Other linker flags allowed it to compile. Thanks!

3,633 Views
ironsean
Contributor V

Not that I can see, the linker call looks like this (line broken for readability):

arm-none-eabi-g++

-mcpu=cortex-m4

-mthumb

-mfloat-abi=hard

-mfpu=fpv4-sp-d16

-O0

-fmessage-length=0

-fsigned-char

-ffunction-sections

-fdata-sections 

-g3

-T "MK64FN1M0xxx12_flash.ld"

-Xlinker --gc-sections

-L

"D:/Development/13214-ELMU/trunk/ETCCode/ELMU_KDS_K64/ELMU_KDS_K64/Project_Settings/Linker_Files" -L

"D:\Development\13214-ELMU\trunk\Freescale\KSDK_1.1.0/lib/ksdk_mqx_lib/kds/K64F12/Debug" -L

"D:\Development\13214-ELMU\trunk\Freescale\KSDK_1.1.0/rtos/mqx/lib/frdmk64f.kds/debug/mqx" -L

"D:\Development\13214-ELMU\trunk\Freescale\KSDK_1.1.0/rtos/mqx/lib/frdmk64f.kds/debug/mqx_stdlib"

-Wl,-Map,"ELMU_KDS_K64.map"

-nanolibc

-o "ELMU_KDS_K64.elf" 

./Sources/Utilities/fsl_debug_console.o 

./Sources/Board/gpio_pins.o

./Sources/Board/hardware_init.o

./Sources/Board/pin_mux.o 

./Sources/BSP_files/init_bsp.o

./Sources/BSP_files/mqx_main.o 

./Sources/config.o

./Sources/main_task.o 

./Project_Settings/Startup_Code/startup.o

./Project_Settings/Startup_Code/startup_MK64F12.o

./Project_Settings/Startup_Code/system_MK64F12.o 

D:/Development/13214-ELMU/trunk/Freescale/KSDK_1.1.0/lib/ksdk_mqx_lib/kds/K64F12/Debug/libksdk_platform_mqx.a

D:/Development/13214-ELMU/trunk/Freescale/KSDK_1.1.0/filesystem/mfs/lib/frdmk64f.kds/debug/mfs/lib_mfs.a

D:/Development/13214-ELMU/trunk/Freescale/KSDK_1.1.0/tcpip/rtcs/lib/frdmk64f.kds/debug/rtcs/lib_rtcs.a

D:/Development/13214-ELMU/trunk/Freescale/KSDK_1.1.0/rtos/mqx/lib/frdmk64f.kds/debug/mqx/lib_mqx.a

D:/Development/13214-ELMU/trunk/Freescale/KSDK_1.1.0/rtos/mqx/lib/frdmk64f.kds/debug/mqx_stdlib/lib_mqx_stdlib.a

-lksdk_platform_mqx

-l_mqx

-l_mqx_stdlib

Would I add that to the command line pattern for the linker? I don't see any built in option to add that call.

Also, for some reason it's defaulting to the Cross ARM C++ Linker as the linker tool, Where it was the Windows ARM Ltd GCC C Linker in Codewarrrior. I can go into the toolchain editor and select tools, but I can't replace it with the Cross ARM C Linker without forcing "Allow all changes". Could this be part of the issue as well?

Sean

0 Kudos