1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
#include <emscripten/emscripten.h>
#include <assert.h>
#include <stdlib.h>
#include <dlfcn.h>
#include <stdio.h>
int mydata = 0;
void onsuccess(void *user_data, void *handle) {
assert(user_data == &mydata);
printf("onsuccess\n");
int* foo = (int*)dlsym(handle, "foo");
assert(foo);
printf("foo = %d\n", *foo);
assert(*foo == 42);
exit(0);
}
void onerror(void *user_data) {
assert(user_data == &mydata);
printf("onerror %s\n", dlerror());
}
int main() {
emscripten_dlopen("libside.so", RTLD_NOW, &mydata, onsuccess, onerror);
printf("returning from main\n");
return 99;
}
|