开发者

how external dll reference occurs in linux

开发者 https://www.devze.com 2023-02-25 16:59 出处:网络
I\'m runing an application that uses a library that I created. This sample application is generated through a make file that builds the application as

I'm runing an application that uses a library that I created. This sample application is generated through a make file that builds the application as

LIBNAME=/usr/local/App/lib/libMYLIB.so

$(CC) -o sample sample.o $(LIBNAME)

I'm able to run the application without setting LD_LIBRARY_PATH. Is that expected?

Does using full path in LIBNAME has something to do with it? ldd sample returns (among other entries)

/usr/local/App/lib/libMYLIB.so (0x00002aaaaaaad000)

What ch开发者_C百科anges do I need to do so that without setting LD_LIBRARY_PATH env variable my application shouldn't work. Using -lMyLIB with cc help?

Thanks.


-L/usr/local/App/lib/ -lMYLIB is what you are after.

It might be the case that linking with the full library name sets an "rpath", which is basically a sort of an LD_LIBRARY_PATH that is embedded in the executable. You can check the current value of the rpath (if any) using chrpath <executable>.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号