Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Linking problem

Posted on 2002-04-12
5
Medium Priority
?
193 Views
Last Modified: 2010-04-22
Hello.

While trying to check why my ./configure script cannot find my libraries,
I found this really confusing problem. I've got a libutil library in /usr/local/lib. When I compile a program

gcc -o test test.cpp -lutil -L/usr/local/lib

it goes just fine. But when instead i export LD_LIBRARY_PATH=/usr/local/lib and remove -L option, it fails (and also fails when ./configure checks for libraries, as I've seen in config.log). I've tried to putj /usr/local/lib in ld.so.conf and run ldconfig with no results.

My system is RH 7.2
0
Comment
Question by:Robson
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 4

Author Comment

by:Robson
ID: 6936429
I solved it!!! My problems were caused by my library name: libutil, which was exactly the same as one of standard system libraries. After renaming it to libfoo_util all goes fine!

And now: first expert who explains why one should not create librares named as standard libraries and why compilation worked with -L option will get at least B grade (I already know it, but I cannot pass points to myself :-)
0
 
LVL 4

Expert Comment

by:IainHere
ID: 6937076
It worked because the system library libutil is in /usr/lib or similar.  The first directory searched is the one specified by -L (and in order, too).  You shouldn't use standard names for the exact reason you posted this question.

More importantly, post a request in CS to have this question PAQ'd, and refund your points (with a link to this question).  Since you answered it yourself, you don't need pay for it.
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 6938545
ld does not use LD_LIBRARY_PATH for searching libraries (except Sun's bundled /usr/ccs/bin/ld)
So  gcc -o test test.cpp -lutil -L/usr/local/lib
works fine 'cause you specified a path to the libutil with -L.

When you omit -L, the default settings of library search pathes apply, and that contains /lib and /usr/lib where it finds libutil system library (if installed).

Check with gcc -v ...
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 6940320
Points refunded and placed in PAQ.

Computer101
E-E Moderator
0
 
LVL 4

Author Comment

by:Robson
ID: 6940321
Thanks IainHere! I'll do that.

To ahoffmann: setting LD_LIBRARY_PATH (after rewriting /etc/ld.so.conf) was my first act of desperation. Second act was tracking linking process with 'strace' :-) That's how I found that ld loads /usr/lib/libutil.so instead of /usr/local/lib/libutil.so

0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

610 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