Компиляция MinGW

From FreeCAD Documentation
Revision as of 12:58, 2 October 2021 by Evgeniy (talk | contribs) (Created page with "Чтобы получить исходный код FreeCAD, клонируйте его из основного репозитория git:")
Other languages:
(2021) Переписывание данной страницы находится на ранней стадии. Вы можете помочь в написании данной страницы!
Так же вы можете попробовать другие способы компиляции.

В данном руководстве будут рассмотрены шаги, необходимые для сборки FreeCAD в Windows с использованием среды MSYS2/MinGW. Базовые знания команд оболочки Bash будут полезны для понимания того, что происходит на каждом этапе сборки. Тщательное следование руководству по пунктам, должно привести вас к созданию рабочей сборки, даже если вы не полностью понимаете, что вы сделали, чтобы получить ее.

Прежде чем вы начнете

Загрузите и установите MSYS2, если вы еще этого не сделали. При запуске MSYS2 используйте 64-разрядную среду выполнения MSYS2 MinGW, если вы не знаете, что делаете, и у вас нет конкретной причины этого не делать. Если вы используете консоль UCRT, убедитесь, что ваша инсталляция адаптирована для использования пакетов UCRT вместо этого.

pacman -Syu

после чего перезапустите и запустите

pacman -Su

прежде чем продолжить.

Установка основных средств разработки

Во всех следующих шагах, если оболочка MSYS2 будет предлагать установки по умолчанию, для всех случаев дайте согласие нажав "Enter", когда вас спросят.

Во-первых, установите набор инструментов mingw-w64 GCC:

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

Это, вероятно, займет несколько минут, так как набор инструментов компилятора довольно велик.

Установите git:

pacman -S git

Закройте текущее окно консоли и перезапустите консоль MSYS2 MinGW 64 (в стандартной установке это будет в меню "Пуск" в папке MSYS2).

Загрузка исходников FreeCAD

Чтобы получить исходный код FreeCAD, клонируйте его из основного репозитория git:

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-python-ply
  • mingw-w64-x86_64-python-six
  • mingw-w64-x86_64-python-yaml
  • mingw-w64-x86_64-python-numpy
  • mingw-w64-x86_64-python-matplotlib
  • 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 mingw-w64-x86_64-python-python-ply mingw-w64-x86_64-python-six mingw-w64-x86_64-python-yaml mingw-w64-x86_64-python-numpy mingw-w64-x86_64-python-matplotlib

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

Run cMake:

cmake ../FreeCAD

And finally:

cmake --build ./