Linking error

Ian Lance Taylor iant@google.com
Thu Jun 14 16:54:00 GMT 2012


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.

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.

Ian



More information about the Binutils mailing list