Reputation: 717
I need to build a hello world function into a dynamic library. I'm coding in C language on linux. Can anyone help with some sample code doing that? And also for linking against the generated library?
Upvotes: 0
Views: 1005
Reputation: 2909
Dig up a copy of libtool and use it. It knows a LOT of the (disturbingly variable) details of how to compile and link a shared library on a large number of operating systems.
http://www.gnu.org/software/libtool/manual/html_node/Using-libtool.html
Upvotes: -2
Reputation: 4589
First compile files to object code
$gcc -Wall -fPIC -c test1.c test2.c
-fPIC
means that it will produce position independent code.
$gcc -shared -o libtest.so test1.o test2.o
Upvotes: 3