This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Linking error


On Fri, Jun 15, 2012 at 12:31 PM, naga raj <gnuuser.raj@gmail.com> wrote:
> Thanks Ian for the reply.
>
> On Thu, Jun 14, 2012 at 10:23 PM, Ian Lance Taylor <iant@google.com> wrote:
>> naga raj <gnuuser.raj@gmail.com> writes:
>>
>>> ? ? I am using arm compiler to run a simple c++ program
>>>
>>> ?#include <iostream>
>>> ?#include <cstdlib>
>>> ?using namespace std;
>>>
>>> ?int main(int argc, char* argv[])
>>> ?{
>>> ? ? ? ? ? ? ? ? cout <<"hi" <<endl;
>>> ? ? ? ? ? ? ? ? return 0;
>>> ? }
>>>
>>> ? It was compiled sucessfully but in linking it is throwing following errors
>>>
>>> ? arm-eabi-g++ -Wl,-T -Wl,../src/lscript.ld
>>> -L../../empty_cpp_bsp_0/lib -o"empty_cpp_0.elf" ?./src/main.o
>>> -Wl,--start-group,-llocal,-lgcc,-lc,-lstdc++,--end-group
>>>
>>> ../../empty_cpp_bsp_0/lib/liblocal.a(close.o): In function `close':
>>> /proj/empty_cpp_bsp_0//libsrc/src/close.c:50: multiple definition of `close'
>>> /bin/../lib/gcc/arm-eabi/4.6.1/../../../../arm-eabi/lib/libc.a(lib_a-sysclose.o):sysclose.c:(.text+0x0):
>>> first defined here
>>>
>>> ../../empty_cpp_bsp_0/lib/liblocal.a(fstat.o): In function `fstat':
>>> /proj/arm/empty_cpp_bsp_0/libsrc/src/fstat.c:51: multiple definition of `fstat'
>>> /bin/../lib/gcc/arm-eabi/4.6.1/../../../../arm-eabi/lib/libc.a(lib_a-sysfstat.o):sysfstat.c:(.text+0x0):
>>> first defined here
>>> collect2: ld returned 1 exit status
>>> make: *** [empty_cpp_0.elf] Error 1
>>>
>>> My requirement is to pick close() & fstat() functions from
>>> /proj/empty_cpp_bsp_0/lib/liblocal.a not from
>>> /bin/../lib/gcc/arm-eabi/4.6.1/../../../../arm-eabi/lib/libc.a
>>>
>>> I have included my local library with -L../../empty_cpp_bsp_0/lib..
>>>
>>> Can anyone please help me in fixing this compilation issue..
>>
>>
>> This is really a library issue, and you didn't say anything about the
>> libraries you are using.
>
> ? It is for a embedded target so we have developed our own libraries.
> In our library close is just a dummy function it does nothing..
>
>> You can try using the option -Wl,foo.map and then looking in the foo.map
>> file to see why the different objects are being included. ?That may
>> suggest how to fix your libraries.
>
> ?From map file I found that close() function is called from libc of
> toolchain and not from my local library. I dont know why it is still
> refering close in local library.
>
> ?> Ian
>
> Thanks,
> Nagaraju

The linking order is from left to right.
Try this ordering: -Wl,--start-group,-lgcc,-llocal,-lc,-lstdc++,--end-group

-Rohit


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]