[prev in list] [next in list] [prev in thread] [next in thread] 

List:       freebsd-chat
Subject:    Re: Where to put private lib files?
From:       Stephen Hurd <shurd () sasktel ! net>
Date:       2010-02-25 6:10:16
Message-ID: 4B861448.2040207 () sasktel ! net
[Download RAW message or body]

Stephen Hurd wrote:
>>> You can also compile in a search path.
>>>     
>>
>> Not PREFIX-safe, hence not allowed in ports unless there is no other
>> solution
>
> Eh?  It doesn't need to be an absolute path.

To follow up on this for you Ronald, to compile in a PREFIX-safe 
relative library path, you need to pass -z origin -rpath 
$ORIGIN/../lib/pkgname to the linker... that is a literal $ so assuming 
you're using regular make files and gcc as the linker, you would add 
this line:

LDFLAGS += -Wl,-z,origin,-rpath,\$$ORIGIN/../lib/$(PORTNAME)

You need to double the $ so that make doesn't expand $ORIGIN for you and 
the \ is for the shell.  The command line would be something like this:
cc -O2 -pipe -march=pentium4  -Wl,-z,origin,-rpath,\$ORIGIN/../lib/test 
test.c -L. -ltest -o test

You may need to fiddle around to get the literal $ in there, a strings 
on the compiled binary would include ``$ORIGIN/../lib/test'' (without 
the quotes of course).

The reason you *need* to use $ORIGIN is that if you don't the relative 
path will be to whatever the pwd is when the process is started making 
them effectively random.

Have fun!
_______________________________________________
freebsd-chat@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-chat
To unsubscribe, send any mail to "freebsd-chat-unsubscribe@freebsd.org"
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic