I am uncertain by what you mean by “fixing the build system to load with regular tools”. Linking leads to a Duplicate Symbols error (the library comes from rust and ships a duplicate copy of some lib-c {or something along those lines}). This is a bug with the zig compiler as noted here. https://codeberg.org/ziglang/zig/issues/31182 do you mean to suggest that I fix this inside the compiler?
I have thought about this, but I have been told that the compilation pipeline is under heavy development due incremental compilation being added, and it does not, to me, seem trivial to fix it given my lack of knowledge of the zig internals. I figured that it would just be easier to load the library dynamically rather than attempting to fix zig source. I have also have not found any tool or resource that can systematically rename/prefix all the symbols in the source .lib or otherwise fix the duplicate-symbols error.
The dynamic loading code that I use I found at DynLib no longer supports Windows, and what is the intended solution? (Zonion’s post I believe, with the memory leak patched). If you want to know the architecture of how I do dynamic linking in more details it is this:
WrapperStruct
LibWithFunctionsStruct
WrapperStruct (irohny) has an internal LibWithFunctionsStruct (lib_iroh). lib_iroh has the type definitions generated from translate-c being called on the library-header.h, but other than that it is just a list of function pointers that is filled by the following snippet:
var lib = try load_lib.open(alloc, path, lib_name);
errdefer lib.close();
return .{
.endpoint_bind = lib.lookup(*const fn ([*c]const EndpointConfig_t, ?*SocketAddrV4_t, ?*SocketAddrV6_t, [*c]const ?*Endpoint_t) EndpointResult_t, "endpoint_bind") orelse return error.FunctionNotFound,
.endpoint_free = lib.lookup(*const fn (?*Endpoint_t) void, "endpoint_free") orelse return error.FunctionNotFound,
// and other functions too
};
WrapperStruct exports the type definitions from lib_iroh and has wrappers defined for the various functions that end up being used.
pub fn endpoint_default(WS: *WrapperStruct) ?*Endpoint_t {
return WS.lib.endpoint_default();
}
pub fn endpoint_free(WS: *WrapperStruct, ep: ?*Endpoint_t) void {
return WS.lib.endpoint_free(ep);
}
I can paste the entirety of my source code here if you think it would be helpful. WrapperStruct is imported simply as “iroh” in the mainfile which I have already shown.
Thanks for responding btw; it’s nice to know that people read these. Any ideas are appreciated if you have them (I have pretty much run out myself)