Linking issues

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

Linking issues

2,482 Views
jagadeeshkumar
Contributor II

Hi all,

  I porting my old project which is implemented using atollic to latest version of MCUXpresso.

 I have ported successfully but because of the following issue I am not able to build the binary.Any one have any Idea about this issue.Fast help will be appreciated.

 c:/nxp/mcuxpressoide_10.2.0_759/ide/tools/bin/../lib/gcc/arm-none-eabi/7.2.1/../../../../arm-none-eabi/lib/thumb/v6-m\libcr_c.a(alloc.o): In function `malloc':
alloc.c:(.text.malloc+0x0): multiple definition of `malloc'
c:/nxp/mcuxpressoide_10.2.0_759/ide/tools/bin/../lib/gcc/arm-none-eabi/7.2.1/../../../../arm-none-eabi/lib/thumb/v6-m\libc.a(lib_a-malloc.o):malloc.c:(.text.malloc+0x0): first defined here
c:/nxp/mcuxpressoide_10.2.0_759/ide/tools/bin/../lib/gcc/arm-none-eabi/7.2.1/../../../../arm-none-eabi/lib/thumb/v6-m\libcr_c.a(alloc.o): In function `free':
alloc.c:(.text.free+0x0): multiple definition of `free'
c:/nxp/mcuxpressoide_10.2.0_759/ide/tools/bin/../lib/gcc/arm-none-eabi/7.2.1/../../../../arm-none-eabi/lib/thumb/v6-m\libc.a(lib_a-malloc.o):malloc.c:(.text.free+0x0): first defined here
collect2.exe: error: ld returned 1 exit status

I have used my own linker file and attached here.Let me know if more information is needed

4 Replies

1,986 Views
lpcxpresso_supp
NXP Employee
NXP Employee

I am glad to hear that you now have things working. I would still recommend that you take a look at the information on linker scripts in the IDE User Guide though - as I suspect that given the way you have ported your project across, you may not have things set up optimally.

Regards,

MCUXpresso IDE Support

0 Kudos

1,986 Views
lpcxpresso_supp
NXP Employee
NXP Employee

From the error message snippet you have provided, you appear to be trying to link against both the Redlib and Newlib C libraries. Don't ! Double check the contents of your file "testbox_plus_Debug_library.ld" and compare it against the recommendations in section 15.7, "Libraries and linker scripts" of the MCUXpresso IDE v10.2 User Guide.

Note that normally you would use the IDE's managed linker script mechanism to autogenerate appropriate linker scripts -  which generally avoids this sort of problem. Please read chapter 16,  "Memory Configuration and Linker Scripts" of the IDE User Guide for more details.

Regards,

MCUXpresso IDE Support

0 Kudos

1,987 Views
jagadeeshkumar
Contributor II

Hi,

  Thank you for immediate response.

I have configured redlib(auto) in my compiler configurations.and in my liker script i have included smartbox_plus_Debug_library.ld file while contains the following information

  GROUP (
"libcr_semihost_nf.a"
"libcr_c.a"
"libcr_eabihelpers.a"
)

If I remove any one .a file from smartbox_plus_Debug_library.ld I am getting two many errors.

In section 15.7, "Libraries and linker scripts" I haven't seen any thing related to redlib(auto).

The linker script what I am using is from my old project.I want to use the same linker to avoid further issues.If its not at all possible then I will try to create from IDE.

Regards,

Jagadeesh

0 Kudos

1,987 Views
jagadeeshkumar
Contributor II

I have selected newlib(host) library.looks like its resolved now

0 Kudos