Skip to content

Commit

Permalink
x2
Browse files Browse the repository at this point in the history
  • Loading branch information
JuergenReppSIT committed Oct 26, 2024
1 parent c1f4dc3 commit da610a0
Show file tree
Hide file tree
Showing 13 changed files with 67 additions and 0 deletions.
Empty file added dlopen-autotools/AUTHORS
Empty file.
Empty file added dlopen-autotools/COPYING
Empty file.
Empty file added dlopen-autotools/ChangeLog
Empty file.
Empty file added dlopen-autotools/INSTALL
Empty file.
14 changes: 14 additions & 0 deletions dlopen-autotools/Makefile.am
Original file line number Diff line number Diff line change
@@ -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
Empty file added dlopen-autotools/NEWS
Empty file.
Empty file added dlopen-autotools/README
Empty file.
6 changes: 6 additions & 0 deletions dlopen-autotools/configure.ac
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
AC_INIT([MyLib], [1.0], [[email protected]])
AM_INIT_AUTOMAKE
AC_PROG_CC
LT_INIT
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
23 changes: 23 additions & 0 deletions dlopen-autotools/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include <stdio.h>
#include <dlfcn.h>

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;
}
6 changes: 6 additions & 0 deletions dlopen-autotools/myfu.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include <stdio.h>

// Define the external function
void myfu() {
printf("Hello from so myfu!\n");
}
6 changes: 6 additions & 0 deletions dlopen-autotools/myfu1.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include <stdio.h>

// Define the external function
void myfu() {
printf("Hello from so1 myfu!\n");
}
6 changes: 6 additions & 0 deletions dlopen-autotools/myfu2.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include <stdio.h>

// Define the external function
void myfu() {
printf("Hello from so2 myfu!\n");
}
6 changes: 6 additions & 0 deletions dlopen-autotools/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
aclocal
autoconf
automake --add-missing
./configure --disable-dependency-tracking
gmake -j
./main

0 comments on commit da610a0

Please sign in to comment.