Browse Source

Example of cross-compiling hello world for Windows

On a Linux system.

Reference :
https://www.swarminglogic.com/index.php?/article/2014_11_crosscompile
DricomDragon 4 years ago
parent
commit
5d285cb9a8
4 changed files with 16 additions and 0 deletions
  1. 2 0
      crossCompile/.gitignore
  2. 3 0
      crossCompile/build-linux.sh
  3. 3 0
      crossCompile/build-windows.sh
  4. 8 0
      crossCompile/main.cpp

+ 2 - 0
crossCompile/.gitignore

@@ -0,0 +1,2 @@
+# Ignore generated binaries
+hello*

+ 3 - 0
crossCompile/build-linux.sh

@@ -0,0 +1,3 @@
+#!/bin/sh
+
+g++ -o hello-linux main.cpp

+ 3 - 0
crossCompile/build-windows.sh

@@ -0,0 +1,3 @@
+#!/bin/sh
+
+x86_64-w64-mingw32-g++ -o hello-windows main.cpp --static

+ 8 - 0
crossCompile/main.cpp

@@ -0,0 +1,8 @@
+#include <iostream>
+
+int main()
+{
+	std::cout << "Hello World!" << std::endl;
+
+	return 0;
+}