All Projects → madduci → docker-msvc-cpp

madduci / docker-msvc-cpp

Licence: other
Dockerized Visual C++ environment with wine

Programming Languages

powershell
5483 projects
Dockerfile
14818 projects
Batchfile
5799 projects
python
139335 projects - #7 most used programming language
CMake
9771 projects
shell
77523 projects
C++
36643 projects - #6 most used programming language

Projects that are alternatives of or similar to docker-msvc-cpp

fp256
An efficient library for 256 bit integer arithmetic
Stars: ✭ 21 (-65%)
Mutual labels:  msvc
libssh
Unofficial LibSSH with added custom native Visual Studio project build tools. LibSSH: Mulitplatform C library implementing the SSHv2 and SSHv1 protocol for client and server implementations.
Stars: ✭ 21 (-65%)
Mutual labels:  msvc
Conty
Easy to use unprivileged Linux container packed into a single portable executable
Stars: ✭ 198 (+230%)
Mutual labels:  wine
d2launcher
Diablo II • Median XL • Mod Launcher for Linux
Stars: ✭ 20 (-66.67%)
Mutual labels:  wine
FAudio-Builds
FAudio builds for Wine
Stars: ✭ 63 (+5%)
Mutual labels:  wine
wine-portable-executable
Wine builds packed into portable executables
Stars: ✭ 85 (+41.67%)
Mutual labels:  wine
BeamNG terrainMaterialCache
BeamNG.drive Black Terrain fix for Linux and Mac
Stars: ✭ 81 (+35%)
Mutual labels:  wine
Autodesk-Fusion-360-for-Linux
This is a project, where I give you a way to use Autodesk Fusion 360 on Linux!
Stars: ✭ 810 (+1250%)
Mutual labels:  wine
d3d9-to-11
Direct3D 9 to Direct3D 11 converter
Stars: ✭ 69 (+15%)
Mutual labels:  wine
SOLIDWORKS-for-Linux
This is a project, where I give you a way to use SOLIDWORKS on Linux!
Stars: ✭ 122 (+103.33%)
Mutual labels:  wine
Fusion360WineInstaller
No description or website provided.
Stars: ✭ 55 (-8.33%)
Mutual labels:  wine
wine-bundler
wine bundler - simple command line alternative to wine bottler and wineskin for macOS
Stars: ✭ 18 (-70%)
Mutual labels:  wine
osu-macOS-Agent
osu!macOS Agent - An auxiliary troubleshooting tool for osu!
Stars: ✭ 36 (-40%)
Mutual labels:  wine
docker-iqfeed
Dockerized IQFeed client with X11VNC for remote viewing
Stars: ✭ 28 (-53.33%)
Mutual labels:  wine
ci playground
Playground for Cloud CI development for C++
Stars: ✭ 23 (-61.67%)
Mutual labels:  msvc
build-scripts
Utility scripts for building of 3rd-party libraries
Stars: ✭ 33 (-45%)
Mutual labels:  msvc
python-installcab
Install individual components from cab installers into wine
Stars: ✭ 28 (-53.33%)
Mutual labels:  wine
MiraiCQ
用C/C++,易语言写QQ机器人,兼容酷Q插件,支持Linux(通过Wine)
Stars: ✭ 55 (-8.33%)
Mutual labels:  wine
singlefile
featured cs:go internal hack, one file and less than 1000 lines.
Stars: ✭ 47 (-21.67%)
Mutual labels:  msvc
winepak-sdk
Platform and SDK runtimes for winepak based applications
Stars: ✭ 46 (-23.33%)
Mutual labels:  wine

docker-msvc-cpp

This is a reproducible Linux-based Dockerfile for cross compiling with MSVC compiler, Conan, CMake, Ninja and Wix Toolset, usable as base image for Continuous Integration setups.

This requires a zipped package of a real MSVC installation from Windows (currently only supporting MSVC 2019, tested until latest 16.11.2), which isn't freely redistributable, so you have to build it on your own.

The MSVC installation can be performed using a Vagrant box and executing the installation of MSVC Community Edition: a Vagrantfile and a Powershell script to prepare the require packages are included in this repository.

Requirements

Hardware

  • Dual-Core CPU, with VT-x/AMD-v enabled
  • 8 GByte RAM (16 GByte recommended)
  • Enough Disk Space for Vagrant and Docker images (50 GByte free recommended)
  • Fast internet connection

Software

  • Virtualbox (6.x)
  • Vagrant (2.x)
  • Docker Engine 18.06+
  • Docker-Compose 1.20+

Vagrant Plugins

  • winrm
  • winrm-elevated

Build

To build the docker image, you need to run the following commands:

# starts the Vagrant box, installs MSVC and the other tools and prepares the zip packages
./download-tools.sh
# Builds the docker images (the Ubuntu 20.04 image with wine and the one including also the tools)
./build-docker-images.sh

The first script will start a Vagrant/Virtualbox Virtual Machine with Windows 10, which will execute an unattended installation of Visual C++ tools, together with CMake, Conan and Wix Toolset. Once the installation is completed, the required files will be compressed in ZIP archives and put on the host machine.

The second script will launch in background a python server on port 20000, self-hosting the ZIP archives and then build 2 docker images:

  • docker-wine, with only wine-stable (6.0 at time of writing), .NET 4.8 and initialized as Windows 10
  • docker-wine-msvc, with the required Visual C++ tools and libraries (cl, link, nmake, rc), the latest Windows 10 SDK, CMake, Conan, Ninja and Wix.

Usage

After building the final docker image, the working directory in the docker image is set to /home/wine/.wine/drive_c/ and in the /home/wine/.wine/drive_c/Tools folder are stored all the required tools, plus a batch file that can set the 64 bit environment, in the specific:

  • /home/wine/.wine/drive_c/x64.bat

It contains all the required Windows paths in Windows-style format (as 'C:..').

The entrypoint of the Docker Image is set to be a wine64-entrypoint bash script that loads the 64bit Windows CMD console that waits for commands.

To start the image and execute a prepared Windows command or script, you have to call it with double-double quotes as follows:

docker run --rm -it -v HOST_PATH_TO_MOUNT:TARGET_PATH madduci/docker-wine-msvc:16.11-2019 ""YOUR_SCRIPT_IN_TARGET_PATH""

docker run --rm -it madduci/docker-wine-msvc:16.11-2019 ""conan install openssl/1.1.1k@""

alternatively, to issue interactive commands:

docker run --rm -it -v HOST_PATH_TO_MOUNT:TARGET_PATH madduci/docker-wine-msvc:16.11-2019
C:>cl /?
C:>conan --version
C:>cmake --version

Caveats

Encoding

There are small issues when dealing with Windows-1252 encoding, that are unfortunately wine issues. For example, it has been observed that file names with bad encoding cannot be handled in the Windows CMD.

Visual C++

It has been noticed that on some code, the 32 Bit compiler triggers internal compiler errors (like C1001), especially when dealing with some Windows-specific header file, such as ATL/MFC related code. The 32 Bit compiler is therefore not enabled. On a 64 Bit build, those problems don't appear and the build works fine. It seems that some compiler flags are also affecting those 32 Bit builds.

CMake

The Visual Studio CMake generator doesn't work, due to issues with MSBuild 16.0 and wine. CMake can be used only with NMake Makefiles or, if you prefer, with Ninja, already included in the image. See the test project contained in this repository.

In order to work under Wine/CMD, CMake requires the environment variable MSVC_REDIST_DIR and that must be transformed in Unix Path format.

set(MSVC_REDIST_DIR $ENV{VCToolsRedistDir})
string(REPLACE  "\\" "/" MSVC_REDIST_DIR "${MSVC_REDIST_DIR}")

Conan

Conan by default tries to use Visual Studio as generator when used with CMake. You have two options: set the environment variable CONAN_CMAKE_GENERATOR to "NMake Makefiles" (see here) or you can run the build step by invoking CMake as follows in your conanfile.py:

def build(self):
        self.run('cmake -g "{generator}" -DCMAKE_BUILD_TYPE={build_type} {source}'.format(generator="NMake MakeFiles", build_type="Release", source=self.source_folder))
        self.run('cmake --build . ')
        # Builds the installer, if you have set CPACK and WIX in CMake
        self.run('cmake --build . --target package')

The extended image comes also with Ninja, so you can speed up your builds by setting "Ninja" as generator, instead of "NMake MakeFiles". This is the default choice, as CONAN_CMAKE_GENERATOR is set to "Ninja" in the x64.bat script.

WIX Toolset

Wix by default attempts to validate the generated MSI setup files and it can return the error LIGHT216. In case you have an incomplete setup (as in the test folder) or have issues with your Wix/MSI settings, you can pass the -sval flag to Wix light command in your CPack configuration:

# LIGHT216 error while building MSI package under wine
set(CPACK_WIX_LIGHT_EXTRA_FLAGS -sval )
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].