How to use chatr to change static library path in binary?
I have solved this but now cannot recall the syntax. I want to strip or change the hard wired library paths on binaries I download from a repository. I do not have root and just want a personal install, but would rather not build every tool. I even posted the solution here once for others, but cannot find it.
Code:
$ bzip2 --help
/usr/lib/dld.sl: Can't open shared library: /usr/local/lib/libbz2.sl
/usr/lib/dld.sl: No such file or directory
Abort
$ whence bzip2
~/myroot/usr/local/bin/bzip2
$ find myroot -name libbz2.sl
myroot/usr/local/lib/libbz2.sl
$
---------- Post updated at 03:45 PM ---------- Previous update was at 02:53 PM ----------
I did something right, and now it works:
Code:
$ chatr +s enable -l /usr/local/lib/libbz2.sl myroot/usr/local/bin/bzip2
myroot/usr/local/bin/bzip2:
current values:
shared executable
shared library dynamic path search:
SHLIB_PATH enabled second
embedded path disabled first Not Defined
shared library list:
static /usr/local/lib/libbz2.sl
dynamic /usr/lib/libc.2
shared library binding:
deferred
global hash table disabled
plabel caching disabled
global hash array size:1103
global hash array nbuckets:3
shared vtable support disabled
explicit unloading enabled
static branch prediction disabled
executable from stack: D (default)
kernel assisted branch prediction enabled
lazy swap allocation disabled
text segment locking disabled
data segment locking disabled
third quadrant private data space disabled
fourth quadrant private data space disabled
third quadrant global data space disabled
data page size: D (default)
instruction page size: D (default)
nulptr references disabled
shared library private mapping disabled
shared library text merging disabled
new values:
shared executable
shared library dynamic path search:
SHLIB_PATH enabled second
embedded path disabled first Not Defined
shared library list:
dynamic /usr/local/lib/libbz2.sl
dynamic /usr/lib/libc.2
shared library binding:
deferred
global hash table disabled
plabel caching disabled
global hash array size:1103
global hash array nbuckets:3
shared vtable support disabled
explicit unloading enabled
static branch prediction disabled
executable from stack: D (default)
kernel assisted branch prediction enabled
lazy swap allocation disabled
text segment locking disabled
data segment locking disabled
third quadrant private data space disabled
fourth quadrant private data space disabled
third quadrant global data space disabled
data page size: D (default)
instruction page size: D (default)
nulptr references disabled
shared library private mapping disabled
shared library text merging disabled
$ bzip2 --help
bzip2, a block-sorting file compressor. Version 1.0.6, 6-Sept-2010.
usage: bzip2 [flags and input files in any order]
-h --help print this message
-d --decompress force decompression
-z --compress force compression
-k --keep keep (don't delete) input files
-f --force overwrite existing output files
-t --test test compressed file integrity
-c --stdout output to standard out
-q --quiet suppress noncritical error messages
-v --verbose be verbose (a 2nd -v gives more)
-L --license display software version & license
-V --version display software version & license
-s --small use less memory (at most 2500k)
-1 .. -9 set block size to 100k .. 900k
--fast alias for -1
--best alias for -9
If invoked as `bzip2', default action is to compress.
as `bunzip2', default action is to decompress.
as `bzcat', default action is to decompress to stdout.
If no file names are given, bzip2 compresses or decompresses
from standard input to standard output. You can combine
short flags, so `-v -4' means the same as -v4 or -4v, &c.
$ ldd -rsv local/bin/bzip2
find library=/usr/lib/libc.2; required by local/bin/bzip2
search path=/usr/lib:/usr/local/lob:/dhome1/n/nbkodln/local/lib (SHLIB_PATH)
trying path=/usr/lib/libc.2
/usr/lib/libc.2 => /usr/lib/libc.2
find library=/usr/lib/libdld.2; required by /usr/lib/libc.2
search path=/usr/lib:/usr/local/lob:/dhome1/n/nbkodln/local/lib (SHLIB_PATH)
trying path=/usr/lib/libdld.2
/usr/lib/libdld.2 => /usr/lib/libdld.2
find library=/usr/lib/libc.2; required by implicit load
search path=/usr/lib:/usr/local/lob:/dhome1/n/nbkodln/local/lib (SHLIB_PATH)
trying path=/usr/lib/libc.2
/usr/lib/libc.2 => /usr/lib/libc.2
find library=/usr/local/lib/libbz2.sl; required by local/bin/bzip2
search path=/usr/lib:/usr/local/lob:/dhome1/n/nbkodln/local/lib (SHLIB_PATH)
trying path=/usr/lib/libbz2.0
trying path=/usr/local/lob/libbz2.0
trying path=/dhome1/n/nbkodln/local/lib/libbz2.0
trying path=/usr/local/lib/libbz2.0 (absolute)
search path=/usr/lib:/usr/local/lob:/dhome1/n/nbkodln/local/lib (SHLIB_PATH)
trying path=/usr/lib/libbz2.sl
trying path=/usr/local/lob/libbz2.sl
trying path=/dhome1/n/nbkodln/local/lib/libbz2.sl
/usr/local/lib/libbz2.sl => /dhome1/n/nbkodln/local/lib/libbz2.sl
$
Word is that sometimes "+b disable" helps, if the files are not ELF.
This modifies your executbles in place, so it is a best practice to keep a copy of the original!
It is a cranky command, as I was getting errors about the missing library from chatr at first. Maybe just fat fingers and too much command recall! Thanks!
Hi,
Environment:
Linux: Ubuntu 12.04
I am connected to internet using static ip. This means my internet provider Pacenet has assigned me static ip. Now, whenever I am trying to change source ip for tcp/ip (ip4) using iptables firewall, I am unable to access internet at all.
Can anybody... (4 Replies)
I'm writing a program which uses curl to be run on Linux PCs which will be used by a number of different users. I cannot make the users all install curl on their individual machines, so I have tried to link curl in statically, rather than using libcurl.so. I downloaded the source and created a... (8 Replies)
Hello,
I have a doubt:-
---------------------
Current script:-
################################################################################################
prefix=user@my-server:
find . -depth -type d -name .git -printf '%h\0' | while read -d "" path ; do (
cd "$path" || exit $?... (4 Replies)
I am having a devil of a time with a very simple make file. The program needs two shared and one static library. If I link the shared libraries only like below the mysql test app works
... (1 Reply)
I have some static library(libxxx.a libyyy.a).
And I want to generate my library(libzzz.a), libzzz.a will use libxxx.a and libyyy.a
I wan't my application only use libzzz.a, (means libzzz.a had include libxxx.a, libyyy.a), how can I do that? Thank you.
example:
I have zzz.c.
I do ... (4 Replies)
Hi,
The following is my Makefile, I wanted to add a staic library named libtimer.a. I'm using the following Makefile. Please let me know how to add this static library:
Makefile:-
It produces "usbserial" executable.
Thanks,
S (1 Reply)
I had just install a solaris 10 server. I set the ip address to static during installation. I want to change it to dynamic but I don't know how. Expert here please help me! (5 Replies)
Hi:
I have a library that it only offers Makefile for building static library. It built libxxx.a file. How do I in any way build a shared library? (either changin the Makefile or direct script or command to build shared library)
Thanks. (1 Reply)