LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 06-28-2011, 12:45 PM   #1
gregorian
Member
 
Registered: Apr 2006
Posts: 509

Rep: Reputation: 34
Program compiled with g++ -L option uses library from /usr/lib


I was unable to compile a program that used libicu42 on Ubuntu 11.04, because Ubuntu 11.04 has only libicu44 and does not have libicu42 installed.

So during compile time I used g++ prog.c -L mylib/ to compile the program. mylib had libicu42 (This library is a shared library and has the .so extension). The program compiled successfully, but when I tried to run it, it failed and complained that it did not find libicu42. So I had to manually install libicu42 in /usr/lib. Then the program worked.

'ldd prog' revealed that it looked for libicu42 in /usr/lib

What was the point of specifying the library path using -L, if the compiled program looked for the library in /usr/lib? It's almost like it was just to satisfy the compiler.
 
Old 06-28-2011, 01:10 PM   #2
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,511

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
The -L option is used for libraries, that are not in your LD_LIBRARY_PATH.

And when you run your program, it will look for the libs in only the
LD_LIBRARY_PATH ( Like /lib:/usr/lib:usr/local/lib:/usr/lib/qt4/lib ).


The package libicu42_4.2.1-3_i386.deb or libicu42_4.2.1-3_amd64.deb
can usually be installed with no conflicts. The library names are
different from other libicu versions.
http://packages.ubuntu.com/maverick/libicu42

..
 
1 members found this post helpful.
Old 06-28-2011, 10:12 PM   #3
gregorian
Member
 
Registered: Apr 2006
Posts: 509

Original Poster
Rep: Reputation: 34
Thank you very much, it explains why the program was looking for files in /usr/lib. But what did g++ do with library path I specified, if the program was going to look for the library in the system?
 
Old 06-29-2011, 01:06 AM   #4
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,511

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
When you do e.g. : g++ prog.c -L mylib/ -licudata

.. then the program will link to libicudata.so,
which is usually a link to libicudata.so.42.1 (or libicudata.so.42).


And afterwards running the executable, it will look for the "so name"
= libicudata.so.42 in the LD_LIBRARY_PATH.

A shared library holds information about "real name" (libicudata.so.42.1)
and "so name" (libicudata.so.42).
http://tldp.org/HOWTO/Program-Librar...libraries.html

..
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
64-bit Fedora 9 /usr/lib/librt.so* library linux001 Fedora 1 11-06-2008 06:05 PM
Could anybody please tell how to install [B]mysqlclient.a[/B] library in [B]/usr/lib. krisvamc Linux - Software 5 04-24-2007 04:08 AM
Could anybody please tell how to install [B]mysqlclient.a[/B] library in [B]/usr/lib. krisvamc Ubuntu 7 04-06-2007 05:35 AM
Unable to load dynamic library '/usr/lib/php4/20050606/gd.so' sYs^ Debian 0 04-22-2006 11:39 AM
Compromised? Files "/usr/lib.hwm", "/usr/lib.pwd", "/usr/lib.pwi" Klaus Pforte Linux - Security 4 09-28-2004 11:33 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 12:07 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration