I read it afterwards, i got it to work, my mistake there, i did read the wrong one, however, only the example from the website i linked works, when i try to change the file names to use my library and so on, it gives me the same error, very strange, essentially i did a copy and paste, here's what i have
Code:
/* nlcnt.c -- demonstrate dynamic loading and
use of the "hello" routine */
/* Need dlfcn.h for the routines to
dynamically load libraries */
#include <dlfcn.h>
#include <stdlib.h>
#include <stdio.h>
/* Note that we don't have to include "libhello.h".
However, we do need to specify something related;
we need to specify a type that will hold the value
we're going to get from dlsym(). */
/* The type "simple_demo_function" describes a function that
takes no arguments, and returns no value: */
typedef void (*simple_demo_function)(void);
int main(void) {
const char *error;
void *module;
simple_demo_function demo_function;
/* Load dynamically loaded library */
module = dlopen("mapping.so", RTLD_LAZY);
if (!module) {
fprintf(stderr, "Couldn't open mapping.so: %s\n",
dlerror());
exit(1);
}
/* Get symbol */
dlerror();
demo_function = dlsym(module, "my_cnt");
if ((error = dlerror())) {
fprintf(stderr, "Couldn't find hello: %s\n", error);
exit(1);
}
/* Now call the function in the DL library */
(*demo_function)();
/* All done, close things cleanly */
dlclose(module);
return 0;
}
Code:
/* mapping.c - demonstrate library use. */
#include <stdio.h>
void my_cnt(void) {
printf("test\n");
}
Code:
/* mapping.h - demonstrate library use. */
void my_cnt(void);
and i compile these with the follow commands
cc -fPIC -Wall -g -c mapping.c
cc -g -shared -Wl,-soname,mapping.so.0 \-o mapping.so.0.0 mapping.o -lc
/sbin/ldconfig -n .
ln -sf mapping.so.0 mapping.so
cc -Wall -g -c nlcnt.c
cc -g -o nlcnt nlcnt.o -ldl
LD_LIBRARY_PATH="." ./nlcnt
any suggestions?