Last active
November 30, 2023 19:52
-
-
Save ihnorton/0cbe2ed595d539e859c4 to your computer and use it in GitHub Desktop.
Simple example of calling Julia from C#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
using System.Runtime.InteropServices; | |
namespace ConsoleApplication1 | |
{ | |
class Program | |
{ | |
[DllImport("libjulia.dll", CallingConvention = CallingConvention.Cdecl)] | |
public static extern void jl_init(string julia_home_dir); | |
[DllImport("libjulia.dll", CallingConvention = CallingConvention.Cdecl)] | |
public static extern void jl_eval_string(string str); | |
static void Main(string[] args) | |
{ | |
// Pass | |
jl_init(@"C:\Users\IEUser\Julia-0.4.0-dev\bin"); | |
// Crash | |
jl_eval_string("print(sqrt(2.0))"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment