On Thu, 1 Feb 2007, Andrew Errington wrote:

On Thu, 01 Feb 2007 11:39, you wrote:
Dear Linuxer,
I was wondering, in Linux can you have stand alone apps? For example,
"sol.exe" is Solitaire on Windows, It can be run without being
'Installed'. So I guess I am asking can you have programs that you don't
install and can just run off your desktop or something to that nature.

Yes.


Go on.

Be kind.

Tell him The Other Bit.


Andrew is quite correct, just perhaps, umm, a little unhelpful.

By default the linker generates executables that link to DLL's such as
libc. etc. etc.

Choose an executable of your choice from /bin or /usr/bin and feed it
to ldd. eg... I choose "/bin/ls" on my Ubuntu Edgy Eft box and get...

ldd /bin/ls
    linux-gate.so.1 =>  (0xffffe000)
    librt.so.1 => /lib/tls/i686/cmov/librt.so.1 (0xb7f77000)
    libacl.so.1 => /lib/libacl.so.1 (0xb7f71000)
    libselinux.so.1 => /lib/libselinux.so.1 (0xb7f5d000)
    libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0xb7e28000)
    libpthread.so.0 => /lib/tls/i686/cmov/libpthread.so.0 (0xb7e15000)
    /lib/ld-linux.so.2 (0xb7f94000)
    libattr.so.1 => /lib/libattr.so.1 (0xb7e11000)
    libdl.so.2 => /lib/tls/i686/cmov/libdl.so.2 (0xb7e0d000)
    libsepol.so.1 => /lib/libsepol.so.1 (0xb7dd0000)

So I can run that executable on this box. I can copy it to any other x86
linux box on the planet that has the DLL's
    linux-gate.so.1
    librt.so.1
    libacl.so.1
    libselinux.so.1
    libc.so.6
    libpthread.so.0
    /lib/ld-linux.so.2
    libattr.so.1
    libdl.so.2
libsepol.so.1 installed (even of some other minor version number) and it should run
and do pretty much The Right Thing.

If it hasn't got that set of DLL's it won't. It will die on start up.

Basically a nifty thing called ld.so wakes up when you run any program
and very quickly links any missing symbols into your executables. It
is even nice in that if two or more programs use the same DLL, (even if
run by different users) they share exactly the same physical copy of
the library in RAM.

But it doesn't have to be like that. You can statically link the
executable to all the libraries it needs, the resulting executable
will be Way Bigger and a whole lot of stuff will be duplicated in
every executable you do this to.

Then it doesn't matter which libraries are present or not present on
the box you execute on... it should run.

The gcc link option -static is the one you want.

A small bonus to compensate you for the Fat size of the executable...

It runs a teensy bit faster. (So long as you have the RAM)








John Carter                             Phone : (64)(3) 358 6639
Tait Electronics                        Fax   : (64)(3) 359 4632
PO Box 1645 Christchurch                Email : [EMAIL PROTECTED]
New Zealand

Reply via email to