gcc wont use libary in /usr/loacal/...
hello
im writing a program which uses libssh ( http://0xbadc0de.be/wiki/libssh:libssh ), its called sclient (s = student) due to a problem with the ssh server i want to make a modification in the sshlib, therfore i have to (re)build the sshlib myself i decided to make a trivial test-modification on the sshlib before doing any real changes so i can test if the compile/link/build-process works, but i cant even manage to build sclient with trivial changes in sshlib i made the follwoing trivial changes to the sshlib: Code:
added to channels.c Code:
added to libssh.h so my modified sshlib is installed in /usr/local/{include|lib} while the systems original is installed in /usr/{include|lib} Code:
ls /usr/local/lib Code:
ls /usr/local/include/libssh Code:
grep 'returnTwo' /usr/local/include/libssh/libssh.h Code:
snapshot from sclient.c Code:
gcc -I/usr/local/include/ -L/usr/local/lib/ -lssh sclient.c Code:
gcc -I/usr/local/include/ -L/usr/local/lib/ sclient.c how do i make gcc build sclient using the sslib in /usr/local/... ?? thanks for help, skaarj some more system info: Code:
uname -a |
Quote:
I. e. in /usr/lib, rename sshlib.a (or whatever) to sshlib.a.old. Then, symlink sshlib.a in /usr/lib to mysshlib.a (or whatever) in /usr/local/lib. Then, if the linker is looking for sshlib.a, it will still find it in /usr/lib, but it will be symlinked to mysshlib.a in /usr/local/lib... Code:
# mv /usr/lib/sshlib.a /usr/lib/sshlib.a.old |
First of all, install your version into an "innocent" directory (like /home/yourid/yourssh), not into /usr/local/lib.
Second, use 'nm' to verify that the missing 'returnTwoTimes' symbol is indeed defined in your library. |
Quote:
Quote:
Quote:
Code:
nm /usr/local/lib/libssh.so | grep return |
Quote:
Check libssh.a; temporarily rename libssh.la or vice versa, i.e. narrow the choices available to linker. |
Quote:
Code:
nm /usr/local/lib/libssh.a | grep return renaming didnt work either, also gcc -static .... dosent work :( |
Quote:
... I think you need Code:
gcc -I/usr/local/include/ -L/usr/local/lib/ sclient.c -lssh Another idea: Code:
gcc -I/usr/local/include/ sclient.c -o sclient.o |
didnt work either :(
Code:
gcc -I/usr/local/include/ -L/usr/local/lib/ sclient.c -lssh Code:
gcc -I/usr/local/include/ sclient.c -o sclient.o |
Quote:
Code:
gcc -I/usr/local/include/ -c sclient.c -o sclient.o Then Code:
gcc -L/usr/local/lib/ sclient.o -lssh |
Code:
gcc -I/usr/local/include/ -c studclient.c -o sclient.o Code:
gcc -L/usr/local/lib/ sclient.o -lssh |
I tried something similar to what you are doing, although the opposite, and it worked for me.
I typically install my library in /usr/local/lib, but for test purposes I installed it in /usr/lib. Then I modified my library code, then built it and installed it /usr/local/lib. When I built a test app that uses the library, it picked up the one in /usr/local/lib; not the one in /usr/lib. I think the reason for this is with how 'ldconfig' collects a listing of the libraries that it is made aware of. I have a file in /etc/ld.so.conf.d, name libc.conf that specifies the /usr/local/lib directory. So if you do not have a libc.conf file, create it with the following contents: Code:
# libc default configuration Code:
ldconfig Now, I'm off to clean up my /usr/lib folder... |
my /etc/ld.so.conf.d/libc.conf looks like the one you posted .... also running ldconf didnt change anything ...
and: Code:
cat /etc/ld.so.conf |
Rerun the 'ldconfig' (at root) and specify the -v option. I'm curious as to whether your modified library shows up in the list.
Code:
ldconfig -v | grep libssh Code:
/lib/i486-linux-gnu: |
Code:
/lib/i486-linux-gnu: |
I do not know what to say. Just now, I developed a silly shared-object library, and installed it in /usr/lib.
Then I added a new function to the library, and installed the modified library in /usr/local/lib. When I built my test application, I specified the library located in /usr/local/lib, so that I could link without any getting any "unresolved reference" errors. When I ran the application, it automatically loaded the shared-object library in /usr/lib, thus causing the application to abort because it could not reference a symbol (i.e. the function I added). When I re-ran the application by first specifying the LD_LIBRARY_PATH=/usr/local/lib, then it worked. Here's my silly library that I tested with... MyLib.h Code:
#ifndef MY_LIB_H Code:
#include "MyLib.h" Code:
gcc -c MyLib.c Code:
gcc -DMOD -c MyLib.c Code:
#include "MyLib.h" Code:
gcc test.c -L/usr/local/lib -lMyLib |
All times are GMT -5. The time now is 03:07 AM. |