LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 09-18-2004, 11:52 AM   #1
OldGuru
LQ Newbie
 
Registered: Sep 2004
Posts: 3

Rep: Reputation: 0
Compiling C code with libraries


Hello,
I'm pretty new to C programming on Linux. For my first program on my system, I have installed 2 libraries libusb abd libftdi. Both libraries are located under: /usr/local/lib/
This direcotry contains:
drwxr-xr-x 2 root root 104 Sep 27 2003 netscape
-rwxr-xr-x 1 root root 35353 Sep 16 14:01 libusb-0.1.4.4.0
lrwxrwxrwx 1 root root 16 Sep 16 14:01 libusb-0.1.4 -> libusb-0.1.4.4.0
lrwxrwxrwx 1 root root 16 Sep 16 14:01 libusb -> libusb-0.1.4.4.0
lrwxrwxrwx 1 root root 19 Sep 18 08:32 libusb.so -> libusb-0.1.so.4.3.0
-rwxr-xr-x 1 root root 710 Sep 18 08:32 libusb.la
-rw-r--r-- 1 root root 30816 Sep 18 08:32 libusb.a
-rwxr-xr-x 1 root root 32252 Sep 18 08:32 libusb-0.1.so.4.3.0
lrwxrwxrwx 1 root root 19 Sep 18 08:32 libusb-0.1.so.4 -> libusb-0.1.so.4.3.0
-rwxr-xr-x 1 root root 13814 Sep 18 12:03 libftdi.so.0.3.0
-rwxr-xr-x 1 root root 700 Sep 18 12:03 libftdi.la
lrwxrwxrwx 1 root root 16 Sep 18 12:03 libftdi.so.0 -> libftdi.so.0.3.0
lrwxrwxrwx 1 root root 16 Sep 18 12:03 libftdi.so -> libftdi.so.0.3.0
-rw-r--r-- 1 root root 8118 Sep 18 12:03 libftdi.a

In my program I use both libraries.
To compile, I use the following command: gcc -lftdi -lusb -o test test.c -L/usr/local/lib
The program compiles fine.

When I execute the program, I get the following error:
./test: error while loading shared libraries: libftdi.so.0: cannot open shared object file: No such file or directory

I checked the this object exists as well as its properties and it all looks right to me.

Any idea why would I get this error and how can I resolve it?

Thank you in advance,
OG.
 
Old 09-18-2004, 01:00 PM   #2
Phyrexicaid
Member
 
Registered: Aug 2004
Location: JHB - South Africa
Distribution: Kubuntu 7.04; openSUSE 10.1
Posts: 176

Rep: Reputation: 30
Try searching the forums for "problems with gcj" I know that is the gcc-java compiler but maybe Komakino's suggestion about creating a symlink will help you.

Seemed to be a problem with Suse 9.1, don't know what distro you're using though.

Not the greatest advice, but hope that helps,
Dave
 
Old 09-18-2004, 01:20 PM   #3
OldGuru
LQ Newbie
 
Registered: Sep 2004
Posts: 3

Original Poster
Rep: Reputation: 0
Thanks, I'll look into it.
Actually, I'm using Suse 8.0,
uname -a gives: Linux linux 2.4.18-4GB #1 Mon Aug 16 15:22:55 UTC 2004 i686 unknown

Thanks again,
Ronen.
 
Old 09-18-2004, 01:22 PM   #4
Phyrexicaid
Member
 
Registered: Aug 2004
Location: JHB - South Africa
Distribution: Kubuntu 7.04; openSUSE 10.1
Posts: 176

Rep: Reputation: 30
That's odd.

I had no problems with gcc or gcj when I was running 8.2, why not try and get an update? Although thats a little extreme to fix a small prob ;o)

Dave.
 
Old 09-18-2004, 07:06 PM   #5
OldGuru
LQ Newbie
 
Registered: Sep 2004
Posts: 3

Original Poster
Rep: Reputation: 0
Finally... I found the solution...
I had to read "shared libraries - HOWTO" and run ldconfig on the new library that I installed (although it looks like it was properly installed).
That solved it!! No more issues. The code runs with no errors anymore (for now ).

Thanks for the help so far,
OG.
 
  


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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
compiling development libraries deadlyhead Linux - Newbie 3 06-05-2005 03:52 AM
libraries compiling into /usr/lib acidjuice Slackware 4 05-14-2005 05:53 AM
Where does compiler look for libraries when compiling Evolution? dhave Linux - Software 2 01-18-2005 11:22 AM
What is the magic trick for compiling libraries? jmorse Linux - General 0 06-30-2004 01:24 PM
compiling with shared and static libraries jinksys Programming 1 11-22-2003 04:54 AM


All times are GMT -5. The time now is 03:17 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration