                "output" (str "file=" t "/output.csv"))
       (first (output/read-stan-output (str t "/output.csv"))))))
 
+(defn lib
+  [path lib-name]
+  (first (filter (fn [s]
+                   (.startsWith s (str path lib-name "_")))
+                 (map str (.listFiles (io/file path))))))
+
 (defn make
   [model]
   (let [text (slurp model)

                     (throw (Exception. "STAN_HOME environment variable is not set.
                                     See `clj-stan` documentation.")))
            model-file (str exe ".stan")
            hpp-file (str exe ".hpp")]
        (spit model-file text)
        (println (format "Compiling %s to C++." model))
        (execute (str home "/bin/stanc") model-file (str "--o=" hpp-file))

                 "-O3" "-o" exe
                 (str home "/src/cmdstan/main.cpp")
                 "-include" hpp-file
                 (str (lib lib-path "cvodes") "/lib/libsundials_nvecserial.a")
                 (str (lib lib-path "cvodes") "/lib/libsundials_cvodes.a"))))
    (->CompiledModel exe)))
