Hi all, I am Swapnil . I wanted to link the shared libraries . Let me tell you how I tried to link them but I am not too sure whether it is correct or not ,I did it according to tutorial . I wrote some libraries by using X lib for instance some header "test.h" in which I wrote function prototypes , a sample program sample.c and body of functions defined in header is in file def.c . As all files are in same dir then there no problem while compiling and running . Next I created Makefile it consists of following statements
all: gcc -lX11 -L/usr/X11R6/lib/ -lncurses -lm sample.c def.c -o try
till here everything is OK after this I modified Makefile to create shared libraries like this
all: gcc -lX11 -L/usr/X11R6/lib/ -lncurses -lm -shared sample.c def.c -o try.so
Shared object created successfully . then I copied header test,h to /usr/include then I copied try.so to /usr/X11R6/lib then I run command #ldconfig to update library database (No errors here) Next If try to compile program , then I get error for functions which I have included
, "sample.c:(.text+0x2a3): undefined reference to `function_name'
If you know something is wrong here or way is to do it this then please tell me immediately I would have been very thankful to them .
Hare Krishna ...Swapnil
On Monday 09 January 2006 17:49, swapnil kamble wrote:
From: swapnil kamble swap.kamble@gmail.com
To: linuxers@mm.ilug-bom.org.in, ilugd@lists.linux-delhi.org, plug-mail@plug.org.in, xorg-arch@lists.x.org
oh boy. Are you going to get flamed or what? :P Cross posting is one thing but this is ... i just don't know what to say :| May God be with you!
Anyway, with regards to your problem. Have you actually tried linking to the shared library that you have created? try.so? (your naming convention sucks btw. use the right naming convention).
gcc foo.c -o bar.bin -ltry
On Tue, Jan 10, 2006 at 04:22:25PM +0000, Dinesh Joshi wrote:
gcc foo.c -o bar.bin -ltry
gcc foo.c -o bar.bin /path/to/try.so
With "-ltry", gcc expects to find libtry.a/libtry.so
Nosferatu