LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Compiling C code with libraries (https://www.linuxquestions.org/questions/programming-9/compiling-c-code-with-libraries-232170/)

OldGuru 09-18-2004 11:52 AM

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.

Phyrexicaid 09-18-2004 01:00 PM

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

OldGuru 09-18-2004 01:20 PM

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.

Phyrexicaid 09-18-2004 01:22 PM

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.

OldGuru 09-18-2004 07:06 PM

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.


All times are GMT -5. The time now is 02:06 PM.