Hello, Trying to create an executable from Julia source, there are questions that raised... The process of exporting functions wasn't successful, function(s) was not exported to dll, and even the generated dll cant be loaded in c++ code. Below is the process explained in details:
Can anybody bring more insight, how to build a standalone executable from Julia source? Following resources were used for experiments below: http://juliacomputing.com/blog/2016/02/09/static-julia.html http://juliacomputing.com/blog/2016/03/10/j2c-announcement.html Assume userimg.jl, which contains exported function(s): # user functionality for DLL @Base.ccallable foo(x::Int) = x+1 Now, create a dll: julia.exe "build_sysimg.jl" "./Julia/Compile/bin/" native "julia_dll.jl" -- force File build_sysimg.jl on line 77 contains following command flags: run(`$julia -C $cpu_target --output-ji $sysimg_path.ji --output-o $sysimg_path.o --sysimage ../../../lib/julia/sys.dll -J $inference_path.ji --startup-file=no sysimg.jl --compile=all --eval nothing`) The resulting dll has 29MB. The next step is to use the dll in c++ project: #include <iostream> #include <windows.h> typedef int(*fnc_foo) (int); int main() { HINSTANCE hDLL = LoadLibraryA("test_dll.dll"); auto a = GetLastError(); if (hDLL == nullptr) throw std::exception("test_dll.dll not found!"); fnc_foo foo = (fnc_foo)GetProcAddress(hDLL, "foo"); if(!foo) throw std::exception("foo in test_dll.dll not found!"); std::cout << foo(10) << "\n"; FreeLibrary(hDLL); return 0; } In the c++ code above the dll cannot be loaded, hDLL = nullptr, and the first exception is thrown. Expecting the dll with Dependency Walker even an exported function foo() cannot be found. Thanks for any suggestions. Jan
