I'm trying to run Clojure on the CLR and getting stuck on some basic issues. Based on this question I am using the following code:
In program.clj:
(ns program
(:require [clojure.core])
(:gen-class
:methods [#^{:static true} [output [int int] int]]))
(defn output [a b]
(+ a b))
(defn -output [a b]
(output a b))
(defn -main []
(println (str "(+ 5 10): " (output 5 10))))
Then in Program.cs:
using System;
using clojure.lang;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
program p = new program();
System.Console.WriteLine(p.output(5, 9));
System.Console.ReadLine();
}
}
}
When I run Program.cs, it throws a TypeInitializationError with the error message "Could not locate clojure/core.clj.dll or clojure/core.clj on load path." To debug, I added the lines:
System.Environment.SetEnvironmentVariable("clojure.load.path", "c:\clojure");
System.Console.WriteLine(System.Environment.GetEnvironmentVariable("clojure.load.path"));
System.Console.WriteLine(RT.CLOJURE_LOAD_PATH);
The first WriteLine shows "c:\clojure", as I would expect. The second one shows "clojure.load.path". My understanding was that the runtime looked to the environment variables for the load path. So why is it not finding it? How else does one set the load path?