I should mention that it is necessary to change the project target CPU from
the default Any to x64 or x86 to match the libjulia architecture.
On Sep 29, 2014 11:58 PM, "Isaiah Norton" <[email protected]> wrote:
> I tried this some time ago during 0.2, so to make sure it still works I
> made a minimal translation of the embedding example to C#:
>
> ```
> using System;
> using System.Runtime.InteropServices;
>
> namespace ConsoleApplication2
> {
> class Program
> {
> [DllImport("libjulia.dll")]
> static extern void jl_init();
> [DllImport("libjulia.dll")]
> static extern void jl_eval_string(string message);
>
> static void Main(string[] args)
> {
> jl_init();
> jl_eval_string("print(sqrt(2.0))");
> }
> }
> }
> ```
>
> I compiled this, copied the binary into `Julia-0.3.0\bin`, and it works:
>
> ```
> C:\cmn\Julia-0.3.0>bin\ConsoleApplication2.exe
> 1.4142135623730951
> ```
>
>
> On Mon, Sep 29, 2014 at 4:11 PM, Tobias Knopp <[email protected]
> > wrote:
>
>> yep, I have done this (mostly for fun) before and it works. One needs
>> some experience with P/Invoke of course but this is no magic but similar to
>> our ccall.
>>
>> Cheers,
>>
>> Tobi
>>
>> Am Montag, 29. September 2014 20:52:10 UTC+2 schrieb Stefan Karpinski:
>>>
>>> I assume that you can call C libraries from .NET, right? The C library
>>> for Julia is libjulia – how to call it from C is explained in the embedding
>>> docs, calling it from .NET should be similar.
>>>
>>>
>>> > On Sep 29, 2014, at 12:37 PM, Guido De Bouver <[email protected]>
>>> wrote:
>>> >
>>> > I have not found the C# examples, but I have not looked for them.
>>> Sorry for that.
>>> >
>>> > So, any help on this, how could we call Julia from .NET ????
>>> >
>>>
>>
>