how external dll reference occurs in linux
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>
.
精彩评论