Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

regd shared library not able to linked

Posted on 2003-11-03
9
Medium Priority
?
274 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
7 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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 500 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 500 total points
ID: 9686001
gcc -v ...
will tell you all the defaults used by gcc
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
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…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…

772 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