Replies: 3 comments 3 replies
-
What exactly are julia> Libc.Libdl.dlopen("build/libcimgui") # Path to a local build of libcimgui.so (excluding the extension)
Ptr{Nothing} @0x00000000028db830
julia> libcimgui = "libcimgui"
"libcimgui"
julia> unsafe_string(@ccall libcimgui.igGetVersion()::Cstring)
"1.91.5" But julia> unsafe_string(@ccall "build/libcimgui".igGetVersion()::Cstring)
"1.91.5"
I'm not sure you can initialize those from Julia, typically the idea is that one would call the equivalent of |
Beta Was this translation helpful? Give feedback.
-
Hi,
Your example does indeed work but I am not module LibIDL
function IDL_Cleanup(just_cleanup)
# this libidl was unknown to this function since it is defined in the parent module really
ccall((:IDL_Cleanup, libidl), Cint, (Cint,), just_cleanup)
end
end Now, I've manged to work around this, by making module LibIDL
libidl = #= ... code to get the library path ... =#
include("lib_idl.jl") # now the `libidl` symbol is available to the wrappers since they are no longer in a module.
#= ... exporting all symbols ... =#
end But I am not sure I like this approach, Is there a better way? Regarding the construction of function IDL_INIT_DATA(init_options::IDL_INIT_DATA_OPTIONS_T)
r = Ref{IDL_INIT_DATA}()
x = Base.unsafe_convert(Ptr{IDL_INIT_DATA}, r)
x.options = init_options # the magic is here with the getproperty/setproperty indirections
GC.@preserve r unsafe_load(x)
end
# where
struct IDL_INIT_DATA
data::NTuple{56, UInt8}
end Still not exactly sure if I did something wrong and it didn't generate the constructors even though the logic should be there, or if Anyhow, this seems to be working 🥳 init_data = IDL_INIT_DATA(init_options)
res = IDL_Initialize(Ref(init_data))
@assert res == 1 |
Beta Was this translation helpful? Give feedback.
-
Sweet 🎉 I think the way you're doing it is fine, that's also what CImGui.jl does (except with the JLL).
Ah cool, I didn't realize we had that. Dumb question, but did you put At least for that test case the constructor seems to be generated. |
Beta Was this translation helpful? Give feedback.
-
Hello, I'm trying to pick up the torch for an IDL-Julia interop.
I'm using Clang to wrap the API header (it's a macro madness, and yet the codegen is almost flawless, kudos)
In the
generator.toml
I've specified the library name to belibidl
but now I am a bit uncertain how I can define the library symbol such that the wrapper knows whatlibidl
is.Unfortunately I can't really build IDL and I can't seem to wrap my head around
_jll
s.For now I've opted for a local lookup of the idl dynamic library which then I save in a const.
So maybe a bit naively I have the following structure:
Looking at another package like
CimGui.jl
I see that thelibcimgui
symbol arrives from the_jll
package but I am not really sure how the internals of_JLL
s work.How can I let
LibIDL
know the value oflibidl
?Should I simply do the local lookup inside the
LibIDL
module directly? I didn't really want to touch too much the generated output.EDIT: Also I have a bit of a side question: How does one initialize datastructures that have been wrapped as a
Beta Was this translation helpful? Give feedback.
All reactions