linux - shared library not found during compilation -


so got several shared libraries trying permanently install on ubuntu system having difficulty it.

i want install libraries , headers in separate folder under /usr/local/lib , /usr/local/include (for example folder named agony) clean , removing them require delete folders. looks this:

/usr/local/lib/agony/libbtigpio.so /usr/local/lib/agony/libbtidsp.so ...  /usr/local/include/agony/gpio.h /usr/local/include/agony/dsp.h ... 

and added file here /etc/ld.so.conf.d/agony.conf include line describing path library folder:

$ cat /etc/ld.so.conf.d/agony.conf /usr/local/lib/agony 

and perform sudo ldconfig update library database. double check if library found ldconfig -p | grep bti* , see following result:

$ ldconfig -p | grep bti     ...      libbtigpio.so (libc6,x86-64) => /usr/local/lib/agony/libbtigpio.so     libbtidsp.so (libc6,x86-64) => /usr/local/lib/agony/libbtidsp.so     ... 

at point should able use libraries without specifying library path. when attempt compile application without providing library path (-l) fails. however, when supply gcc library path ex:

gcc source.c -l /usr/local/lib/agony output -lbtigpio -lbtidsp  

it works!!

i don't want use ld_library_path environment variable because library going used everywhere on system , don't want other compilers worry providing ld_library_path.

what doing wrong here?

at point should able use libraries without specifying library path

here lies confusion.

you have built shared library libbtigpio.so (just sticking one), placed in /usr/local/lib/agony, , updated ldconfig database accordingly.

the effect of when run program has been linked libbtigpio dynamic linker (/lib/x86_64-linux-gnu/ld-2.21.so, or similar) know load library process , not need tell setting ld_library_path in environment.

however, haven't done affects list of default library search directories hardwired build of gcc, passes linker (/usr/bin/ld) when link program libbtigpio in first place.

that list of default search directories find if verbose build of program - gcc -v ... - , pick out value of library_path output, e.g.

library_path=/usr/lib/gcc/x86_64-linux-gnu/5/:\         /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/:\         /usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/:\         /lib/x86_64-linux-gnu/:\         /lib/../lib/:\         /usr/lib/x86_64-linux-gnu/:\         /usr/lib/../lib/:\         /usr/lib/gcc/x86_64-linux-gnu/5/../../../:\         /lib/:\         /usr/lib 

/usr/local/lib/agony not 1 of , make 1 of have build gcc source yourself. hence, in order link program libbtigpio still need tell ld find -l/usr/local/lib/agony -lbtigpio.


Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -