linux dynamic libraries
I want to create Makefile that builds a .so library, but I only find examples that create .a libraries. So,
Does someone of you know which are the main differences between a .so and a .a library? Are they the same thing? thanks. cheers, Aizkorri. |
Take a look at this example that builds a shared object and uses that so to build an executable.
$ cat loadtest.c Code:
#include <stdio.h> Code:
#include <stdio.h> Code:
void test(); $ cat makefile Code:
all: testme |
Thanks a lot, now I have a little idea on how to build a .so, but I'm getting this output when doing "make" and ./testme:
> ls >loadtest.c Makefile test.c test.h >make >gcc -c loadtest.c >gcc -c test.c >gcc -shared -o libtest.so test.o >gcc -o testme loadtest.o -L. -ltest >ls >libtest.so loadtest.c loadtest.o Makefile test.c test.h testme >test.o >./testme >./testme: error while loading shared libraries: libtest.so: cannot >open shared object file: No such file or directory But libtest.so it there!?!? Do you know what is wrong?. (I think the code you gave me is ok) cheers, Aizkorri. |
The dynamic linker cannot find your shared object. You either need to put the directory in /etc/ld.so.conf and run ldconfig, or modify you LD_LIBRARY_PATH environment variable.
Since you are just testing I recommend the env variable. Code:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path/to/shared/object |
Thank you, now it's working.
|
All times are GMT -5. The time now is 07:10 PM. |