Date: Wed, 24 Feb 2010 22:10:16 -0800 From: Stephen Hurd <shurd@sasktel.net> To: =?UTF-8?B?RGFnLUVybGluZyBTbcO4cmdyYXY=?= <des@des.no> Cc: Ronald <followait@163.com>, "Freebsd-Chat@Freebsd.Org" <freebsd-chat@freebsd.org> Subject: Re: Where to put private lib files? Message-ID: <4B861448.2040207@sasktel.net> In-Reply-To: <4B84C02A.9010001@sasktel.net> References: <DD958BBC52D94F79855244E6890704DB@jqslaptop> <868wak2sv5.fsf@ds4.des.no> <4B83B4AA.3030405@sasktel.net> <864ol817yq.fsf@ds4.des.no> <4B84C02A.9010001@sasktel.net>
next in thread | previous in thread | raw e-mail | index | archive | help
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!
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4B861448.2040207>