Dynamic Linking Library Problem Using GCC
Olivier Rochecouste
olivier.rochecouste@irisa.fr
Mon Dec 13 15:30:00 GMT 2004
Hi Cheok,
I'm not an expert but I think you should make a symlink to your shared library:
"ln -s libmean.so.1.0.1 libmean.so"
ld should be able to find the .so now
--
Olivier
> Hi,
>
> I read through the tutorial
> http://www.adp-gmbh.ch/cpp/gcc/create_lib.html in
> buidling dynamic library using gcc. It is interesting.
> However, after following the steps inside the
> tutorial, it doesn't work in my system.
>
> Here is the sequence of steps which I had performed:
>
> [yccheok@localhost project]$ ls -al
> total 28
> drwxrwxr-x 2 yccheok yccheok 4096 Dec 13 01:16 .
> drwx------ 65 yccheok yccheok 12288 Dec 13 00:58 ..
> -rw-rw-r-- 1 yccheok yccheok 56 Dec 13 00:48
> calc_mean.c
> -rw-rw-r-- 1 yccheok yccheok 29 Dec 13 00:48
> calc_mean.h
> -rw-rw-r-- 1 yccheok yccheok 224 Dec 13 00:49
> main.c
> [yccheok@localhost project]$ gcc -c -fPIC calc_mean.c
> -o calc_mean.o
> [yccheok@localhost project]$ gcc -shared
> -Wl,-soname,libmean.so.1 -o
> libmean.so.1.0.1 calc_mean.o
> [yccheok@localhost project]$ gcc main.c -o
> dynamically_linked -L. -lmean
> /usr/bin/ld: cannot find -lmean
> collect2: ld returned 1 exit status
> [yccheok@localhost project]$ ls -al
> total 40
> drwxrwxr-x 2 yccheok yccheok 4096 Dec 13 01:17 .
> drwx------ 65 yccheok yccheok 12288 Dec 13 00:58 ..
> -rw-rw-r-- 1 yccheok yccheok 56 Dec 13 00:48
> calc_mean.c
> -rw-rw-r-- 1 yccheok yccheok 29 Dec 13 00:48
> calc_mean.h
> -rw-rw-r-- 1 yccheok yccheok 908 Dec 13 01:16
> calc_mean.o
> -rwxrwxr-x 1 yccheok yccheok 4349 Dec 13 01:16
> libmean.so.1.0.1
> -rw-rw-r-- 1 yccheok yccheok 224 Dec 13 00:49
> main.c
> [yccheok@localhost project]$
>
> Can you please advice on why the ld cannot find the
> mean library. Do I need to prior perform anything with
> ldconfig before i dynamic linked my main application
> with the mean library?
>
> Thank you!
>
> -cheok
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
More information about the Gcc-help
mailing list