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
endNow, 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 ... =#
endBut 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}
endStill 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.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
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.tomlI've specified the library name to belibidlbut now I am a bit uncertain how I can define the library symbol such that the wrapper knows whatlibidlis.Unfortunately I can't really build IDL and I can't seem to wrap my head around
_jlls.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.jlI see that thelibcimguisymbol arrives from the_jllpackage but I am not really sure how the internals of_JLLs work.How can I let
LibIDLknow the value oflibidl?Should I simply do the local lookup inside the
LibIDLmodule 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