UNIX Socket FAQ

A forum for questions and answers about network programming on Linux and all other Unix-like systems

You are not logged in.

#1 2011-04-09 02:34 AM

nithesh
Member
Registered: 2011-04-09
Posts: 6

linking

Hi,

i have build a so file libtest.so in a particular folder /root/xyz.

Normally while linking i would use -L /root/xyz -ltest option.

But read article about ldconfig and inserted my path in ld.so.conf.
executed ldconfig comand.

while linking ie. (gcc sample.cpp -o sample -ltest) it
gives
/usr/bin/ld: cannot find -ltest
error

is there anything missing.

Regards,

Offline

#2 2011-04-09 04:44 PM

RobSeace
Administrator
From: Boston, MA
Registered: 2002-06-12
Posts: 3,829
Website

Re: linking

You ran "ldconfig" as root after changing "/etc/ld.so.conf"?  Did the library exist in that directory at the time you ran "ldconfig"?  Because, you need to re-run ldconfig every time you change the library, to update the cache...

Offline

#3 2011-04-10 07:53 AM

nithesh
Member
Registered: 2011-04-09
Posts: 6

Re: linking

my libtest.so is in /root/Samples.

added the path to /etc/ld.so.conf.
and then compiled my test exe. it gave error saying cannot find -ltestlib.

when i moved the so from /root/Samples to /usr/lib and then did ldconfig it work.

how to configure it to search for /root/Samples.

Regards,
nithesh

Offline

#4 2011-04-10 04:06 PM

RobSeace
Administrator
From: Boston, MA
Registered: 2002-06-12
Posts: 3,829
Website

Re: linking

Oh, I bet I know the problem: "/root" is only readable by user root, I bet...  So, if you're compiling as non-root, it wouldn't have permission to access the library...  Put it somewhere else, like "/usr/local/lib" or something, and make sure the permissions are set so everyone can access it...

Offline

#5 2011-04-11 10:37 AM

nithesh
Member
Registered: 2011-04-09
Posts: 6

Re: linking

Yes u r right i change the permission for the root folder and it worked.

Regards,

Nithesh

Offline

#6 2011-04-11 12:00 PM

RobSeace
Administrator
From: Boston, MA
Registered: 2002-06-12
Posts: 3,829
Website

Re: linking

Well, I wouldn't recommend allowing anyone to access root's home dir...  That's very dangerous on a multi-user system...  There's a reason it was set as it was...  You'd be much wiser to put libraries someplace logical where they belong, like "/usr/local/lib", rather than under root's home directory...

Offline

#7 2011-04-12 04:59 AM

nithesh
Member
Registered: 2011-04-09
Posts: 6

Re: linking

Yes you are right. was just checking the functionality of ldconfig. 

Thanks
Nithesh

Offline

#8 2011-08-16 11:08 PM

developwyo
Member
Registered: 2011-08-16
Posts: 6

Re: linking

RobSeace wrote:

Well, I wouldn't recommend allowing anyone to access root's home dir...  That's very dangerous on a multi-user system...  There's a reason it was set as it was...  You'd be much wiser to put libraries someplace logical where they belong, like "/usr/local/lib", rather than under root's home directory...

Have any of you other glorious people found this out the hard way when you were ultra noobs? Mark me down...

Offline

Board footer

Powered by FluxBB