regd shared library not able to linked

written a application using gcc compiler and have created
a shared library file. am able to make use of the library if i
mention it during runtime...
but it is not automatically taking the path though i mentioned in config file....
what config i have to update exactly to make this linking
possible...pls help thnks
GoksAsked:
Who is Participating?
 
mtmikeCommented:
If you want your library to be a system library, you have to place it in either /lib or /usr/lib. Usually /usr/local/lib will also work.

This search path can be configured, but that's not recommended. Take a look at the default linker scripts in /usr/lib/ldscripts. The search path is set using SEARCH_DIR("...");
0
 
mtmikeCommented:
As far as I understand you've written, compiled and installed a shared library and have made sure its installation path is in the '/etc/ld.so.conf' dynamic linker configuration file.

You do need to update the cache by invoking 'ldconfig'.

You can also use 'ldconfig -p' to print the contents of the cache.
0
 
GoksAuthor Commented:
thanx for u'r suggestion.

i've run the ldconfig and the ldconfig -p also displays the libfile but still i am not able to link with that library.i am able to link if give the libpath explicitly with -L option but not linking by default. the error i get is:

gcc capp.c -lsamp
/usr/bin/ld: cannot find -lsamp
collect2: ld returned 1 exit status

what might be the problem.

thanx
0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

 
mtmikeCommented:
That's normal.

The library path must be specified explicitly for linking with libraries outside the default search path of the linker (ld).

Note that there are two different linkers: 'ld' combines object files into archives (and is invoked by gcc) and 'ld.so' dynamically links in the needed libraries at runtime.
0
 
ahoffmannCommented:
you need to specify where to find libsamp.*, like
  gcc capp.c-L/path/where/lib/installed -lsamp

ldconfig is for runtime only
0
 
GoksAuthor Commented:
actually i dont want to use -L option or environment variables such as LD_LIBRARY_PATH i want to use it like std libraries such as -lpthread r -lm.

in all that i've searched it's given that it can be achieved by adding the libpath to /etc/ld.so.conf and executing ldconfig but for me even after doing that i am not able to link to the library by simply specifying -lsamp on the command line.

i dont know how to proceed with that.
0
 
ahoffmannCommented:
gcc -v ...
will tell you all the defaults used by gcc
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.