Re: statically linking standard libraries

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thanks Axel,

I also need to pass a linker script to the linker. I tried the
following option to g++:

-Xlinker "-T temp.ld"

It complains that it cannot find the linker script file even though
the temp.ld is in the same directory. I tried specifying the entire
path to the file but it didn't like that either. Is there a way to
specify the path?

Jerin

On Fri, Oct 16, 2009 at 12:30 PM, Axel Freyn <axel-freyn@xxxxxx> wrote:
> Hi Jerin,
>
>> I'm having some issues trying to compile a standalone library.
>>
>> I first create my object files without linking:
>> cross-g++ -c -o  abc.o -fno-use-cxa-atexit abc.cc
>> cross-g++ -c -o  cppfunc.o -fno-use-cxa-atexit cppfunc.cc
>> cross-g++ -c -o  assemble.o -fno-use-cxa-atexit assemble.cc
>>
>> I'm unable to link them together. When I run:
>> cross-ld  -T test.ld assemble.o cppfunc.o abc.o -o standalone_program
>>
>> The linker throws errors:
>> : undefined reference to `printf'
>> : undefined reference to `free'
>> : undefined reference to `strcpy'
>> ..
>>
>> I'm trying to cross compile the code. I'm compiling on an x86 machine
>> but the binary has to run on a different architecture. The "cross-g++"
>> and "cross-ld" binaries compile code for the different architecture.
>>
>> I want to build a standalone binary. I tried passing a couple of
>> options to the g++ and ld:
>> -Bstatic
>> -L/path to libstdc++.a
>>
>> but that did not help.
> The errors result from the fact that some libraries are missing. At
> least "-lcstd" is needed (this includes "printf"). Did you try
>
> cross-g++ -static assemble.o cppfunc.o abc.o -o standalone_program
>
> ?
> This would leave cross-g++ the decision, which libraries have to be
> passed to "ld" exactly.
>
> HTH,
>
> Axel
>
>
>


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux