What is the difference between "-Bstatic -lm" VS "-static -lm"?
Reply by ●March 24, 20152015-03-24
On Monday, March 23, 2015 at 4:53:44 PM UTC-7, Rob Doyle wrote:
> On 3/23/2015 2:14 PM, wrote:
> > On Friday, March 20, 2015 at 8:58:54 PM UTC-7, Rob Doyle wrote:
> >> On 3/20/2015 6:29 PM wrote:
> >>> When I ran ldd on myprogeamExecutable and I got: linux-vdso.so.1 =>
> >>> (0x00007fff08709000) libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6
> >>> (0x00007f015360a000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6
> >>> (0x00007f0153245000) /lib64/ld-linux-x86-64.so.2
> >>> (0x00007f0153929000)
> >>>
> >>> I need to port this to a server.
> >>>
> >>> I am wondering how to meet these dependencies - I know the server is
> >>> 64bit Debian - what Debian commands needs to be issued to meet these
> >>> dependencies?
> >>>
> >>> myprogeamExecutable was generated on a 64 bit Ubuntu (AMD cpu). If
> >>> Ubuntu binaries are not compatible, I will find a Debian VM and
> >>> recompile - but wil still have to address the dependencies - what
> >>> are each of the dependencies mean?
> >>>
> >>
> >> Statically link the executable with libraries. The file will be
> >> huge but won't require any shared libraries.
> >>
> >> Google will help. For example:
> >>
> >> http://stackoverflow.com/questions/3870121/statically-linking-libraries-in-linux
> >>
> >> Rob.
> >
> > When u say Statically link the executable with libraries
> > do you mean at run time?
> >
> > Because, it was compiled on a different machine and then I only had to link one library with the "-lm" command.
>
> This just says you need to link with 'libm' - the math library. It
> doesn't say anything about static linkage.
>
> > Could you elaborate your reply? Thanks
>
> Libraries can be statically linked into the program when it is built
> or dynamically linked when the program is executed.
>
> If you statically link in all the libraries, the program does not
> require any shared libraries on the target computer.
>
> http://cs-fundamentals.com/tech-interview/c/difference-between-static-and-dynamic-linking.php
>
> Rob.
Rob, Just to confirm - I need to recompile as below?
gcc a.c b.c -o myprogramEXE -static libm
Reply by Rob Doyle●March 23, 20152015-03-23
On 3/23/2015 2:14 PM, speech2020@gmail.com wrote:
> On Friday, March 20, 2015 at 8:58:54 PM UTC-7, Rob Doyle wrote:
>> On 3/20/2015 6:29 PM wrote:
>>> When I ran ldd on myprogeamExecutable and I got: linux-vdso.so.1 =>
>>> (0x00007fff08709000) libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6
>>> (0x00007f015360a000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6
>>> (0x00007f0153245000) /lib64/ld-linux-x86-64.so.2
>>> (0x00007f0153929000)
>>>
>>> I need to port this to a server.
>>>
>>> I am wondering how to meet these dependencies - I know the server is
>>> 64bit Debian - what Debian commands needs to be issued to meet these
>>> dependencies?
>>>
>>> myprogeamExecutable was generated on a 64 bit Ubuntu (AMD cpu). If
>>> Ubuntu binaries are not compatible, I will find a Debian VM and
>>> recompile - but wil still have to address the dependencies - what
>>> are each of the dependencies mean?
>>>
>>
>> Statically link the executable with libraries. The file will be
>> huge but won't require any shared libraries.
>>
>> Google will help. For example:
>>
>> http://stackoverflow.com/questions/3870121/statically-linking-libraries-in-linux
>>
>> Rob.
>
> When u say Statically link the executable with libraries
> do you mean at run time?
>
> Because, it was compiled on a different machine and then I only had to link one library with the "-lm" command.
This just says you need to link with 'libm' - the math library. It
doesn't say anything about static linkage.
On Friday, March 20, 2015 at 8:58:54 PM UTC-7, Rob Doyle wrote:
> On 3/20/2015 6:29 PM wrote:
> > When I ran ldd on myprogeamExecutable and I got: linux-vdso.so.1 =>
> > (0x00007fff08709000) libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6
> > (0x00007f015360a000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6
> > (0x00007f0153245000) /lib64/ld-linux-x86-64.so.2
> > (0x00007f0153929000)
> >
> > I need to port this to a server.
> >
> > I am wondering how to meet these dependencies - I know the server is
> > 64bit Debian - what Debian commands needs to be issued to meet these
> > dependencies?
> >
> > myprogeamExecutable was generated on a 64 bit Ubuntu (AMD cpu). If
> > Ubuntu binaries are not compatible, I will find a Debian VM and
> > recompile - but wil still have to address the dependencies - what
> > are each of the dependencies mean?
> >
>
> Statically link the executable with libraries. The file will be
> huge but won't require any shared libraries.
>
> Google will help. For example:
>
> http://stackoverflow.com/questions/3870121/statically-linking-libraries-in-linux
>
> Rob.
When u say
> Statically link the executable with libraries
do you mean at run time?
Because, it was compiled on a different machine and then I only had to link one library with the "-lm" command.
Could you elaborate your reply? Thanks
Reply by Tauno Voipio●March 21, 20152015-03-21
On 21.3.15 03:29, speech2020@gmail.com wrote:
> When I ran ldd on myprogeamExecutable and I got:
> linux-vdso.so.1 => (0x00007fff08709000)
> libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f015360a000)
> libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f0153245000)
> /lib64/ld-linux-x86-64.so.2 (0x00007f0153929000)
>
> I need to port this to a server.
>
> I am wondering how to meet these dependencies - I know the server is 64bit Debian - what Debian commands needs to be issued to meet these dependencies?
>
> myprogeamExecutable was generated on a 64 bit Ubuntu (AMD cpu). If Ubuntu binaries are not compatible, I will find a Debian VM and recompile - but wil still have to address the dependencies - what are each of the dependencies mean?
libm is the mathematics library. The other pieces are present in
all user-space runnable code.
linux-vdso is a system-call helper used by the C library.
libc is the standard C runtime library.
ld-linux-x86-64 is the 64 bit dynamic library loader.
Ubuntu is a direct derivative of Debian, so your binary should
work directly on the server, unless the server system code is
so old that it is obsolete.
--
-TV
Reply by Rob Doyle●March 21, 20152015-03-21
On 3/20/2015 6:29 PM, speech2020@gmail.com wrote:
> When I ran ldd on myprogeamExecutable and I got: linux-vdso.so.1 =>
> (0x00007fff08709000) libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6
> (0x00007f015360a000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6
> (0x00007f0153245000) /lib64/ld-linux-x86-64.so.2
> (0x00007f0153929000)
>
> I need to port this to a server.
>
> I am wondering how to meet these dependencies - I know the server is
> 64bit Debian - what Debian commands needs to be issued to meet these
> dependencies?
>
> myprogeamExecutable was generated on a 64 bit Ubuntu (AMD cpu). If
> Ubuntu binaries are not compatible, I will find a Debian VM and
> recompile - but wil still have to address the dependencies - what
> are each of the dependencies mean?
>
When I ran ldd on myprogeamExecutable and I got:
linux-vdso.so.1 => (0x00007fff08709000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f015360a000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f0153245000)
/lib64/ld-linux-x86-64.so.2 (0x00007f0153929000)
I need to port this to a server.
I am wondering how to meet these dependencies - I know the server is 64bit Debian - what Debian commands needs to be issued to meet these dependencies?
myprogeamExecutable was generated on a 64 bit Ubuntu (AMD cpu). If Ubuntu binaries are not compatible, I will find a Debian VM and recompile - but wil still have to address the dependencies - what are each of the dependencies mean?