public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Dynamic Linking Library Problem Using GCC
@ 2004-12-13 15:18 Cheok Yan Cheng
  2004-12-13 15:30 ` Olivier Rochecouste
  0 siblings, 1 reply; 3+ messages in thread
From: Cheok Yan Cheng @ 2004-12-13 15:18 UTC (permalink / raw)
  To: gcc-help

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 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Dynamic Linking Library Problem Using GCC
  2004-12-13 15:18 Dynamic Linking Library Problem Using GCC Cheok Yan Cheng
@ 2004-12-13 15:30 ` Olivier Rochecouste
  0 siblings, 0 replies; 3+ messages in thread
From: Olivier Rochecouste @ 2004-12-13 15:30 UTC (permalink / raw)
  To: gcc-help

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 
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: Dynamic Linking Library Problem Using GCC
@ 2004-12-13 16:32 Martin York
  0 siblings, 0 replies; 3+ messages in thread
From: Martin York @ 2004-12-13 16:32 UTC (permalink / raw)
  To: Olivier Rochecouste, gcc-help

 
Hi Cheok,

By specifying the argument:
-Wl,-soname,libmean.so.1

The executable will search for 'libmean.so.1' file at runtime to load.
But this does not exist. So you would also need to create a link from
your actual library to this name.

So in addition to the suggestion by 'Oliver' you will need to add
"ln -s libmean.so.1.0.1 libmean.so.1"


I am not sure why you are setting the 'soname' to a different name to
the resulting library, this seems dangerous to me (unless you can always
guarantee binary compatibility between all versions of libmean.so.1.X).

The general rule for building shared libs I use is:

g++ -shared -Wl,-soname,lib<LIBNAME>.so.<MAJ_VER>.<MIN_VER> -o
lib<LIBNAME>.so.<MAJ_VER>.<MIN_VER>  <FILES>
ln -s lib<LIBNAME>.so.<MAJ_VER>.<MIN_VER> lib<LIBNAME>.so.<MAJ_VER>
ln -s lib<LIBNAME>.so.<MAJ_VER> lib<LIBNAME>.so






-----Original Message-----
From: gcc-help-owner@gcc.gnu.org [mailto:gcc-help-owner@gcc.gnu.org] On
Behalf Of Olivier Rochecouste
Sent: 13 December 2004 10:30
To: gcc-help@gcc.gnu.org
Subject: Re: Dynamic Linking Library Problem Using GCC

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
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2004-12-13 16:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-12-13 15:18 Dynamic Linking Library Problem Using GCC Cheok Yan Cheng
2004-12-13 15:30 ` Olivier Rochecouste
2004-12-13 16:32 Martin York

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).