chore: reorg
This commit is contained in:
21
__ffi/live-reload-rust/load-shared.c
Normal file
21
__ffi/live-reload-rust/load-shared.c
Normal file
@@ -0,0 +1,21 @@
|
||||
#include <dlfcn.h>
|
||||
#include <stdio.h>
|
||||
|
||||
typedef void (*greet_t)(const char *name);
|
||||
|
||||
int main(void) {
|
||||
// this was `./libmain.so`
|
||||
void *lib = dlopen("./libgreet.so", RTLD_LAZY);
|
||||
if (!lib) {
|
||||
fprintf(stderr, "failed to load library\n");
|
||||
return 1;
|
||||
}
|
||||
greet_t greet = (greet_t) dlsym(lib, "greet");
|
||||
if (!lib) {
|
||||
fprintf(stderr, "could not look up symbol 'greet'\n");
|
||||
return 1;
|
||||
}
|
||||
greet("venus");
|
||||
dlclose(lib);
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user