Cross-Compile FreeRDP using Mingw-w64

2023-05-16

Original: https://github.com/FreeRDP/FreeRDP/wiki/Compilation

FreeRDP can be compiled for Windows (32/64 Bit) on a Linux system using the Mingw cross-compilers. The following instruction was tested with Mingw-w64 2.0 and gcc-4.7 on Scientific Linux 6.1 (x64) but should work relatively independent of the Mingw/gcc version.

1. Install the Mingw-cross compilers (most Linux distros offer binary packages for Mingw in their repos). On older distros you may need to compile the latest version of Mingw from source. If you want to create 32 Bit binaries only, then Mingw32 is sufficient, otherwise you should install Mingw-w64.

2. Download the latest version of openssl (http://www.openssl.org/), compile it using the Mingw cross-compilers and install it. Instructions how to do this can be found on http://www.blogcompiler.com/.

3. Download FreeRDP and unpack the source archive. Create a subdirectory in the FreeRDP source tree called “mingw_build” where FreeRDP will be build. Open a terminal and goto this directory. Enter the command


cmake -DCMAKE_SYSTEM_NAME="Windows" \
      -DCMAKE_C_COMPILER="/opt/mingw64/bin/x86_64-w64-mingw32-gcc" \
      -DCMAKE_RC_COMPILER="/opt/mingw64/bin/x86_64-w64-mingw32-windres" \
      -DCMAKE_INSTALL_PREFIX="/opt/mingw64" \
      -DBUILD_SHARED_LIBS=OFF \
      -DCMAKE_C_FLAGS="-DFREERDP_EXPORTS -Dsprintf_s=snprintf" \
      -DCMAKE_EXE_LINKER_FLAGS="-L/opt/mingw64/lib" \
      -DWITH_SSE2=OFF \
      -DWITH_SSE2_TARGET=OFF \
      -DOPENSSL_INCLUDE_DIR="/opt/mingw64/include" \
      -DLIB_EAY="/opt/mingw64/lib/libcrypto.a" \
      -DSSL_EAY="/opt/mingw64/lib/libssl.a" \
      ..

This will configure FreeRDP for cross-compilation. Note that you need to adjust the paths according to your installation of Mingw and OpenSSL. Using the command above the wfreerdp.exe binary will be statically linked and can be executed on any Windows machine.

Note: You need a recent version of cmake (I used 2.8.7) as the logic in the FindOpenSSL cmake makro is broken (for cross-compilation) in older versions.

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Cross-Compile FreeRDP using Mingw-w64 的相关文章

随机推荐