-
-
Notifications
You must be signed in to change notification settings - Fork 193
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simple C# DLL import fails #139
Comments
Ok I think I understand where I am going wrong with this. Is it the case that I need to also link against libjulia.dll too? I can't find any example of how to do this for Julia with C#, if that is indeed possible. I can find examples of how to embed Julia in a C application. I also see how PackageCompiler builds the exe by linking the DLL to program.c. However, my C is sufficiently poor that I don't understand how to write a DLL that enables me to call a Julia function multiple times without the overhead of jl_init every time. I will attempt to at least produce a DLL that loads jl_init every time as a stepping stone... Any help greatly appreciated. |
My final thoughts for the day, and until someone who knows what they are doing is able to point me in the right direction: I have taken the hello.dll built from hello.jl, and made a new shared library using program.c (and exporting main). I now import this new dll into C# and try to call main but I get a new error! I simply changed line 19 of program.c to I compiled the new dll using The error I get is I feel like I am so close to being able to use Julia but I'm just not quite able to get this to work. EDIT: I only have one version of Julia on my PC. EDIT: Forgot to give my C# code
|
Solved! Everything started working when I kept JULIAC_PROGRAM_LIBNAME consistent in my compile options: I have no idea what the point of JULIAC_PROGRAM_LIBNAME is supposed to do, but if it changes it seems to give the image consistency check error. |
Having the same problem: Can you summarise what you have actually done? Was using program.c really necessary? Where do you set Thanks |
You may want to take a look at this related issue which shows how to build a shared library with PackageCompiler.jl and call the resulting library from C++. |
https://github.com/simonbyrne/libcg has examples for C and Rust and it should not be too hard to adopt that to C#. |
First off, let me say how great this tool is. I've been able to generate exes with Julia 1.0, which is very pleasing. This is on Windows 10 x64.
However, I'm now struggling to import a DLL generated using this tool into a simple C# program because it raises an access violation:
Here is the culprit code
hello.dll has been compiled running build_shared_lib("hello.jl") and is the example hello.jl distributed with PackageCompiler.
I've set Visual Studio to target x64, I already dealt with an earlier error which was due to targetting x86.
The text was updated successfully, but these errors were encountered: