Solved

regd shared library not able to linked

Posted on 2003-11-03
9
255 Views
Last Modified: 2010-04-22
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
0
Comment
Question by:Goks
  • 3
  • 2
  • 2
9 Comments
 
LVL 5

Expert Comment

by:mtmike
ID: 9670336
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
 

Author Comment

by:Goks
ID: 9677483
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
 
LVL 5

Expert Comment

by:mtmike
ID: 9677611
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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 51

Expert Comment

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

ldconfig is for runtime only
0
 

Author Comment

by:Goks
ID: 9684303
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
 
LVL 5

Accepted Solution

by:
mtmike earned 125 total points
ID: 9685554
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
 
LVL 51

Assisted Solution

by:ahoffmann
ahoffmann earned 125 total points
ID: 9686001
gcc -v ...
will tell you all the defaults used by gcc
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now