diff --git a/include.xml b/include.xml
index ab8552d2d..633aac06e 100644
--- a/include.xml
+++ b/include.xml
@@ -45,7 +45,7 @@
-
+
diff --git a/lime/system/System.hx b/lime/system/System.hx
index a2e852d51..ff73133cc 100644
--- a/lime/system/System.hx
+++ b/lime/system/System.hx
@@ -125,7 +125,7 @@ class System {
#if !disable_cffi
#if sys
- #if (iphone || emscripten || android)
+ #if (iphone || emscripten || android || static_link)
return cpp.Lib.load (library, method, args);
#end
diff --git a/project/Build.xml b/project/Build.xml
index 1dce92c8b..d2f0dc548 100644
--- a/project/Build.xml
+++ b/project/Build.xml
@@ -153,7 +153,7 @@
-
+
diff --git a/templates/cpp/static/BuildMain.xml b/templates/cpp/static/BuildMain.xml
new file mode 100644
index 000000000..467d2019b
--- /dev/null
+++ b/templates/cpp/static/BuildMain.xml
@@ -0,0 +1,91 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ::foreach ndlls::
+ ::end::
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/templates/cpp/static/Main.cpp b/templates/cpp/static/Main.cpp
new file mode 100644
index 000000000..8a7a36efd
--- /dev/null
+++ b/templates/cpp/static/Main.cpp
@@ -0,0 +1,37 @@
+#include
+
+#ifdef HX_WINDOWS
+#include
+#endif
+
+extern "C" const char *hxRunLibrary ();
+extern "C" void hxcpp_set_top_of_stack ();
+
+::foreach ndlls::::if (registerStatics)::
+extern "C" int ::name::_register_prims ();::end::::end::
+
+
+#ifdef HX_WINDOWS
+int __stdcall WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
+#else
+extern "C" int main(int argc, char *argv[]) {
+#endif
+
+ hxcpp_set_top_of_stack ();
+
+ ::foreach ndlls::::if (registerStatics)::
+ ::name::_register_prims ();::end::::end::
+
+ const char *err = NULL;
+ err = hxRunLibrary ();
+
+ if (err) {
+
+ printf("Error: %s\n", err);
+ return -1;
+
+ }
+
+ return 0;
+
+}
\ No newline at end of file