[uClibc] Re: About the code buld and codesize reduce

Peter S. Mazinger ps.m at gmx.net
Fri Oct 22 18:36:25 UTC 2004


> Dear...
>  
> Remember I used the glibc and use gcc to compile my source code...
>  
> If a library, names "math.a", it provides
>  
> add()
> minus()
> multiple()
> divide()
> sum()
> square()
>  
> when I write a main function in hello.c, I use add() function in math.a
> only, such as
>  
> main()
> {
>     add()
>     return 0;
> }
>  
> the compiler command, how to do and it could just link the add()
> function in the math.a only.
> please give me a idea?
>  
> gcc hello.c -static math.a 
>  
> right?
>  
> The question when I meet, is dynamic link to statically link...
> If I want to use -lpthread -lstdc++ -ldl to static
>  
> armeb-linux-uclib-gcc hello.c math.a -static -lpthread -lstdc++ -ldl
>  
> it seems that the codesize is summation of the pthread, stdc++ and
> dl....
>  
> How to reduce it? I try to add -O2...I want to reduce more....

If you want to build partly against static, partly against dynamic 
libs, you can use -Wl,-Bstatic -lpthread -Wl,-Bdynamic (without -static 
on the command line). In this case you'll use libpthread.a, the rest 
of the used libs will be dynamic.

Peter

-- 
Peter S. Mazinger <ps dot m at gmx dot net>           ID: 0xA5F059F2
Key fingerprint = 92A4 31E1 56BC 3D5A 2D08  BB6E C389 975E A5F0 59F2




More information about the uClibc mailing list