diff --git a/dlopen-autotools/AUTHORS b/dlopen-autotools/AUTHORS new file mode 100644 index 000000000..e69de29bb diff --git a/dlopen-autotools/COPYING b/dlopen-autotools/COPYING new file mode 100644 index 000000000..e69de29bb diff --git a/dlopen-autotools/ChangeLog b/dlopen-autotools/ChangeLog new file mode 100644 index 000000000..e69de29bb diff --git a/dlopen-autotools/INSTALL b/dlopen-autotools/INSTALL new file mode 100644 index 000000000..e69de29bb diff --git a/dlopen-autotools/Makefile.am b/dlopen-autotools/Makefile.am new file mode 100644 index 000000000..1dd8c92c0 --- /dev/null +++ b/dlopen-autotools/Makefile.am @@ -0,0 +1,14 @@ +lib_LTLIBRARIES = libmyfu1.la +libmyfu1_la_SOURCES = myfu1.c +libmyfu1_la_CFLAGS = -fPIC +libmyfu1_la_LDFLAGS = -version-info 1:0:0 -rpath /usr/local/lib +lib_LTLIBRARIES += libmyfu2.la +libmyfu2_la_SOURCES = myfu2.c +libmyfu2_la_CFLAGS = -fPIC +libmyfu2_la_LDFLAGS = -version-info 1:0:0 -rpath /usr/local/lib + +main_LDADD = libmyfu1.la libmyfu2.la -ldl +bin_PROGRAMS = main +main_SOURCES = main.c +main_LDADD += libmyfu1.la +main_LDADD += libmyfu2.la diff --git a/dlopen-autotools/NEWS b/dlopen-autotools/NEWS new file mode 100644 index 000000000..e69de29bb diff --git a/dlopen-autotools/README b/dlopen-autotools/README new file mode 100644 index 000000000..e69de29bb diff --git a/dlopen-autotools/configure.ac b/dlopen-autotools/configure.ac new file mode 100644 index 000000000..993ce0026 --- /dev/null +++ b/dlopen-autotools/configure.ac @@ -0,0 +1,6 @@ +AC_INIT([MyLib], [1.0], [juergen_repp@web.de]) +AM_INIT_AUTOMAKE +AC_PROG_CC +LT_INIT +AC_CONFIG_FILES([Makefile]) +AC_OUTPUT diff --git a/dlopen-autotools/main.c b/dlopen-autotools/main.c new file mode 100644 index 000000000..468b781d2 --- /dev/null +++ b/dlopen-autotools/main.c @@ -0,0 +1,23 @@ +#include +#include + +void myfu() { + printf("Hello from main myfu!\n"); +} + + +int main() { + void *handle; + handle = dlopen("libmyfu2.so", RTLD_NOW); + myfu(); + void (*myfu)() = (void (*)()) dlsym(handle, "myfu"); + char *error = dlerror(); + if (error) { + fprintf(stderr, "Error finding symbol 'myfu': %s\n", error); + dlclose(handle); + return 1; + } + printf("Calling myfu:\n"); + myfu(); + return 0; +} diff --git a/dlopen-autotools/myfu.c b/dlopen-autotools/myfu.c new file mode 100644 index 000000000..0d0f7aa3f --- /dev/null +++ b/dlopen-autotools/myfu.c @@ -0,0 +1,6 @@ +#include + +// Define the external function +void myfu() { + printf("Hello from so myfu!\n"); +} diff --git a/dlopen-autotools/myfu1.c b/dlopen-autotools/myfu1.c new file mode 100644 index 000000000..90c94f4c1 --- /dev/null +++ b/dlopen-autotools/myfu1.c @@ -0,0 +1,6 @@ +#include + +// Define the external function +void myfu() { + printf("Hello from so1 myfu!\n"); +} diff --git a/dlopen-autotools/myfu2.c b/dlopen-autotools/myfu2.c new file mode 100644 index 000000000..a2304c843 --- /dev/null +++ b/dlopen-autotools/myfu2.c @@ -0,0 +1,6 @@ +#include + +// Define the external function +void myfu() { + printf("Hello from so2 myfu!\n"); +} diff --git a/dlopen-autotools/run.sh b/dlopen-autotools/run.sh new file mode 100644 index 000000000..15e266aff --- /dev/null +++ b/dlopen-autotools/run.sh @@ -0,0 +1,6 @@ + aclocal + autoconf + automake --add-missing + ./configure --disable-dependency-tracking + gmake -j + ./main