Compile on MinGW: Difference between revisions

From FreeCAD Documentation
(Added single command)
(Wiki code.)
Line 1: Line 1:
<languages/>
<languages/>
<translate>
<translate>

<!--T:2-->
<!--T:2-->
{{VeryImportantMessage|(2021) The re-write of this page is an early draft, and work is still in progress. Please help us to finish it!<br/> Meanwhile, try other [[Compiling|compilation options]].}}
{{VeryImportantMessage|(2021) The re-write of this page is an early draft, and work is still in progress. Please help us to finish it!<br>Meanwhile, try other [[Compiling|compilation options]].}}

</translate>
</translate>
{{TOCright}}
{{TOCright}}
<translate>
<translate>
{{TOCright}}


This guide will walk through the steps necessary to build FreeCAD on Windows using the MSYS2/MinGW environment. Basic familiarity with Bash shell commands will be useful for understanding what each step does, but following the guide by rote should result in a working build even if you don't understand exactly what you did to get it.
This guide will walk through the steps necessary to build FreeCAD on Windows using the MSYS2/MinGW environment. Basic familiarity with Bash shell commands will be useful for understanding what each step does, but following the guide by rote should result in a working build even if you don't understand exactly what you did to get it.
Line 13: Line 14:


Download and install [https://www.msys2.org MSYS2] if you have not already. When launching MSYS2, use the "MSYS2 MinGW 64-bit" runtime unless you know what you are doing and have a specific reason not to. If you use the UCRT console, make sure to adapt your installation to use the UCRT packages instead.
Download and install [https://www.msys2.org MSYS2] if you have not already. When launching MSYS2, use the "MSYS2 MinGW 64-bit" runtime unless you know what you are doing and have a specific reason not to. If you use the UCRT console, make sure to adapt your installation to use the UCRT packages instead.

</translate>
<pre>
<pre>
pacman -Syu
pacman -Syu
</pre>
</pre>
<translate>

and then relaunching and running
and then relaunching and running

</translate>
<pre>
<pre>
pacman -Su
pacman -Su
</pre>
</pre>
<translate>

before proceeding.
before proceeding.


Line 27: Line 36:


First, install the mingw-w64 GCC toolchain:
First, install the mingw-w64 GCC toolchain:

</translate>
<pre>
<pre>
pacman -S --needed base-devel mingw-w64-x86_64-toolchain mingw-w64-x86_64-cmake mingw-w64-x86_64-ninja
pacman -S --needed base-devel mingw-w64-x86_64-toolchain mingw-w64-x86_64-cmake mingw-w64-x86_64-ninja
</pre>
</pre>
<translate>

This will probably take several minutes to complete, as the compiler toolchain is quite large.
This will probably take several minutes to complete, as the compiler toolchain is quite large.


Install git:
Install git:

</translate>
<pre>
<pre>
pacman -S git
pacman -S git
</pre>
</pre>
<translate>


Close your current console window and relaunch the MSYS2 MinGW 64 console (in a standard installation this will be in your Start menu in the MSYS2 folder).
Close your current console window and relaunch the MSYS2 MinGW 64 console (in a standard installation this will be in your Start menu in the MSYS2 folder).
Line 42: Line 58:


To get the FreeCAD source code, clone it from the main git repository:
To get the FreeCAD source code, clone it from the main git repository:

</translate>
<pre>
<pre>
git clone https://github.com/FreeCAD/FreeCAD
git clone https://github.com/FreeCAD/FreeCAD
</pre>
</pre>
<translate>


If you do not want to compile the latest HEAD, once you have the source you can check out a specific tag:
If you do not want to compile the latest HEAD, once you have the source you can check out a specific tag:

</translate>
<pre>
<pre>
cd FreeCAD
cd FreeCAD
git checkout tags/0.19.2 -b releases/FreeCAD-0-19
git checkout tags/0.19.2 -b releases/FreeCAD-0-19
</pre>
</pre>
<translate>


Or a specific pull request (in this example, PR 1234):
Or a specific pull request (in this example, PR 1234):

</translate>
<pre>
<pre>
cd FreeCAD
cd FreeCAD
Line 58: Line 82:
git checkout pr/1234
git checkout pr/1234
</pre>
</pre>
<translate>


=== Install required libraries ===
=== Install required libraries ===
Line 66: Line 91:


To resolve the current (9/11/2021) problem with the OpenCASCADE installation, it is necessary to modify the installed cMake configuration files for the library. In the files /mingw64/lib/cmake/opencascade/*-release.cmake, remove all occurrences of the string
To resolve the current (9/11/2021) problem with the OpenCASCADE installation, it is necessary to modify the installed cMake configuration files for the library. In the files /mingw64/lib/cmake/opencascade/*-release.cmake, remove all occurrences of the string

</translate>
<pre>
<pre>
\${OCCT_INSTALL_BIN_LETTER}
\${OCCT_INSTALL_BIN_LETTER}
</pre>
</pre>
<translate>

(Note the leading backslash -- that character must be removed along with the variable reference).
(Note the leading backslash -- that character must be removed along with the variable reference).


Line 83: Line 112:


The following is a single command to install everything but OpenCASCADE:
The following is a single command to install everything but OpenCASCADE:

</translate>
<pre>
<pre>
pacman -S mingw-w64-x86_64-xerces-c mingw-w64-x86_64-qt5 mingw-w64-x86_64-med mingw-w64-x86_64-swig mingw-w64-x86_64-qtwebkit mingw-w64-x86_64-coin mingw-w64-x86_64-python-pivy mingw-w64-x86_64-pyside2-qt5
pacman -S mingw-w64-x86_64-xerces-c mingw-w64-x86_64-qt5 mingw-w64-x86_64-med mingw-w64-x86_64-swig mingw-w64-x86_64-qtwebkit mingw-w64-x86_64-coin mingw-w64-x86_64-python-pivy mingw-w64-x86_64-pyside2-qt5
</pre>
</pre>
<translate>


=== Build FreeCAD ===
=== Build FreeCAD ===


Make a directory for the build: note this is typically not a subdirectory of the source directory (it is often useful to be able to delete either the source or the build directory independently).
Make a directory for the build: note this is typically not a subdirectory of the source directory (it is often useful to be able to delete either the source or the build directory independently).

</translate>
<pre>
<pre>
mkdir FreeCAD-build
mkdir FreeCAD-build
cd FreeCAD-build
cd FreeCAD-build
<pre>
<pre>
<translate>


Run cMake:
Run cMake:

</translate>
<pre>
<pre>
cmake ../FreeCAD
cmake ../FreeCAD
</pre>
</pre>
<translate>


And finally:
And finally:

</translate>
<pre>
<pre>
cmake --build ./
cmake --build ./
</pre>
</pre>
<translate>



</translate>
</translate>

Revision as of 08:42, 20 September 2021

(2021) The re-write of this page is an early draft, and work is still in progress. Please help us to finish it!
Meanwhile, try other compilation options.

This guide will walk through the steps necessary to build FreeCAD on Windows using the MSYS2/MinGW environment. Basic familiarity with Bash shell commands will be useful for understanding what each step does, but following the guide by rote should result in a working build even if you don't understand exactly what you did to get it.

Before you start

Download and install MSYS2 if you have not already. When launching MSYS2, use the "MSYS2 MinGW 64-bit" runtime unless you know what you are doing and have a specific reason not to. If you use the UCRT console, make sure to adapt your installation to use the UCRT packages instead.

pacman -Syu

and then relaunching and running

pacman -Su

before proceeding.

Install basic development tools

In all of the following steps, when prompted by MSYS2's shell, accept the default installations of everything by pressing "Enter" when asked.

First, install the mingw-w64 GCC toolchain:

pacman -S --needed base-devel mingw-w64-x86_64-toolchain mingw-w64-x86_64-cmake mingw-w64-x86_64-ninja

This will probably take several minutes to complete, as the compiler toolchain is quite large.

Install git:

pacman -S git

Close your current console window and relaunch the MSYS2 MinGW 64 console (in a standard installation this will be in your Start menu in the MSYS2 folder).

Check out the FreeCAD sources

To get the FreeCAD source code, clone it from the main git repository:

git clone https://github.com/FreeCAD/FreeCAD

If you do not want to compile the latest HEAD, once you have the source you can check out a specific tag:

cd FreeCAD
git checkout tags/0.19.2 -b releases/FreeCAD-0-19

Or a specific pull request (in this example, PR 1234):

cd FreeCAD
git fetch origin pull/1234/head:pr/1234
git checkout pr/1234

Install required libraries

FreeCAD depends on many 3rd-party libraries for its functionality. They may be installed individually, or as a single unified command. Updating this list is the current ongoing work of this documentation: to help, repeatedly run the cmake command from the next section, and install whatever the next package is that it errors on. As of this writing there is a problem with the pacman-installed OpenCASCADE package.

  • mingw-w64-x86_64-opencascade

To resolve the current (9/11/2021) problem with the OpenCASCADE installation, it is necessary to modify the installed cMake configuration files for the library. In the files /mingw64/lib/cmake/opencascade/*-release.cmake, remove all occurrences of the string

\${OCCT_INSTALL_BIN_LETTER}

(Note the leading backslash -- that character must be removed along with the variable reference).

Now, install the following required dependencies using pacman:

  • mingw-w64-x86_64-xerces-c
  • mingw-w64-x86_64-qt5
  • mingw-w64-x86_64-med
  • mingw-w64-x86_64-swig
  • mingw-w64-x86_64-qtwebkit
  • mingw-w64-x86_64-coin
  • mingw-w64-x86_64-python-pivy
  • mingw-w64-x86_64-pyside2-qt5

The following is a single command to install everything but OpenCASCADE:

pacman -S mingw-w64-x86_64-xerces-c mingw-w64-x86_64-qt5 mingw-w64-x86_64-med mingw-w64-x86_64-swig mingw-w64-x86_64-qtwebkit mingw-w64-x86_64-coin mingw-w64-x86_64-python-pivy mingw-w64-x86_64-pyside2-qt5

Build FreeCAD

Make a directory for the build: note this is typically not a subdirectory of the source directory (it is often useful to be able to delete either the source or the build directory independently).

mkdir FreeCAD-build
cd FreeCAD-build
<pre>

Run cMake:

<pre>
cmake ../FreeCAD

And finally:

cmake --build ./