Skip to content

Instantly share code, notes, and snippets.

@ihnorton
Last active November 30, 2023 19:52
Show Gist options
  • Star 10 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ihnorton/0cbe2ed595d539e859c4 to your computer and use it in GitHub Desktop.
Save ihnorton/0cbe2ed595d539e859c4 to your computer and use it in GitHub Desktop.
Simple example of calling Julia from C#
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