Sponsored Content
Full Discussion: removing library path
Operating Systems HP-UX removing library path Post 302145563 by porter on Wednesday 14th of November 2007 04:05:06 PM
Old 11-14-2007
Here is a script I use to prefix a link command which I use to strip the leading paths.

I do this by executing the build command and looking at the resulting binary and it's dynamic references then rebuilding the binary.

There are a couple of required variables for this to work, mainly SHLB_REF_STRONG is a PATH like list of directories that should be stripped, these are then matched against the referenced library, if it matches a -Wl,+cdp argument is added to the build line.

Then the binary is rebuilt.

Code:
#!/bin/sh
# author: porter@www.unix.com
# this is provided as is with no claim to be fit for any purpose
# do not remove this header

ORIGINAL_CMD=$@

if test "$LD" = ""
then
	LD=ld
fi

is_member()
{
	is_member_1=$1
	shift
	for is_member_i in $@
	do
		if test "$is_member_i" = "$is_member_1"
		then
			return 0
		fi
	done
	return 1
}

is_ld()
{
	for is_ld_i in $@
	do
		case "$is_ld_i" in
		$LD )
			return 0
			;;
		$CC )
			return 1;
			;;
		$CXX )
			return 1;
			;;
		* )
			;;
		esac
	done
	return 1
}

# echo $ORIGINAL_CMD=$ORIGINAL_CMD

SEARCH_PATHS="`echo $SHLB_REF_STRONG $SHLB_REF_WEAK | sed y/:/\\ /`"
STRIP_PATHS=

# echo SEARCH_PATHS=$SEARCH_PATHS

$ORIGINAL_CMD

RC=$?

if test "$RC" != "0"
then
	exit $RC
fi

PREV_FLAG=
OUTPUT_FILE=

for d in $ORIGINAL_CMD
do
	case "$d" in
	-o )
		PREV_FLAG=$d
		;;
	* )
		case "$PREV_FLAG" in
		-o )
			OUTPUT_FILE="$d"
			;;
		* )
			;;
		esac
		PREV_FLAG=
		;;
	esac
done

# echo OUTPUT_FILE=$OUTPUT_FILE

if test -f "$OUTPUT_FILE"
then
	for d in `chatr "$OUTPUT_FILE" | grep dynamic`
	do
		if test -f "$d"
		then
# echo POSSIBLE $d
			e=`dirname $d`
			if is_member $e $SEARCH_PATHS
			then
				STRIP_PATHS="$STRIP_PATHS $d"
			fi			
		fi
	done
else
	exit 0
fi

# echo STRIP_PATHS=$STRIP_PATHS

if test "$STRIP_PATHS" = ""
then
	exit 0
fi

rm $OUTPUT_FILE

NEW_CMD="$ORIGINAL_CMD"

for d in $STRIP_PATHS
do
	e=`basename $d`
	if is_ld $ORIGINAL_CMD
	then
		NEW_CMD="$NEW_CMD +cdp $d:$e"
	else
		NEW_CMD="$NEW_CMD -Wl,+cdp,$d:$e"
	fi
done

#echo CC=$CC
#echo CXX=$CXX
#echo LD=$LD
#echo NEW_CMD=$NEW_CMD

$NEW_CMD

RC=$?

# echo NEW_CMD returned $RC

if test "$RC" != "0"
then
	echo NEW_CMD returned $RC
	exit $RC
fi

# chatr $OUTPUT_FILE

# exit 1

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

library path

How do you get an application to use an alternate library? Dave:confused: (2 Replies)
Discussion started by: nucca
2 Replies

2. Shell Programming and Scripting

Setting path for a stand alone library in home directory

Hi all, This is probably a basic question. I had installed a stand-alone library called szip in my home directory, as I don't have the necessary root permission. I tried to set an environment for both include and lib files in my .cshrc script as setenv /home/szip/lib setenv... (3 Replies)
Discussion started by: alamcheril
3 Replies

3. UNIX for Advanced & Expert Users

library path in linux

Is there something which is an alternative to the variable LD_LIBRARY_PATH? The behaviour of this variable is that the path specified here will be checked before checking usual paths. But I want to have some folders checked for shared libraries after the usual paths. i.e usual paths have to... (3 Replies)
Discussion started by: bbala
3 Replies

4. Shell Programming and Scripting

unix Library path variables.

Library path variables. I need to know the library rnvironment variable in linux. Ie, I install zlib directory in the custom path /usr/local/mylib and give --enable-zlib in the ffmpeg install, ffmpeg should check for the zlib libraries in the path /usr/local/mylib. Currently it checks /usr/lib... (5 Replies)
Discussion started by: anilcliff
5 Replies

5. Shell Programming and Scripting

Library on Remote machine or $PATH is not working..

I don't know how to put this. However here is the problem. While executing command remotely on a Unix machine i get an error /usr/lib/hpux32/dld.so: Unable to find library 'libxerces-c.sl.21'. However when i execute the command on the remote machine locally. it works fine. Also i have... (2 Replies)
Discussion started by: suraj.sheikh
2 Replies

6. UNIX for Advanced & Expert Users

Can't find path for shared library: libintl.sl

Hello, Any inputs about this one? /usr/lib/dld.sl: Can't find path for shared library: libintl.sl /usr/lib/dld.sl: No such file or directory : Core file for 32-bit PA-RISC application : /tmp/usr/local/bin/git saved to /etc/core.git. ABORT instruction (core dumped) bash-4.0# echo... (3 Replies)
Discussion started by: SystemAddict
3 Replies

7. Programming

C++ library path

Hello, How to set up the path for downloaded C/C++ libraries (or, header files) so that they can be included like system headers (stdio.h or iostream)? The libraries/headers are from a package containing different folders each has different sets of headers and put in... (1 Reply)
Discussion started by: yifangt
1 Replies

8. Programming

Boost library path for cmake & make

I was compiling a downloaded open source pkg. Following the install instruction, I did $ mkdir build; cd build; cmake ../; make but got error message:make: *** No rule to make target 'usr/lib64/lib64/libboost_graph-mt.so.5'. needed by ../bin.gam-create. stop make: *** Error 2 make: *** Error... (1 Reply)
Discussion started by: yifangt
1 Replies

9. Programming

Library/header path for ./configure

Hello, I am always confused about adding library path for ./configure when compiling software under Linux Debian based OS. For example the README of the software tells --with-boost=PATH specify directory for the boost header files --with-mpi=PATH specify prefix directory for... (4 Replies)
Discussion started by: yifangt
4 Replies

10. AIX

AIX full path to socket library

Can somebody help me too identify full path to socket library on AIX? Cannot find anything Thanks for contribution (2 Replies)
Discussion started by: digioleg54
2 Replies
ldd_pa(1)						      General Commands Manual							 ldd_pa(1)

NAME
ldd_pa: ldd - list dynamic dependencies of executable files or shared libraries on PA-RISC systems SYNOPSIS
filename... Remarks This manpage describes on PA-RISC systems. For on Integrity systems, see ldd_ia(1). DESCRIPTION
is a command that can list the dynamic dependencies of incomplete executable files or shared libraries. lists verbose information about dynamic dependencies and symbol references. If the object file is an executable file, lists all shared libraries that would be loaded as a result of executing the file. If it is a shared library, lists all shared libraries that would be loaded as a result of loading the library. uses the same algorithm as the dynamic loader and to locate the shared libraries. See and sections in dld.sl(5) for more information. Options recognizes the following options: PA-RISC 32-bit only. Used in conjunction with and/or to force to bind all dependent libraries and report unsats. By default the smartbind mechanism in only binds libraries whose symbols are explicitly referenced. Check reference to data symbols. Check reference to data and code symbols. Display the search path used to locate the shared libraries. Display all dependency relationships. EXTERNAL INFLUENCES
Environment Variables uses the following environment variables to locate shared libraries. PA-RISC 64-bit mode: A colon-separated list of path names which defines the search path for shared libraries at runtime. See in dld.sl(5) for more information. A colon-separated or space-separated list of libraries which the dynamic loader implicitly loads first at runtime. See in dld.sl(5) for more information. A colon-separated list of path names which defines the search path for shared libraries at runtime. See and in dld.sl(5) for more information. The following internationalization variables affect the execution of Determines the locale category for native language, local customs and coded character set in the absence of and other environment variables. If is not specified or is set to the empty string, a default of (see lang(5)) is used instead of Determines the values for all locale categories and has precedence over and other environment variables. Determines the locale that should be used to affect the format and contents of diagnostic messages written to standard error. Determines the locale category for numeric formatting. Determines the locale category for character handling functions. Determines the location of message catalogs for the processing of If any internationalization variable contains an invalid setting, behaves as if all internationalization variables are set to See envi- ron(5). DIAGNOSTICS
prints the record of shared library path names to stdout. The optional list of symbol resolution problems are printed to stderr. returns zero when the operation is successful. A non-zero return code indicates that an error occurred. EXAMPLES
By default prints a simple dynamic path information. This consists of the dependencies recorded in the executable (or the shared library) followed by the physical location where these libraries are found. The option causes to print dependency relationship along with the dynamic path information. The option causes to analyze all symbol references and print information about unsatisfied code and data symbols. The option causes to print the dynamic search path lists used to load the libraries in the order that the path lists are referenced: WARNINGS
does not list shared libraries explicitly loaded using dlopen(3C) or shl_load(3X). FILES
output file 32-bit PA-RISC dynamic loader 64-bit PA-RISC dynamic loader 32-bit dummy executable loaded to check the dependencies of shared libraries. 64-bit dummy executable loaded to check the dependencies of shared libraries. message catalog SEE ALSO
System Tools ld(1) invoke the link editor Miscellaneous a.out(4) assembler, compiler, and linker output dld.sl(5) PA-RISC dynamic loader Texts and Tutorials
All times are GMT -4. The time now is 10:21 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy