libtest demonstrates how to use shared libraries
authorMarkus Bröker <mbroeker@largo.dyndns.tv>
Sat, 13 Dec 2008 17:57:59 +0100
changeset 7 a1aa30f0f904
parent 6 c3dc3eb3b541
child 8 96d16dfe787a
libtest demonstrates how to use shared libraries committer: Markus Bröker <mbroeker@largo.homelinux.org>
libtest/Makefile
libtest/func1.c
libtest/func2.c
libtest/lib/.keep
libtest/main.c
new file mode 100644
--- /dev/null
+++ b/libtest/Makefile
@@ -0,0 +1,24 @@
+     CC = gcc
+ CFLAGS =-Wall -O2 -fPIC
+LDFLAGS = -Llib -ltest
+OBJECTS = func1.o func2.o
+
+.c.o:
+	$(CC) -c $(CFLAGS) -shared $<
+
+all: lib/libtest.so.1.0.1 prog
+
+prog: main.c
+	$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@
+
+lib/libtest.so.1.0.1: $(OBJECTS)
+	$(CC) -shared -Wl,-soname,lib/libtest.so.1 $(OBJECTS) -o $@
+	@echo "Look carefully at this :)"
+	ln -s libtest.so.1.0.1 lib/libtest.so.1
+	ln -s libtest.so.1.0.1 lib/libtest.so
+
+.PHONY: clean
+
+clean:
+	rm -f lib/libtest.*
+	rm -f *.o prog
new file mode 100644
--- /dev/null
+++ b/libtest/func1.c
@@ -0,0 +1,6 @@
+#include <stdio.h>
+
+void func1()
+{
+	printf("Func1: Implement me\n");
+}
new file mode 100644
--- /dev/null
+++ b/libtest/func2.c
@@ -0,0 +1,6 @@
+#include <stdio.h>
+
+void func2()
+{
+	printf("Func2: Implement me\n");
+}
new file mode 100644
new file mode 100644
--- /dev/null
+++ b/libtest/main.c
@@ -0,0 +1,10 @@
+void func1();
+void func2();
+
+int main(int argc, char **argv)
+{
+	func1();
+	func2();
+
+	return 0;
+}