Re: [julia-users] Re: Calling Julia from .NET

2014-10-29 Thread Stefan Babinec
It's quite interesting that my sample above works perfectly under Win 7 but 
when I tried to repeat it under Win 8.1 I got following error (running from 
console):

**
Exception: EXCEPTION_ACCESS_VIOLATION at 0x8f6d37d2e4 -- unknown function 
(ip: 1832375012)
unknown function (ip: 1832375012)
anonymous at inference.jl:410
unknown function (ip: 1824097072)
builtin_tfunction at inference.jl:541
unknown function (ip: 1824073740)
abstract_call at inference.jl:860
unknown function (ip: 1824073740)
abstract_eval_call at inference.jl:900
abstract_eval at inference.jl:935
unknown function (ip: 1824073740)
abstract_eval_arg at inference.jl:866
unknown function (ip: 1824073740)
abstract_eval_call at inference.jl:878
abstract_eval at inference.jl:935
unknown function (ip: 1824073740)
abstract_interpret at inference.jl:1090
unknown function (ip: 1824073740)
typeinf at inference.jl:1409  at  (unknown line)
unknown function (ip: 1824073740)
abstract_call_gf at inference.jl:726
unknown function (ip: 1824073740)
abstract_call at inference.jl:819
unknown function (ip: 1824073740)
abstract_eval_call at inference.jl:900
abstract_eval at inference.jl:935
unknown function (ip: 1824073740)
abstract_interpret at inference.jl:1098
unknown function (ip: 1824073740)
typeinf at inference.jl:1409  at  (unknown line)
unknown function (ip: 1824073740)
typeinf_ext at inference.jl:1216
unknown function (ip: 1824073740)
unknown function (ip: 1824068669)
unknown function (ip: 1824071645)
unknown function (ip: 1824073841)
unknown function (ip: 1824123220)
unknown function (ip: 1824358486)
unknown function (ip: 1824333072)
unknown function (ip: 1824390705)
unknown function (ip: 287507815)
unknown function (ip: 1432107587)
unknown function (ip: -2)
unknown function (ip: -1540888000)
unknown function (ip: -1540887784)
unknown function (ip: 1432107587)
unknown function (ip: 1547850588)
unknown function (ip: 1549890657)
unknown function (ip: 1967807596)
unknown function (ip: 775106096)
unknown function (ip: 23662)
unknown function (ip: -1540888544)
unknown function (ip: 1)
unknown function (ip: -1540888560)
unknown function (ip: 44)
unknown function (ip: -1540888560)
unknown function (ip: 286343240)
unknown function (ip: 286343240)
unknown function (ip: 0)
unknown function (ip: -1540888560)
unknown function (ip: 1914573205)
unknown function (ip: 1894973440)
unknown function (ip: -1540887488)
unknown function (ip: 286343240)
unknown function (ip: 286343240)
unknown function (ip: -1540888544)
unknown function (ip: 287507815)
unknown function (ip: -1540888512)
unknown function (ip: -1539105552)
unknown function (ip: 1914573205)
unknown function (ip: -1540888272)
unknown function (ip: -1540887488)
unknown function (ip: -1540888000)
unknown function (ip: -1540887784)
unknown function (ip: -1540887440)
unknown function (ip: -1540887624)
unknown function (ip: -1540887488)
unknown function (ip: -1540887896)
unknown function (ip: -1540887784)
unknown function (ip: -1540888176)
unknown function (ip: 287506648)
unknown function (ip: -1504039680)
unknown function (ip: -1539105552)

Unhandled Exception: System.AccessViolationException: Attempted to read or 
write
 protected memory. This is often an indication that other memory is corrupt.
   at ConsoleApplication1.Program.jl_init(String message)
   at ConsoleApplication1.Program.Main(String[] args) in c:\_Julia 
Test\Julia_In
terop\Program.cs:line 28

**

Same version of VS 2013 for recompiling, same version of .NET, same sample. 

Any ideas ?

Thanks.






[julia-users] Re: Calling Julia from .NET

2014-10-06 Thread Tony Kelman
It should probably be noted in this thread that Julia master can now be 
compiled using Visual Studio (2013, only really tested with 64 bit so far 
since I still need to build new LLVM binaries for 32 bit), 
see https://github.com/JuliaLang/julia/pull/7761 for instructions and more 
information. It can start up a basic REPL, but many operations don't work - 
there are issues with 128-bit integer intrinsics in LLVM, various headers 
that likely aren't preprocessed correctly yet, etc. And the "build system" 
is a hacky mess of a shell script, plus minor tweaks to the existing 
makefiles, that still has to run in msys. A much better long-term solution 
would be to start porting as much of Julia's build system to cmake as 
possible, downloading mingw binaries for any dependencies that can't be 
easily built using MSVC (openblas, arpack, gmp). This may eventually enable 
better debugging of Julia on Windows using native Visual-Studio-format 
debuggers rather than MinGW gdb.




On Saturday, October 4, 2014 8:31:01 AM UTC-7, Greg Trzeciak wrote:
>
> If performance is not an issue you could use WebSockets and eval(). 
>
> It's my first day here and using Julia so don't take it as recommendation 
> - more like an option to explore.
>
> On Friday, September 26, 2014 11:55:55 AM UTC+2, Guido De Bouver wrote:
>>
>> dear Julia users,
>>
>> I would need to call Julia from VB .NET. I have seen it is possible to do 
>> so from C#, but is it possible to call from VB .NET ? If so, any examples 
>> available ?
>> Thanks for this great product
>>
>

[julia-users] Re: Calling Julia from .NET

2014-10-04 Thread Greg Trzeciak
If performance is not an issue you could use WebSockets and eval(). 

It's my first day here and using Julia so don't take it as recommendation - 
more like an option to explore.

On Friday, September 26, 2014 11:55:55 AM UTC+2, Guido De Bouver wrote:
>
> dear Julia users,
>
> I would need to call Julia from VB .NET. I have seen it is possible to do 
> so from C#, but is it possible to call from VB .NET ? If so, any examples 
> available ?
> Thanks for this great product
>


Re: [julia-users] Re: Calling Julia from .NET

2014-10-03 Thread Isaiah Norton
You can call your methods the same way you would call them from C, using
ccall and .NET interop to expose managed functions with a C ABI.

(To be honest, if I was stuck with .NET and wanted a nicer language I would
probably just use F#)
On Oct 3, 2014 2:23 AM, "Stefan Babinec"  wrote:

> Hi Isaiah.
>
> Yes, you are probably right. Maybe staticaly compiled Julia would help in
> this case of debugging under msvc.
>
> Another question.
>
> How am I able to call from .NET my own methods written in Julia  ?
> How am I able to let know libjulia.dll that such methods exist ?
>
> Thanks.
>
> Stefan.
>
> On Thursday, October 2, 2014 2:53:50 PM UTC+2, Isaiah wrote:
>>
>> Hi Stefan, I'm not sure. I guess it might be failing the first time it
>> tries to map an executable page. You might find some clues on the llvm
>> mailing list. But the bigger issue is that the msvc debugger won't be very
>> useful because msvc doesn't know anything about the jit'd object format
>> (still ELF I think). If you want to use a debugger you should download the
>> mingw64 tools in readme.windows and use gdb.
>> On Oct 2, 2014 3:59 AM, "Stefan Babinec"  wrote:
>>
>>> Thanks Isaiah.
>>>
>>> It works.
>>>
>>> I also tried to pass Julia's system image to jl_init and with the little
>>> help
>>>
>>> of SetDllDirectory method it works properly when i try to run it in
>>> console.
>>>
>>> ***
>>> using System.Runtime.InteropServices;
>>>
>>> namespace ConsoleApplication1
>>> {
>>> class Program
>>> {
>>> [DllImport("kernel32.dll", SetLastError = true)]
>>> static extern bool SetDllDirectory(string lpPathName);
>>>
>>> [DllImport("libjulia.dll")]
>>> static extern void jl_init(string message);
>>>
>>> [DllImport("libjulia.dll")]
>>> static extern void jl_eval_string(string message);
>>>
>>> static void Main(string[] args)
>>> {
>>> SetDllDirectory(@"c:\Users\SB\AppData\Local\Julia-0.3.0\bin\
>>> ");
>>>
>>> jl_init(@"c:\Users\SB\AppData\Local\Julia-0.3.0\bin\");
>>>
>>> jl_eval_string("print(sqrt(2.0))");
>>> }
>>> }
>>> }
>>> ***
>>>
>>> But when I try to run it directly in VS 2103 in (Debug/Release) I get
>>>
>>> following error from jl_init:
>>>
>>> "System.AccesViolationException.
>>> Attempted to read or write protected memory. This is often an indication
>>> that
>>>
>>> other memory is corrupt."
>>>
>>> Small piece from :
>>> http://social.msdn.microsoft.com/Forums/en-US/8789ea67-
>>> fbc5-4a7b-a4eb-d4a8a050d5c1/attempt-to-read-or-write-
>>> protected-memory-this-is-often-an-indicating-that-
>>> other-memory-is-corrupt
>>>
>>> "This issue shouldn't happen in managed code. The problem is typically
>>> caused by some component (typically unmanaged, but can also be a bad
>>> P/Invoke signature) that corrupts the program's memory."
>>>
>>> I tried also to suppress this exception by disabling
>>> "Tools menu ->Options -> Debugging -> General -> Suppress JIT
>>> optimization on module load"
>>> but with no success ?
>>>
>>> Any ideas ?
>>>
>>> Best regards.
>>>
>>> Stefan.
>>>
>>> On Wednesday, October 1, 2014 12:16:15 AM UTC+2, Isaiah wrote:

 The ">" indicates the cmd prompt working directory:
 ```
 C:\cmn\Julia-0.3.0>bin\ConsoleApplication2.exe
 1.4142135623730951
 ```
 Otherwise, try passing the bin path as a char* to jl_init as suggested.


 On Tue, Sep 30, 2014 at 11:24 AM, Stefan Babinec 
 wrote:

> I've copied exe file directly to julia's bin directory Isaiah.
>
> And I get the above mentioned error when I try to run it in the bin
> directory.
>
>
> On Tuesday, September 30, 2014 4:57:41 PM UTC+2, Isaiah wrote:
>>
>> Try running it from the Julia directory as `bin\CommandLine2.exe`.
>> This is very much a minimal example; for general use, the bin directory
>> should be passed as an argument to `jl_init`:
>>
>> https://github.com/JuliaLang/julia/blob/1ee440bee5035ccb33f8
>> 2b8a45febddd2f973baa/src/jlapi.c#L70-L73
>>
>> To go much further than this will really require to dig in to both
>> jlapi.c and the general Julia source code. Be aware that dealing with 
>> type
>> translation and garbage collection are both non-trivial. See also
>> `examples/embedding.c` in the julia tree, and several previous discussion
>> on the mailing list.
>>
>> On Tue, Sep 30, 2014 at 9:08 AM, Stefan Babinec 
>> wrote:
>>
>>> Hi Isaiah.
>>>
>>> I tried and got this error:
>>> "System image file " ?l\../lib/julia/sys.ji" not found"
>>>
>>> System Image sys.ji looks to be on his place and I have no problem
>>> running Julia.
>>>
>>> Thanks.
>>>
>>>
>>> On Tuesday, September 30, 2014 2:03:42 PM UTC+2, Isaiah wrote:

 I should mention that it is necessary to change the project target
 CPU from the default Any to x64 or x86

Re: [julia-users] Re: Calling Julia from .NET

2014-10-02 Thread Stefan Babinec
Hi Isaiah.

Yes, you are probably right. Maybe staticaly compiled Julia would help in 
this case of debugging under msvc.

Another question.

How am I able to call from .NET my own methods written in Julia  ?
How am I able to let know libjulia.dll that such methods exist ?

Thanks.

Stefan.

On Thursday, October 2, 2014 2:53:50 PM UTC+2, Isaiah wrote:
>
> Hi Stefan, I'm not sure. I guess it might be failing the first time it 
> tries to map an executable page. You might find some clues on the llvm 
> mailing list. But the bigger issue is that the msvc debugger won't be very 
> useful because msvc doesn't know anything about the jit'd object format 
> (still ELF I think). If you want to use a debugger you should download the 
> mingw64 tools in readme.windows and use gdb.
> On Oct 2, 2014 3:59 AM, "Stefan Babinec" > 
> wrote:
>
>> Thanks Isaiah.
>>
>> It works.
>>
>> I also tried to pass Julia's system image to jl_init and with the little 
>> help 
>>
>> of SetDllDirectory method it works properly when i try to run it in 
>> console. 
>>
>> ***
>> using System.Runtime.InteropServices;
>>
>> namespace ConsoleApplication1
>> {
>> class Program
>> {
>> [DllImport("kernel32.dll", SetLastError = true)]
>> static extern bool SetDllDirectory(string lpPathName);
>>
>> [DllImport("libjulia.dll")]
>> static extern void jl_init(string message);
>>
>> [DllImport("libjulia.dll")]
>> static extern void jl_eval_string(string message);
>>
>> static void Main(string[] args)
>> {
>> 
>> SetDllDirectory(@"c:\Users\SB\AppData\Local\Julia-0.3.0\bin\");
>>
>> jl_init(@"c:\Users\SB\AppData\Local\Julia-0.3.0\bin\"); 
>>
>> jl_eval_string("print(sqrt(2.0))");
>> }
>> }
>> }
>> ***
>>
>> But when I try to run it directly in VS 2103 in (Debug/Release) I get 
>>
>> following error from jl_init:
>>
>> "System.AccesViolationException.
>> Attempted to read or write protected memory. This is often an indication 
>> that 
>>
>> other memory is corrupt."
>>
>> Small piece from :
>>
>> http://social.msdn.microsoft.com/Forums/en-US/8789ea67-fbc5-4a7b-a4eb-d4a8a050d5c1/attempt-to-read-or-write-protected-memory-this-is-often-an-indicating-that-other-memory-is-corrupt
>>
>> "This issue shouldn't happen in managed code. The problem is typically 
>> caused by some component (typically unmanaged, but can also be a bad 
>> P/Invoke signature) that corrupts the program's memory."
>>
>> I tried also to suppress this exception by disabling 
>> "Tools menu ->Options -> Debugging -> General -> Suppress JIT 
>> optimization on module load"
>> but with no success ?
>>
>> Any ideas ?
>>
>> Best regards.
>>
>> Stefan.
>>
>> On Wednesday, October 1, 2014 12:16:15 AM UTC+2, Isaiah wrote:
>>>
>>> The ">" indicates the cmd prompt working directory:
>>> ```
>>> C:\cmn\Julia-0.3.0>bin\ConsoleApplication2.exe
>>> 1.4142135623730951
>>> ```
>>> Otherwise, try passing the bin path as a char* to jl_init as suggested.
>>>
>>>
>>> On Tue, Sep 30, 2014 at 11:24 AM, Stefan Babinec  
>>> wrote:
>>>
 I've copied exe file directly to julia's bin directory Isaiah.

 And I get the above mentioned error when I try to run it in the bin 
 directory.


 On Tuesday, September 30, 2014 4:57:41 PM UTC+2, Isaiah wrote:
>
> Try running it from the Julia directory as `bin\CommandLine2.exe`. 
> This is very much a minimal example; for general use, the bin directory 
> should be passed as an argument to `jl_init`:
>
> https://github.com/JuliaLang/julia/blob/1ee440bee5035ccb33f82b8a45febd
> dd2f973baa/src/jlapi.c#L70-L73
>
> To go much further than this will really require to dig in to both 
> jlapi.c and the general Julia source code. Be aware that dealing with 
> type 
> translation and garbage collection are both non-trivial. See also 
> `examples/embedding.c` in the julia tree, and several previous discussion 
> on the mailing list. 
>
> On Tue, Sep 30, 2014 at 9:08 AM, Stefan Babinec  
> wrote:
>
>> Hi Isaiah.
>>
>> I tried and got this error:
>> "System image file " ?l\../lib/julia/sys.ji" not found"
>>
>> System Image sys.ji looks to be on his place and I have no problem 
>> running Julia.
>>
>> Thanks.
>>
>>
>> On Tuesday, September 30, 2014 2:03:42 PM UTC+2, Isaiah wrote:
>>>
>>> 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"  
>>> 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
>>>

Re: [julia-users] Re: Calling Julia from .NET

2014-10-02 Thread Isaiah Norton
Hi Stefan, I'm not sure. I guess it might be failing the first time it
tries to map an executable page. You might find some clues on the llvm
mailing list. But the bigger issue is that the msvc debugger won't be very
useful because msvc doesn't know anything about the jit'd object format
(still ELF I think). If you want to use a debugger you should download the
mingw64 tools in readme.windows and use gdb.
On Oct 2, 2014 3:59 AM, "Stefan Babinec"  wrote:

> Thanks Isaiah.
>
> It works.
>
> I also tried to pass Julia's system image to jl_init and with the little
> help
>
> of SetDllDirectory method it works properly when i try to run it in
> console.
>
> ***
> using System.Runtime.InteropServices;
>
> namespace ConsoleApplication1
> {
> class Program
> {
> [DllImport("kernel32.dll", SetLastError = true)]
> static extern bool SetDllDirectory(string lpPathName);
>
> [DllImport("libjulia.dll")]
> static extern void jl_init(string message);
>
> [DllImport("libjulia.dll")]
> static extern void jl_eval_string(string message);
>
> static void Main(string[] args)
> {
> SetDllDirectory(@"c:\Users\SB\AppData\Local\Julia-0.3.0\bin\");
>
> jl_init(@"c:\Users\SB\AppData\Local\Julia-0.3.0\bin\");
>
> jl_eval_string("print(sqrt(2.0))");
> }
> }
> }
> ***
>
> But when I try to run it directly in VS 2103 in (Debug/Release) I get
>
> following error from jl_init:
>
> "System.AccesViolationException.
> Attempted to read or write protected memory. This is often an indication
> that
>
> other memory is corrupt."
>
> Small piece from :
>
> http://social.msdn.microsoft.com/Forums/en-US/8789ea67-fbc5-4a7b-a4eb-d4a8a050d5c1/attempt-to-read-or-write-protected-memory-this-is-often-an-indicating-that-other-memory-is-corrupt
>
> "This issue shouldn't happen in managed code. The problem is typically
> caused by some component (typically unmanaged, but can also be a bad
> P/Invoke signature) that corrupts the program's memory."
>
> I tried also to suppress this exception by disabling
> "Tools menu ->Options -> Debugging -> General -> Suppress JIT optimization
> on module load"
> but with no success ?
>
> Any ideas ?
>
> Best regards.
>
> Stefan.
>
> On Wednesday, October 1, 2014 12:16:15 AM UTC+2, Isaiah wrote:
>>
>> The ">" indicates the cmd prompt working directory:
>> ```
>> C:\cmn\Julia-0.3.0>bin\ConsoleApplication2.exe
>> 1.4142135623730951
>> ```
>> Otherwise, try passing the bin path as a char* to jl_init as suggested.
>>
>>
>> On Tue, Sep 30, 2014 at 11:24 AM, Stefan Babinec 
>> wrote:
>>
>>> I've copied exe file directly to julia's bin directory Isaiah.
>>>
>>> And I get the above mentioned error when I try to run it in the bin
>>> directory.
>>>
>>>
>>> On Tuesday, September 30, 2014 4:57:41 PM UTC+2, Isaiah wrote:

 Try running it from the Julia directory as `bin\CommandLine2.exe`. This
 is very much a minimal example; for general use, the bin directory should
 be passed as an argument to `jl_init`:

 https://github.com/JuliaLang/julia/blob/1ee440bee5035ccb33f82b8a45febd
 dd2f973baa/src/jlapi.c#L70-L73

 To go much further than this will really require to dig in to both
 jlapi.c and the general Julia source code. Be aware that dealing with type
 translation and garbage collection are both non-trivial. See also
 `examples/embedding.c` in the julia tree, and several previous discussion
 on the mailing list.

 On Tue, Sep 30, 2014 at 9:08 AM, Stefan Babinec 
 wrote:

> Hi Isaiah.
>
> I tried and got this error:
> "System image file " ?l\../lib/julia/sys.ji" not found"
>
> System Image sys.ji looks to be on his place and I have no problem
> running Julia.
>
> Thanks.
>
>
> On Tuesday, September 30, 2014 2:03:42 PM UTC+2, Isaiah wrote:
>>
>> 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" 
>> 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
>>>

Re: [julia-users] Re: Calling Julia from .NET

2014-10-02 Thread Stefan Babinec
Thanks Isaiah.

It works.

I also tried to pass Julia's system image to jl_init and with the little 
help 

of SetDllDirectory method it works properly when i try to run it in 
console. 

***
using System.Runtime.InteropServices;

namespace ConsoleApplication1
{
class Program
{
[DllImport("kernel32.dll", SetLastError = true)]
static extern bool SetDllDirectory(string lpPathName);

[DllImport("libjulia.dll")]
static extern void jl_init(string message);

[DllImport("libjulia.dll")]
static extern void jl_eval_string(string message);

static void Main(string[] args)
{
SetDllDirectory(@"c:\Users\SB\AppData\Local\Julia-0.3.0\bin\");

jl_init(@"c:\Users\SB\AppData\Local\Julia-0.3.0\bin\"); 

jl_eval_string("print(sqrt(2.0))");
}
}
}
***

But when I try to run it directly in VS 2103 in (Debug/Release) I get 

following error from jl_init:

"System.AccesViolationException.
Attempted to read or write protected memory. This is often an indication 
that 

other memory is corrupt."

Small piece from :
http://social.msdn.microsoft.com/Forums/en-US/8789ea67-fbc5-4a7b-a4eb-d4a8a050d5c1/attempt-to-read-or-write-protected-memory-this-is-often-an-indicating-that-other-memory-is-corrupt

"This issue shouldn't happen in managed code. The problem is typically 
caused by some component (typically unmanaged, but can also be a bad 
P/Invoke signature) that corrupts the program's memory."

I tried also to suppress this exception by disabling 
"Tools menu ->Options -> Debugging -> General -> Suppress JIT optimization 
on module load"
but with no success ?

Any ideas ?

Best regards.

Stefan.

On Wednesday, October 1, 2014 12:16:15 AM UTC+2, Isaiah wrote:
>
> The ">" indicates the cmd prompt working directory:
> ```
> C:\cmn\Julia-0.3.0>bin\ConsoleApplication2.exe
> 1.4142135623730951
> ```
> Otherwise, try passing the bin path as a char* to jl_init as suggested.
>
>
> On Tue, Sep 30, 2014 at 11:24 AM, Stefan Babinec  > wrote:
>
>> I've copied exe file directly to julia's bin directory Isaiah.
>>
>> And I get the above mentioned error when I try to run it in the bin 
>> directory.
>>
>>
>> On Tuesday, September 30, 2014 4:57:41 PM UTC+2, Isaiah wrote:
>>>
>>> Try running it from the Julia directory as `bin\CommandLine2.exe`. This 
>>> is very much a minimal example; for general use, the bin directory should 
>>> be passed as an argument to `jl_init`:
>>>
>>> https://github.com/JuliaLang/julia/blob/1ee440bee5035ccb33f82b8a45febd
>>> dd2f973baa/src/jlapi.c#L70-L73
>>>
>>> To go much further than this will really require to dig in to both 
>>> jlapi.c and the general Julia source code. Be aware that dealing with type 
>>> translation and garbage collection are both non-trivial. See also 
>>> `examples/embedding.c` in the julia tree, and several previous discussion 
>>> on the mailing list. 
>>>
>>> On Tue, Sep 30, 2014 at 9:08 AM, Stefan Babinec  
>>> wrote:
>>>
 Hi Isaiah.

 I tried and got this error:
 "System image file " ?l\../lib/julia/sys.ji" not found"

 System Image sys.ji looks to be on his place and I have no problem 
 running Julia.

 Thanks.


 On Tuesday, September 30, 2014 2:03:42 PM UTC+2, Isaiah wrote:
>
> 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"  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 <
>> tobias...@googlemail.com> 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 
>

Re: [julia-users] Re: Calling Julia from .NET

2014-09-30 Thread Isaiah Norton
The ">" indicates the cmd prompt working directory:
```
C:\cmn\Julia-0.3.0>bin\ConsoleApplication2.exe
1.4142135623730951
```
Otherwise, try passing the bin path as a char* to jl_init as suggested.


On Tue, Sep 30, 2014 at 11:24 AM, Stefan Babinec  wrote:

> I've copied exe file directly to julia's bin directory Isaiah.
>
> And I get the above mentioned error when I try to run it in the bin
> directory.
>
>
> On Tuesday, September 30, 2014 4:57:41 PM UTC+2, Isaiah wrote:
>>
>> Try running it from the Julia directory as `bin\CommandLine2.exe`. This
>> is very much a minimal example; for general use, the bin directory should
>> be passed as an argument to `jl_init`:
>>
>> https://github.com/JuliaLang/julia/blob/1ee440bee5035ccb33f82b8a45febd
>> dd2f973baa/src/jlapi.c#L70-L73
>>
>> To go much further than this will really require to dig in to both
>> jlapi.c and the general Julia source code. Be aware that dealing with type
>> translation and garbage collection are both non-trivial. See also
>> `examples/embedding.c` in the julia tree, and several previous discussion
>> on the mailing list.
>>
>> On Tue, Sep 30, 2014 at 9:08 AM, Stefan Babinec 
>> wrote:
>>
>>> Hi Isaiah.
>>>
>>> I tried and got this error:
>>> "System image file " ?l\../lib/julia/sys.ji" not found"
>>>
>>> System Image sys.ji looks to be on his place and I have no problem
>>> running Julia.
>>>
>>> Thanks.
>>>
>>>
>>> On Tuesday, September 30, 2014 2:03:42 PM UTC+2, Isaiah wrote:

 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"  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 <
> tobias...@googlemail.com> 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 <
>>> guido.d...@telenet.be> 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 
>>> >
>>>
>>
>
>>


Re: [julia-users] Re: Calling Julia from .NET

2014-09-30 Thread Stefan Babinec
I've copied exe file directly to julia's bin directory Isaiah.

And I get the above mentioned error when I try to run it in the bin 
directory.


On Tuesday, September 30, 2014 4:57:41 PM UTC+2, Isaiah wrote:
>
> Try running it from the Julia directory as `bin\CommandLine2.exe`. This is 
> very much a minimal example; for general use, the bin directory should be 
> passed as an argument to `jl_init`:
>
>
> https://github.com/JuliaLang/julia/blob/1ee440bee5035ccb33f82b8a45febddd2f973baa/src/jlapi.c#L70-L73
>
> To go much further than this will really require to dig in to both jlapi.c 
> and the general Julia source code. Be aware that dealing with type 
> translation and garbage collection are both non-trivial. See also 
> `examples/embedding.c` in the julia tree, and several previous discussion 
> on the mailing list. 
>
> On Tue, Sep 30, 2014 at 9:08 AM, Stefan Babinec  > wrote:
>
>> Hi Isaiah.
>>
>> I tried and got this error:
>> "System image file " ?l\../lib/julia/sys.ji" not found"
>>
>> System Image sys.ji looks to be on his place and I have no problem 
>> running Julia.
>>
>> Thanks.
>>
>>
>> On Tuesday, September 30, 2014 2:03:42 PM UTC+2, Isaiah wrote:
>>>
>>> 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"  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 >>> > 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 <
>> guido.d...@telenet.be> 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  
>> > 
>>
>
  
>

Re: [julia-users] Re: Calling Julia from .NET

2014-09-30 Thread Isaiah Norton
Try running it from the Julia directory as `bin\CommandLine2.exe`. This is
very much a minimal example; for general use, the bin directory should be
passed as an argument to `jl_init`:

https://github.com/JuliaLang/julia/blob/1ee440bee5035ccb33f82b8a45febddd2f973baa/src/jlapi.c#L70-L73

To go much further than this will really require to dig in to both jlapi.c
and the general Julia source code. Be aware that dealing with type
translation and garbage collection are both non-trivial. See also
`examples/embedding.c` in the julia tree, and several previous discussion
on the mailing list.

On Tue, Sep 30, 2014 at 9:08 AM, Stefan Babinec  wrote:

> Hi Isaiah.
>
> I tried and got this error:
> "System image file " ?l\../lib/julia/sys.ji" not found"
>
> System Image sys.ji looks to be on his place and I have no problem running
> Julia.
>
> Thanks.
>
>
> On Tuesday, September 30, 2014 2:03:42 PM UTC+2, Isaiah wrote:
>>
>> 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"  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 
>>> 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 
> 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 
> >
>

>>>


Re: [julia-users] Re: Calling Julia from .NET

2014-09-30 Thread Stefan Babinec
Hi Isaiah.

I tried and got this error:
"System image file " ?l\../lib/julia/sys.ji" not found"

System Image sys.ji looks to be on his place and I have no problem running 
Julia.

Thanks.


On Tuesday, September 30, 2014 2:03:42 PM UTC+2, Isaiah wrote:
>
> 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"  > 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 > > 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  
 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  
 > 

>>>
>> 

Re: [julia-users] Re: Calling Julia from .NET

2014-09-30 Thread Isaiah Norton
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"  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  > 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 
>>> 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 
>>> >
>>>
>>
>


Re: [julia-users] Re: Calling Julia from .NET

2014-09-29 Thread Isaiah Norton
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 
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 
>> 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 
>> >
>>
>


Re: [julia-users] Re: Calling Julia from .NET

2014-09-29 Thread Tobias Knopp
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  > 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  
> > 
>


Re: [julia-users] Re: Calling Julia from .NET

2014-09-29 Thread 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  
> 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  
> 


[julia-users] Re: Calling Julia from .NET

2014-09-29 Thread Guido De Bouver
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  



[julia-users] Re: Calling Julia from .NET

2014-09-26 Thread Stefan Babinec
Hi Guido.

Can you please point me to C# example ? 

I would appreciate your help.

Thanks.

On Friday, September 26, 2014 11:55:55 AM UTC+2, Guido De Bouver wrote:
>
> dear Julia users,
>
> I would need to call Julia from VB .NET. I have seen it is possible to do 
> so from C#, but is it possible to call from VB .NET ? If so, any examples 
> available ?
> Thanks for this great product
>