I’m building a shared library, this shared library has a bunch of c code including imgui, that calls internally sscanf that for some reason crashes if I attach a .root_source_file = b.path(“file.zig“) to the library root_module, the file.zig is empty by the way, commening this line soves the issue, but I need that file to be included…
So I’m trying to make a small repro, to do a bug report but my repro calls the ucrt_sscanf while main main project calls mingw_sscanf and I don’t know why or how to do change the implementations.
I have a bootstrap.exe, core.dll and a game.dll, the bootstrap loads both core and game, the core.dll contains all game’s dependencies and static variables, game, contains my game logic, and because of how I setup things game can be hot-reloaded, so thats my main goal.
Problem is: calling a function in core that calls sscanf from causes a crash inside atexit function, the issue happens only if core has a mix of zig and c/cpp code, isolating one of the other is fine, and like I mention before doing this causes the sscanf function to change implemetations, so my guess is that something is forcing zig to include 2 crts maybe at the same time
Edit: calling it from bootstrap.exe of game.dll casues the crash
Just an idea, but are you telling Zig to build for the same target as the c/cpp code? Based on the error, it seems like your c/c++ is using mingw, while the zig is defaulting to a different c runtime. Try using the mingw target for your zig code.
I’m using the same ResolvedTarget for everything, dispite that zig build system does something weird if I include raylib + root_source_file (didn’t try other combinations) in the same compile step, heres my build script
the “file.zig” in the build is actually called “expo.zig“ is not empty, but even if was, having the root_source_file assigned is what causing the issue. If I build 2 different dlls one for the c (core.dll) and other for the zig (core2.dll) the issue desapears.