-
-
Notifications
You must be signed in to change notification settings - Fork 542
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
Dynamic loading of modules doesn't work.
To Reproduce
main.c
file:
#include <stdio.h>
#include <dlfcn.h>
#include "flecs.h"
ecs_os_dl_t my_api_dlopen(const char *libname) {
void *handle = dlopen(libname, RTLD_NOW|RTLD_LOCAL);
if (!handle) {
fprintf(stderr, "%s\n", dlerror());
exit(EXIT_FAILURE);
}
return (ecs_os_dl_t)handle;
}
ecs_os_proc_t my_api_dlproc(ecs_os_dl_t lib, const char *procname) {
return (ecs_os_proc_t)dlsym((void*)lib, procname);
}
void my_api_dlclose(ecs_os_dl_t lib) {
dlclose((void*)lib);
}
int main(void) {
ecs_os_api.dlopen_ = my_api_dlopen;
ecs_os_api.dlproc_ = my_api_dlproc;
ecs_os_api.dlclose_ = my_api_dlclose;
ecs_world_t *ecs = ecs_init();
ecs_import_from_library(ecs, "window", NULL);
ecs_app_run(ecs, &(ecs_app_desc_t){});
ecs_fini(ecs);
}
window.c
file:
#include "flecs.h"
void WindowImport(ecs_world_t *world) {
ECS_MODULE(world, Window);
}
Get an fatal error:
yahton@debian:~/atomix$ ./nob && ./build/main
[INFO] directory `./build` already exists
[INFO] directory `./build/libs` already exists
[INFO] directory `./build/modules` already exists
[INFO] CMD: cc -Wall -Wextra -shared -fPIC -o ./build/libs/librgfw.so -x c -DRGFW_IMPLEMENTATION -DRGFW_OPENGL ./include/RGFW.h -lX11 -lXrandr -lGL
[INFO] CMD: cc -Wall -Wextra -I./include -L./build/libs -shared -fPIC -o ./build/modules/libwindow.so ./modules/window.c -lflecs -lrgfw
[INFO] CMD: cc -Wall -Wextra -I./include -L./build/libs -o ./build/main main.c -lflecs
fatal: flecs.c: 27215: assert(e != 0): Window (MODULE_UNDEFINED)
./build/libs/libflecs.so(+0x57931) [0x7fcbceff1931]
./build/libs/libflecs.so(ecs_printv_+0xe5) [0x7fcbcf00f06e]
./build/libs/libflecs.so(ecs_log_+0xc4) [0x7fcbcf00f277]
./build/libs/libflecs.so(ecs_assert_log_+0x101) [0x7fcbcf00fae4]
./build/libs/libflecs.so(ecs_import+0x2a5) [0x7fcbcf0158ca]
./build/libs/libflecs.so(ecs_import_from_library+0x57a) [0x7fcbcf015f0e]
./build/main(+0x12f1) [0x5647cf6c82f1]
/lib/x86_64-linux-gnu/libc.so.6(+0x2724a) [0x7fcbcedc524a]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0x85) [0x7fcbcedc5305]
./build/main(+0x1121) [0x5647cf6c8121]
Aborted
Expected behavior
No assert fatal error :/
Additional context
Debian GNU/Linux 12 (bookworm) x86_64
My thoughts
I am new to ECS, but it seems that ECS_MODULE
does not register module entity, even though ecs_import
expects it.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working