g++ - Force shared libraries to be linked as static??

Armitage

Banned
Feb 23, 2001
8,086
0
0
I'm trying to run an executable on a machine that doesn't have the peoper shared libraries installed (libmysqlclient FWIW)?

I've tried copying the library in question to my home directory and add the path to it to LD_LIBRARY_PATH. This worked for libg2c, but it's not working for libmysqlclient.

Is there anyway to fore the linker to threat the library as a staic library at build time, so it's right there in the executable?
Any other ideas?

It is such a PITA working on a system I don't have root on :| especially when the guy that does have it is gone till Monday :disgust:
 

Armitage

Banned
Feb 23, 2001
8,086
0
0
Holy executable size batman!
But it worked! Not sure how I missed that looking through the man pages on Wed. ... I guess my brain was already on vacation.
Thanks.
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
Originally posted by: Armitage
Holy executable size batman!
But it worked! Not sure how I missed that looking through the man pages on Wed. ... I guess my brain was already on vacation.
Thanks.

I hear ya. I went the easier route and looked into something I knew could be static to see how it built. :p
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
It probably didn't work because libmysqlclient also depends on a handfull of other libraries.

ldd /usr/lib/libmysqlclient.so.10
libz.so.1 => /usr/lib/libz.so.1 (0x70050000)
libcrypt.so.1 => /lib/libcrypt.so.1 (0x70074000)
libnsl.so.1 => /lib/libnsl.so.1 (0x700b0000)
libm.so.6 => /lib/libm.so.6 (0x700d4000)
libc.so.6 => /lib/libc.so.6 (0x70168000)
/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x08000000)
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
Originally posted by: Nothinman
It probably didn't work because libmysqlclient also depends on a handfull of other libraries.

ldd /usr/lib/libmysqlclient.so.10
libz.so.1 => /usr/lib/libz.so.1 (0x70050000)
libcrypt.so.1 => /lib/libcrypt.so.1 (0x70074000)
libnsl.so.1 => /lib/libnsl.so.1 (0x700b0000)
libm.so.6 => /lib/libm.so.6 (0x700d4000)
libc.so.6 => /lib/libc.so.6 (0x70168000)
/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x08000000)

It's not smart enough to go down the list and grab everything it needs?
 

Armitage

Banned
Feb 23, 2001
8,086
0
0
Originally posted by: n0cmonkey
Originally posted by: Nothinman
It probably didn't work because libmysqlclient also depends on a handfull of other libraries.

ldd /usr/lib/libmysqlclient.so.10
libz.so.1 => /usr/lib/libz.so.1 (0x70050000)
libcrypt.so.1 => /lib/libcrypt.so.1 (0x70074000)
libnsl.so.1 => /lib/libnsl.so.1 (0x700b0000)
libm.so.6 => /lib/libm.so.6 (0x700d4000)
libc.so.6 => /lib/libc.so.6 (0x70168000)
/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x08000000)

It's not smart enough to go down the list and grab everything it needs?

Well it would be if they were present on the system. When I hacked things around in my original try, I only copied over the libmysqlclient file. I didn't think to check for dependencies from that library.
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
It's not smart enough to go down the list and grab everything it needs?

g++ -static should be, but his original attempt was to copy the necessary libraries and use LD_LIBRARY_PATH to have the dynamic linker find them in a non-standard directory.
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
Originally posted by: Nothinman
It's not smart enough to go down the list and grab everything it needs?

g++ -static should be, but his original attempt was to copy the necessary libraries and use LD_LIBRARY_PATH to have the dynamic linker find them in a non-standard directory.

It appears I'm not smart enough to follow a thread. :p

I get it now. :)