See if this works for you: import core.runtime;
void myMainFunc() { } extern (C) int initializeDee() { int result; void exceptionHandler(Throwable e) { throw e; } try { Runtime.initialize(&exceptionHandler); result = myMainFunc(); Runtime.terminate(&exceptionHandler); } catch (Throwable o) { result = 0; } return result; } This is similar to how it's done for Windows GUI applications, where we have to manually run the initialize function in druntime (unless it's hidden by some GUI framework).