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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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.
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
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.
OWASP: Threats Fundamentals

Learn the top ten threats that are present in modern web-application development and how to protect your business from them.

ahoffmannCommented:
you need to specify where to find libsamp.*, like
  gcc capp.c-L/path/where/lib/installed -lsamp

ldconfig is for runtime only
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.
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("...");

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ahoffmannCommented:
gcc -v ...
will tell you all the defaults used by gcc
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux OS Dev

From novice to tech pro — start learning today.