Compile on MinGW: Difference between revisions
Renatorivo (talk | contribs) No edit summary |
Renatorivo (talk | contribs) No edit summary |
||
(7 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
<languages/> |
<languages/> |
||
<translate> |
|||
{{VeryImportantMessage|Warning, the contents of this page may be obsolete. Please help us to keep it updated!}} |
|||
<!--T:2--> |
|||
{{VeryImportantMessage|(2019) The contents of this page are obsolete. Please help us to keep it updated!<br/> Meanwhile, try other [[Compiling|compilation options]].}} |
|||
==How to build and run FreeCAD under MSYS/MinGW== |
|||
</translate> |
|||
{{TOCright}} |
|||
<translate> |
|||
==How to build and run FreeCAD under MSYS/MinGW== <!--T:3--> |
|||
===Prerequisites=== |
===Prerequisites=== <!--T:4--> |
||
<!--T:5--> |
|||
Here comes a short introduction how to setup a MSYS/MinGW environment |
Here comes a short introduction how to setup a MSYS/MinGW environment |
||
on a Windows system, to build all needed libraries and finally to build |
on a Windows system, to build all needed libraries and finally to build |
||
the FreeCAD sources. |
the FreeCAD sources. |
||
==== MSYS/MinGW==== |
==== MSYS/MinGW==== <!--T:6--> |
||
<!--T:7--> |
|||
If not already installed get a MinGW installer from the Sourceforge page at |
If not already installed get a MinGW installer from the Sourceforge page at |
||
http://sourceforge.net/projects/mingw. When writing this tutorial the latest |
http://sourceforge.net/projects/mingw. When writing this tutorial the latest |
||
Line 18: | Line 25: | ||
file in the 3rd party folder of the FreeCAD sources. |
file in the 3rd party folder of the FreeCAD sources. |
||
<!--T:8--> |
|||
Then as second step MSYS needs to be installed to have an environment to run |
Then as second step MSYS needs to be installed to have an environment to run |
||
./configure scripts which we make heavy use of in order to build all needed |
./configure scripts which we make heavy use of in order to build all needed |
||
libraries. From the Soureforge page the file MSYS-1.0.11.exe was taken. |
libraries. From the Soureforge page the file MSYS-1.0.11.exe was taken. |
||
<!--T:9--> |
|||
A virginal MSYS/MinGW installation lacks of a few modules we later need. |
A virginal MSYS/MinGW installation lacks of a few modules we later need. |
||
First, we need the utility pexport which can be found in the file |
First, we need the utility pexport which can be found in the file |
||
Line 29: | Line 38: | ||
Here, the pexports utility can go to the bin directory of your MinGW installation. |
Here, the pexports utility can go to the bin directory of your MinGW installation. |
||
<!--T:10--> |
|||
Then, we also need the development files for the pthreads module which is part |
Then, we also need the development files for the pthreads module which is part |
||
of the file pthreads-w32-2.8.0-3-mingw32-dev.tar.lzma. Just download and copy |
of the file pthreads-w32-2.8.0-3-mingw32-dev.tar.lzma. Just download and copy |
||
Line 34: | Line 44: | ||
==== CMake==== |
==== CMake==== <!--T:11--> |
||
<!--T:12--> |
|||
Download the CMake utility from http://www.cmake.org/cmake/resources/software.html. |
Download the CMake utility from http://www.cmake.org/cmake/resources/software.html. |
||
Get the archive with the binaries for the Windows platform and unpack whereever you |
Get the archive with the binaries for the Windows platform and unpack whereever you |
||
want. There is nothing further to do for this. |
want. There is nothing further to do for this. |
||
==== SWIG==== |
==== SWIG==== <!--T:13--> |
||
<!--T:14--> |
|||
Download the SWIG utility from www.swig.org and extract it somewhere on your harddisk. |
Download the SWIG utility from www.swig.org and extract it somewhere on your harddisk. |
||
===Third party libraries=== |
===Third party libraries=== <!--T:15--> |
||
<!--T:16--> |
|||
Here is a description which libraries we need for FreeCAD and how to build them from |
Here is a description which libraries we need for FreeCAD and how to build them from |
||
the sources. In order not to pollute our MinGW installation with too many files from |
the sources. In order not to pollute our MinGW installation with too many files from |
||
Line 52: | Line 67: | ||
==== zlib==== |
==== zlib==== <!--T:17--> |
||
<!--T:18--> |
|||
For zlib there is already a ready package for MinGW. So, therefore simply download |
For zlib there is already a ready package for MinGW. So, therefore simply download |
||
the file libz-1.2.3-1-mingw32-dev.tar.gz from the Sourceforge site and extract the |
the file libz-1.2.3-1-mingw32-dev.tar.gz from the Sourceforge site and extract the |
||
Line 58: | Line 75: | ||
==== Python==== |
==== Python==== <!--T:19--> |
||
<!--T:20--> |
|||
It seems to be nearly impossible to build the Python sources directly with the MinGW |
It seems to be nearly impossible to build the Python sources directly with the MinGW |
||
compiler. This is because some Python modules require some features which are not |
compiler. This is because some Python modules require some features which are not |
||
Line 66: | Line 85: | ||
copy the include folder to C:\MSYS\1.0\local, the DLL can go to C:\MSYS\1.0\local\bin. |
copy the include folder to C:\MSYS\1.0\local, the DLL can go to C:\MSYS\1.0\local\bin. |
||
<!--T:21--> |
|||
Now we also need the so called import library. There we cannot use the .lib file which |
Now we also need the so called import library. There we cannot use the .lib file which |
||
comes together with the installer. But it's easy to create one with the pexports/dlltool |
comes together with the installer. But it's easy to create one with the pexports/dlltool |
||
utilities. Assuming the Python version is 2.6 do these two steps: |
utilities. Assuming the Python version is 2.6 do these two steps: |
||
</translate> |
|||
pexports python26.dll > python26.def |
pexports python26.dll > python26.def |
||
dlltool -D python26.dll -d python26.def -l libpython26.dll.a |
dlltool -D python26.dll -d python26.def -l libpython26.dll.a |
||
<translate> |
|||
<!--T:22--> |
|||
The file libpython26.dll.a can now be moved to C:\MSYS\1.0\local\lib. |
The file libpython26.dll.a can now be moved to C:\MSYS\1.0\local\lib. |
||
====f2c==== |
====f2c==== <!--T:23--> |
||
<!--T:24--> |
|||
For this library we don't need any header files but only the import library to build the |
For this library we don't need any header files but only the import library to build the |
||
Salome SMESH sources. The easiest way to build this file is: |
Salome SMESH sources. The easiest way to build this file is: |
||
</translate> |
|||
pexports libgfortran-3.dll > f2c.def |
pexports libgfortran-3.dll > f2c.def |
||
dlltool -D libgfortran-3.dll -d f2c.def -l libf2c.dll.a |
dlltool -D libgfortran-3.dll -d f2c.def -l libf2c.dll.a |
||
<translate> |
|||
<!--T:25--> |
|||
The file libf2c.dll.a can now be moved to C:\MSYS\1.0\local\lib. |
The file libf2c.dll.a can now be moved to C:\MSYS\1.0\local\lib. |
||
====xerces-c==== |
====xerces-c==== <!--T:26--> |
||
<!--T:27--> |
|||
Download a source archive from http://xml.apache.org/dist/xerces-c/ and extract it. |
Download a source archive from http://xml.apache.org/dist/xerces-c/ and extract it. |
||
Open a MSYS command line window and change to the xerces-c sources. From there run |
Open a MSYS command line window and change to the xerces-c sources. From there run |
||
</translate> |
|||
./configure LDFLAGS=-no-undefined |
./configure LDFLAGS=-no-undefined |
||
<translate> |
|||
<!--T:28--> |
|||
Once ./configure has finished it's best to move to the source directory because we |
Once ./configure has finished it's best to move to the source directory because we |
||
don't need to build the dozens of test applications and other stuff. So, do this: |
don't need to build the dozens of test applications and other stuff. So, do this: |
||
</translate> |
|||
cd src |
cd src |
||
make |
make |
||
make install |
make install |
||
<translate> |
|||
<!--T:29--> |
|||
This takes a few minutes to be done. |
This takes a few minutes to be done. |
||
====boost==== |
====boost==== <!--T:30--> |
||
<!--T:31--> |
|||
For boost there exists a testing package with cmake support. This, however, seems to be |
For boost there exists a testing package with cmake support. This, however, seems to be |
||
stable enough to build with the MinGW compiler. So, get the file boost-1.41.0.cmake0.zip |
stable enough to build with the MinGW compiler. So, get the file boost-1.41.0.cmake0.zip |
||
from http://sodium.resophonic.com/boost-cmake/1.41.0.cmake0/ and unpack it. |
from http://sodium.resophonic.com/boost-cmake/1.41.0.cmake0/ and unpack it. |
||
<!--T:32--> |
|||
Now, start the cmake-gui.exe from within the MSYS command line. This is necessary for cmake |
Now, start the cmake-gui.exe from within the MSYS command line. This is necessary for cmake |
||
in order to find the compiler and other stuff. Select the folder of the boost sources with |
in order to find the compiler and other stuff. Select the folder of the boost sources with |
||
Line 112: | Line 143: | ||
which system you want to generate the Makefiles. Select MSYS/Makefiles, not MinGW/Makefiles. |
which system you want to generate the Makefiles. Select MSYS/Makefiles, not MinGW/Makefiles. |
||
<!--T:33--> |
|||
When the configuration step has finished go to the options and search for WINMANGLE_LIBNAMES. |
When the configuration step has finished go to the options and search for WINMANGLE_LIBNAMES. |
||
Switch this off because otherwise the boost library names contain the compiler name. This |
Switch this off because otherwise the boost library names contain the compiler name. This |
||
Line 117: | Line 149: | ||
the installtion folder choose the directory C:\MSYS\1.0\local. |
the installtion folder choose the directory C:\MSYS\1.0\local. |
||
<!--T:34--> |
|||
So, reconfigure boost and press on Generate once it has finished. Close the CMake GUI window |
So, reconfigure boost and press on Generate once it has finished. Close the CMake GUI window |
||
and enter |
and enter |
||
</translate> |
|||
make |
make |
||
make install |
make install |
||
<translate> |
|||
<!--T:35--> |
|||
into the command line. This will take a couple of minutes. |
into the command line. This will take a couple of minutes. |
||
====eigen2==== |
====eigen2==== <!--T:36--> |
||
<!--T:37--> |
|||
Download eigen-2.0.15.tar.gz or any later version from http://eigen.tuxfamily.org/index.php?title=Main_Page. |
Download eigen-2.0.15.tar.gz or any later version from http://eigen.tuxfamily.org/index.php?title=Main_Page. |
||
Unpack the files and start again cmake-gui. Set the installation directory to C:\MSYS\1.0\local |
Unpack the files and start again cmake-gui. Set the installation directory to C:\MSYS\1.0\local |
||
and press on Configure and Generate. Close the window and start the installation with |
and press on Configure and Generate. Close the window and start the installation with |
||
</translate> |
|||
make |
make |
||
make install |
make install |
||
<translate> |
|||
<!--T:38--> |
|||
o Qt4 |
o Qt4 |
||
From the Qt website at ftp://ftp.trollech.com you can download already prebuilt packages for the |
From the Qt website at ftp://ftp.trollech.com you can download already prebuilt packages for the |
||
Line 140: | Line 177: | ||
together. In this case the source tarball must be downloaded. Use version 4.5.3 or higher. Unpack |
together. In this case the source tarball must be downloaded. Use version 4.5.3 or higher. Unpack |
||
the sources and start the configure.exe you'll find inside the sources. |
the sources and start the configure.exe you'll find inside the sources. |
||
</translate> |
|||
./configure |
./configure |
||
<translate> |
|||
<!--T:39--> |
|||
By default the build the debug and release version. If you only want the release version use the |
By default the build the debug and release version. If you only want the release version use the |
||
option "-release". |
option "-release". |
||
Line 148: | Line 186: | ||
Configure will ask you some questions under which license you want to use Qt. Choose LGPL here. |
Configure will ask you some questions under which license you want to use Qt. Choose LGPL here. |
||
Now run the build with |
Now run the build with |
||
</translate> |
|||
make |
make |
||
<translate> |
|||
<!--T:40--> |
|||
This can take quite some time because Qt has become a really huge library over the years. Once the |
This can take quite some time because Qt has become a really huge library over the years. Once the |
||
build has finished run a |
build has finished run a |
||
</translate> |
|||
make install |
make install |
||
<translate> |
|||
<!--T:41--> |
|||
to copy the header files to their right place. All the binaries and header files are still inside |
to copy the header files to their right place. All the binaries and header files are still inside |
||
the source folder. If you like you can copy all the .dll, .a, and the direcories under "include" to |
the source folder. If you like you can copy all the .dll, .a, and the direcories under "include" to |
||
Line 161: | Line 201: | ||
====Coin==== |
====Coin==== <!--T:42--> |
||
Get a source archive from www.coin3d.org. Unpack the sources and run |
|||
<!--T:43--> |
|||
Get a source archive from www.coin3d.org. Unpack the sources and run |
|||
</translate> |
|||
./confiure |
./confiure |
||
make |
make |
||
make install |
make install |
||
<translate> |
|||
<!--T:44--> |
|||
It may happen that a message dialog pops up due to a missing cygwin1.dll. You simply ignore this. |
It may happen that a message dialog pops up due to a missing cygwin1.dll. You simply ignore this. |
||
====SoQt==== |
====SoQt==== <!--T:45--> |
||
Get a source archive from www.coin3d.org. Unpack the sources and run |
|||
<!--T:46--> |
|||
Get a source archive from www.coin3d.org. Unpack the sources and run |
|||
</translate> |
|||
./configure CXXFLAGS="-DCOIN_DLL" --with-qt=/usr/local |
./configure CXXFLAGS="-DCOIN_DLL" --with-qt=/usr/local |
||
make |
make |
||
make install |
make install |
||
<translate> |
|||
<!--T:47--> |
|||
In case your Qt development files are not under /usr/local choose the correct directory there. |
In case your Qt development files are not under /usr/local choose the correct directory there. |
||
Again a message dialog may pop up due to the missing cygwin1.dll. |
Again a message dialog may pop up due to the missing cygwin1.dll. |
||
====PyQt/sip==== |
====PyQt/sip==== <!--T:48--> |
||
<!--T:49--> |
|||
Warning: the following is obsoleted from version 0.14, since FreeCAD is now using |
Warning: the following is obsoleted from version 0.14, since FreeCAD is now using |
||
pySide instead of PyQt. At the moment, PySide suport for MingW seems still not complete: |
pySide instead of PyQt. At the moment, PySide suport for MingW seems still not complete: |
||
https://bugreports.qt-project.org/browse/PYSIDE-113?page=com.atlassian.jira.plugin.system.issuetabpanels%3aall-tabpanel |
https://bugreports.qt-project.org/browse/PYSIDE-113?page=com.atlassian.jira.plugin.system.issuetabpanels%3aall-tabpanel |
||
<!--T:50--> |
|||
Download the sources archives for sip and PyQt4 from www.riverbankcomputing.co.uk. |
Download the sources archives for sip and PyQt4 from www.riverbankcomputing.co.uk. |
||
<!--T:51--> |
|||
In order to build sip extract the archive and open a MSYS command line. From within |
In order to build sip extract the archive and open a MSYS command line. From within |
||
its source archive call |
its source archive call |
||
</translate> |
|||
python configure.py --platform win32-g++ --destdir=/usr/local |
python configure.py --platform win32-g++ --destdir=/usr/local |
||
make |
make |
||
<translate> |
|||
<!--T:52--> |
|||
It may happen that this step aborts because the Python include headers cannot be found. |
It may happen that this step aborts because the Python include headers cannot be found. |
||
In this case edit the Makefile and add the include path for the ython headers and also |
In this case edit the Makefile and add the include path for the ython headers and also |
||
the path and filename of the Python library. |
the path and filename of the Python library. |
||
<!--T:53--> |
|||
Unfortunately, the 'make install' command doesn't work because the Makefile was generated |
Unfortunately, the 'make install' command doesn't work because the Makefile was generated |
||
to use Windows batch commands instead of bash commands. Thus, copy the following files to |
to use Windows batch commands instead of bash commands. Thus, copy the following files to |
||
a path where Python can find it, e.g. /usr/local/bin. |
a path where Python can find it, e.g. /usr/local/bin. |
||
</translate> |
|||
sipconfig.py |
sipconfig.py |
||
sipdistutils.py |
sipdistutils.py |
||
Line 209: | Line 260: | ||
sip.pyd |
sip.pyd |
||
sip.exe |
sip.exe |
||
<translate> |
|||
<!--T:54--> |
|||
In order to build PyQt4 extract the source archive and open a MSYS command line. Go to the |
In order to build PyQt4 extract the source archive and open a MSYS command line. Go to the |
||
directory and start |
directory and start |
||
</translate> |
|||
export PATH=/usr/local/lib/:$PATH |
export PATH=/usr/local/lib/:$PATH |
||
python configure.py --destdir=/usr/local/lib/site-packages |
python configure.py --destdir=/usr/local/lib/site-packages |
||
make |
make |
||
<translate> |
|||
<!--T:55--> |
|||
Since the Makefile doesn't find the Python header files copy them all and also the file sip.h |
Since the Makefile doesn't find the Python header files copy them all and also the file sip.h |
||
to a directory where they can be found. A good place seems to be the directory of the Qt sources. |
to a directory where they can be found. A good place seems to be the directory of the Qt sources. |
||
There copy the files to $QTDIR/include. The Python library file python26.dll.a can go $QTDIR/lib. |
There copy the files to $QTDIR/include. The Python library file python26.dll.a can go $QTDIR/lib. |
||
<!--T:56--> |
|||
After the build has finished you have to copy all files that end with .pyd to their destination, |
After the build has finished you have to copy all files that end with .pyd to their destination, |
||
e.g. /usr/local/lib/site-packages/PyQt4. Lateron when you have built the FreeCAD sources you have |
e.g. /usr/local/lib/site-packages/PyQt4. Lateron when you have built the FreeCAD sources you have |
||
Line 226: | Line 280: | ||
====ODE==== |
====ODE==== <!--T:57--> |
||
<!--T:58--> |
|||
TODO: Still not clear if this will be used. (http://www.ode.org), >= 0.10.x |
TODO: Still not clear if this will be used. (http://www.ode.org), >= 0.10.x |
||
====OpenCASCADE==== |
====OpenCASCADE==== <!--T:59--> |
||
<!--T:60--> |
|||
For the build of the OpenCASCADE libraries get the sources from www.opencascade.org or alternatively |
For the build of the OpenCASCADE libraries get the sources from www.opencascade.org or alternatively |
||
it is also possible to download a stripped source tarball from the Debian mirrors which don't include |
it is also possible to download a stripped source tarball from the Debian mirrors which don't include |
||
any fonts and other resource files. |
any fonts and other resource files. |
||
<!--T:61--> |
|||
Unpack the sources and download a CMake script from http://opencascade-cmake.googlecode.com/svn/trunk/ |
Unpack the sources and download a CMake script from http://opencascade-cmake.googlecode.com/svn/trunk/ |
||
and the file occ_config.h.cmake. Copy both files into the 'ros' directory, start cmake-gui from |
and the file occ_config.h.cmake. Copy both files into the 'ros' directory, start cmake-gui from |
||
within a MSYS command line and select MSYS Makefiles. In the options the following switches can be |
within a MSYS command line and select MSYS Makefiles. In the options the following switches can be |
||
disabled: |
disabled: |
||
</translate> |
|||
OPENCASCADE_WRAPPERS |
OPENCASCADE_WRAPPERS |
||
OPENCASCADE_VISUALISATION |
OPENCASCADE_VISUALISATION |
||
OPENCASCADE_OCAF |
OPENCASCADE_OCAF |
||
OPENCASCADE_DRAW |
OPENCASCADE_DRAW |
||
<translate> |
|||
<!--T:62--> |
|||
Then specify for OPENCASCADE_INSTALL_PREFIX C:/MSYS/1.0/local as destination directory- |
Then specify for OPENCASCADE_INSTALL_PREFIX C:/MSYS/1.0/local as destination directory- |
||
<!--T:63--> |
|||
Now click the Configure button which takes a while and afterwards the Generate button. |
Now click the Configure button which takes a while and afterwards the Generate button. |
||
====Note 1==== |
====Note 1==== <!--T:64--> |
||
<!--T:65--> |
|||
The original sources don't completely compile with MinGW. Therefore you have to apply the patch |
The original sources don't completely compile with MinGW. Therefore you have to apply the patch |
||
OpenCASCADE6.3.0-MinGW.patch from http://code.google.com/p/opencascade-cmake/source/browse/trunk |
OpenCASCADE6.3.0-MinGW.patch from http://code.google.com/p/opencascade-cmake/source/browse/trunk |
||
====Note 2==== |
====Note 2==== <!--T:66--> |
||
<!--T:67--> |
|||
The original sources includes also a configure script and the Makefile.am files. |
The original sources includes also a configure script and the Makefile.am files. |
||
But it appeared to be very hard to build the libraries this way. Thus, it highly |
But it appeared to be very hard to build the libraries this way. Thus, it highly |
||
recommended to do it the CMake way. |
recommended to do it the CMake way. |
||
====Note 3==== |
====Note 3==== <!--T:68--> |
||
<!--T:69--> |
|||
For a couple of libraries the arguments passed to the linker exceeds the number of |
For a couple of libraries the arguments passed to the linker exceeds the number of |
||
allowed characters and thus the linker stops with an error: "Bad file number". |
allowed characters and thus the linker stops with an error: "Bad file number". |
||
Line 268: | Line 335: | ||
Afterwards the shared library can be built out of these object files. |
Afterwards the shared library can be built out of these object files. |
||
<!--T:70--> |
|||
Example: |
Example: |
||
If the build.make file has a line of the form |
If the build.make file has a line of the form |
||
Line 279: | Line 347: | ||
rm -f *.obj |
rm -f *.obj |
||
====Netgen==== |
====Netgen==== <!--T:71--> |
||
<!--T:72--> |
|||
Modify the following files: |
Modify the following files: |
||
* libsrc/meshing/improve2.hpp |
* libsrc/meshing/improve2.hpp |
||
Line 292: | Line 362: | ||
Add DLL_HEADER to classes OCCSurface, Meshing2OCCSurfaces, MeshOptimize2dOCCSurfaces, OCCRefinementSurfaces |
Add DLL_HEADER to classes OCCSurface, Meshing2OCCSurfaces, MeshOptimize2dOCCSurfaces, OCCRefinementSurfaces |
||
Run the configure script with these arguments |
Run the configure script with these arguments </translate> |
||
./configure --prefix=/usr/local --enable-shared --enable-occ --with-occ=/usr/local --with-tcl=/usr/local/lib --enable-nglib CXXFLAGS="-DNGLIB_EXPORTS -DWNT" |
./configure --prefix=/usr/local --enable-shared --enable-occ --with-occ=/usr/local --with-tcl=/usr/local/lib --enable-nglib CXXFLAGS="-DNGLIB_EXPORTS -DWNT" |
||
make && make install |
make && make install |
||
<translate> |
|||
===Building the FreeCAD sources=== <!--T:73--> |
|||
<!--T:74--> |
|||
===Building the FreeCAD sources=== |
|||
In order build the FreeCAD sources either get the developer sources from the SVN repository |
In order build the FreeCAD sources either get the developer sources from the SVN repository |
||
or get one of the .tar.gz tarballs and extract it. |
or get one of the .tar.gz tarballs and extract it. |
||
Line 307: | Line 378: | ||
accepts all your input create the Makefiles by clicking on Generate. Now close the window |
accepts all your input create the Makefiles by clicking on Generate. Now close the window |
||
and enter |
and enter |
||
</translate> |
|||
make |
make |
||
make install |
make install |
||
<translate> |
|||
<!--T:75--> |
|||
This will take a couple of minutes. From the command line window change to the FreeCAD bin |
This will take a couple of minutes. From the command line window change to the FreeCAD bin |
||
folder and start the application with ./FreeCAD. In case it complains about some DLLs it cannot |
folder and start the application with ./FreeCAD. In case it complains about some DLLs it cannot |
||
find you have to extend your PATH environment variable with |
find you have to extend your PATH environment variable with |
||
</translate> |
|||
export PATH=$PATH:/usr/local/bin:/usr/local/lib |
export PATH=$PATH:/usr/local/bin:/usr/local/lib |
||
<translate> |
|||
<!--T:76--> |
|||
If no grave problems remains repeating ./FreeCAD should start the application now. |
If no grave problems remains repeating ./FreeCAD should start the application now. |
||
====Note==== |
====Note==== <!--T:77--> |
||
<!--T:78--> |
|||
In order to let CMake detect the boost libraries you must make sure that the |
In order to let CMake detect the boost libraries you must make sure that the |
||
DLLs are in the system path because the check builds some test applications |
DLLs are in the system path because the check builds some test applications |
||
Line 325: | Line 400: | ||
find boost. In this case do a export PATH=/usr/local/lib:$PATH |
find boost. In this case do a export PATH=/usr/local/lib:$PATH |
||
<!--T:79--> |
|||
Have fun! |
Have fun! |
||
<translate> |
|||
<!--T:1--> |
|||
[[Category:Developer_Documentation]] |
|||
[[Category:Developer]] |
|||
</translate> |
</translate> |
||
{{Userdocnavi{{#translation:}}}} |
|||
{{clear}} |
|||
[[Category:Developer_Documentation{{#translation:}}]] |
|||
[[Category:Developer{{#translation:}}]] |
Revision as of 21:38, 20 February 2020
Meanwhile, try other compilation options.
How to build and run FreeCAD under MSYS/MinGW
Prerequisites
Here comes a short introduction how to setup a MSYS/MinGW environment on a Windows system, to build all needed libraries and finally to build the FreeCAD sources.
MSYS/MinGW
If not already installed get a MinGW installer from the Sourceforge page at http://sourceforge.net/projects/mingw. When writing this tutorial the latest version was mingw-get-inst-20100831.exe. Download and just double-click the excutable. This installs the compiler and a minimal Windows developer environment. Make sure to also install the Fortran compiler because there is a single Fortran file in the 3rd party folder of the FreeCAD sources.
Then as second step MSYS needs to be installed to have an environment to run ./configure scripts which we make heavy use of in order to build all needed libraries. From the Soureforge page the file MSYS-1.0.11.exe was taken.
A virginal MSYS/MinGW installation lacks of a few modules we later need. First, we need the utility pexport which can be found in the file pexports-0.44-1-mingw32-bin.tar.lzma. I don't know where to put this file and how to make MSYS to install the stuff inside. But the file can be opened with a ZIP program and the content can be copied to their destination manually. Here, the pexports utility can go to the bin directory of your MinGW installation.
Then, we also need the development files for the pthreads module which is part of the file pthreads-w32-2.8.0-3-mingw32-dev.tar.lzma. Just download and copy the files inside to your MinGW installation.
CMake
Download the CMake utility from http://www.cmake.org/cmake/resources/software.html. Get the archive with the binaries for the Windows platform and unpack whereever you want. There is nothing further to do for this.
SWIG
Download the SWIG utility from www.swig.org and extract it somewhere on your harddisk.
Third party libraries
Here is a description which libraries we need for FreeCAD and how to build them from the sources. In order not to pollute our MinGW installation with too many files from the 3rd party libraries we have to build you can e.g. create a sub-directory "local" in your MSYS installation. If you have installed MSYS under C:\MSYS then simply create the directory C:\MSYS\1.0\local.
zlib
For zlib there is already a ready package for MinGW. So, therefore simply download the file libz-1.2.3-1-mingw32-dev.tar.gz from the Sourceforge site and extract the two directories lib and include to C:\MSYS\1.0\local.
Python
It seems to be nearly impossible to build the Python sources directly with the MinGW compiler. This is because some Python modules require some features which are not implemented on the MinGW platform. Fortunately, the Python sources are plain C code and instead of trying to build it with MinGW you can get a ready binary package built with the MSVC compiler. You can install the Python stuff whereever you want. Afterwards copy the include folder to C:\MSYS\1.0\local, the DLL can go to C:\MSYS\1.0\local\bin.
Now we also need the so called import library. There we cannot use the .lib file which comes together with the installer. But it's easy to create one with the pexports/dlltool utilities. Assuming the Python version is 2.6 do these two steps:
pexports python26.dll > python26.def dlltool -D python26.dll -d python26.def -l libpython26.dll.a
The file libpython26.dll.a can now be moved to C:\MSYS\1.0\local\lib.
f2c
For this library we don't need any header files but only the import library to build the Salome SMESH sources. The easiest way to build this file is:
pexports libgfortran-3.dll > f2c.def dlltool -D libgfortran-3.dll -d f2c.def -l libf2c.dll.a
The file libf2c.dll.a can now be moved to C:\MSYS\1.0\local\lib.
xerces-c
Download a source archive from http://xml.apache.org/dist/xerces-c/ and extract it. Open a MSYS command line window and change to the xerces-c sources. From there run
./configure LDFLAGS=-no-undefined
Once ./configure has finished it's best to move to the source directory because we don't need to build the dozens of test applications and other stuff. So, do this:
cd src make make install
This takes a few minutes to be done.
boost
For boost there exists a testing package with cmake support. This, however, seems to be stable enough to build with the MinGW compiler. So, get the file boost-1.41.0.cmake0.zip from http://sodium.resophonic.com/boost-cmake/1.41.0.cmake0/ and unpack it.
Now, start the cmake-gui.exe from within the MSYS command line. This is necessary for cmake in order to find the compiler and other stuff. Select the folder of the boost sources with the CMakeLists.txt file, select a build directory and start Configure. You'll be asked for which system you want to generate the Makefiles. Select MSYS/Makefiles, not MinGW/Makefiles.
When the configuration step has finished go to the options and search for WINMANGLE_LIBNAMES. Switch this off because otherwise the boost library names contain the compiler name. This causes the boost cmake check to fail later when we try to build the FreeCAD sources. And for the installtion folder choose the directory C:\MSYS\1.0\local.
So, reconfigure boost and press on Generate once it has finished. Close the CMake GUI window and enter
make make install
into the command line. This will take a couple of minutes.
eigen2
Download eigen-2.0.15.tar.gz or any later version from http://eigen.tuxfamily.org/index.php?title=Main_Page. Unpack the files and start again cmake-gui. Set the installation directory to C:\MSYS\1.0\local and press on Configure and Generate. Close the window and start the installation with
make make install
o Qt4 From the Qt website at ftp://ftp.trollech.com you can download already prebuilt packages for the MinGW platform. But depending on the version you have installed it can happen that they don't fit together. In this case the source tarball must be downloaded. Use version 4.5.3 or higher. Unpack the sources and start the configure.exe you'll find inside the sources.
./configure
By default the build the debug and release version. If you only want the release version use the option "-release".
Configure will ask you some questions under which license you want to use Qt. Choose LGPL here. Now run the build with
make
This can take quite some time because Qt has become a really huge library over the years. Once the build has finished run a
make install
to copy the header files to their right place. All the binaries and header files are still inside the source folder. If you like you can copy all the .dll, .a, and the direcories under "include" to the subdirectories of C:\MSYS\1.0\local.
Coin
Get a source archive from www.coin3d.org. Unpack the sources and run
./confiure make make install
It may happen that a message dialog pops up due to a missing cygwin1.dll. You simply ignore this.
SoQt
Get a source archive from www.coin3d.org. Unpack the sources and run
./configure CXXFLAGS="-DCOIN_DLL" --with-qt=/usr/local make make install
In case your Qt development files are not under /usr/local choose the correct directory there. Again a message dialog may pop up due to the missing cygwin1.dll.
PyQt/sip
Warning: the following is obsoleted from version 0.14, since FreeCAD is now using pySide instead of PyQt. At the moment, PySide suport for MingW seems still not complete: https://bugreports.qt-project.org/browse/PYSIDE-113?page=com.atlassian.jira.plugin.system.issuetabpanels%3aall-tabpanel
Download the sources archives for sip and PyQt4 from www.riverbankcomputing.co.uk.
In order to build sip extract the archive and open a MSYS command line. From within its source archive call
python configure.py --platform win32-g++ --destdir=/usr/local make
It may happen that this step aborts because the Python include headers cannot be found. In this case edit the Makefile and add the include path for the ython headers and also the path and filename of the Python library.
Unfortunately, the 'make install' command doesn't work because the Makefile was generated to use Windows batch commands instead of bash commands. Thus, copy the following files to a path where Python can find it, e.g. /usr/local/bin.
sipconfig.py sipdistutils.py siputils.py sip.pyd sip.exe
In order to build PyQt4 extract the source archive and open a MSYS command line. Go to the directory and start
export PATH=/usr/local/lib/:$PATH python configure.py --destdir=/usr/local/lib/site-packages make
Since the Makefile doesn't find the Python header files copy them all and also the file sip.h to a directory where they can be found. A good place seems to be the directory of the Qt sources. There copy the files to $QTDIR/include. The Python library file python26.dll.a can go $QTDIR/lib.
After the build has finished you have to copy all files that end with .pyd to their destination, e.g. /usr/local/lib/site-packages/PyQt4. Lateron when you have built the FreeCAD sources you have to copy the PyQt4 directory and sip.pyd to the FreeCAD bin directory or set a symlink.
ODE
TODO: Still not clear if this will be used. (http://www.ode.org), >= 0.10.x
OpenCASCADE
For the build of the OpenCASCADE libraries get the sources from www.opencascade.org or alternatively it is also possible to download a stripped source tarball from the Debian mirrors which don't include any fonts and other resource files.
Unpack the sources and download a CMake script from http://opencascade-cmake.googlecode.com/svn/trunk/ and the file occ_config.h.cmake. Copy both files into the 'ros' directory, start cmake-gui from within a MSYS command line and select MSYS Makefiles. In the options the following switches can be disabled:
OPENCASCADE_WRAPPERS OPENCASCADE_VISUALISATION OPENCASCADE_OCAF OPENCASCADE_DRAW
Then specify for OPENCASCADE_INSTALL_PREFIX C:/MSYS/1.0/local as destination directory-
Now click the Configure button which takes a while and afterwards the Generate button.
Note 1
The original sources don't completely compile with MinGW. Therefore you have to apply the patch OpenCASCADE6.3.0-MinGW.patch from http://code.google.com/p/opencascade-cmake/source/browse/trunk
Note 2
The original sources includes also a configure script and the Makefile.am files. But it appeared to be very hard to build the libraries this way. Thus, it highly recommended to do it the CMake way.
Note 3
For a couple of libraries the arguments passed to the linker exceeds the number of allowed characters and thus the linker stops with an error: "Bad file number". To solve this issue you can open the file build.make of the according library and split the block (e.g. TKGeomAlgo_OBJECTS) into several smaller ones and modify the build rule this way that you create first a static library, add the other object files to the group and then unpack the static archive into one directory. This trick solves the problem to reduce the whole number of characters. Afterwards the shared library can be built out of these object files.
Example: If the build.make file has a line of the form
g++ <options> -shared -o libTKGeomAlgo.dll $(TKGeomAlgo_OBJECTS) <libs>
then change it into
ar rcs win32/libTKGeomAlgo.a $(TKGeomAlgo_OBJECTS1) ar q win32/libTKGeomAlgo.a $(TKGeomAlgo_OBJECTS2) ... ar x win32/libTKGeomAlgo.a g++ <options> -shared -o libTKGeomAlgo.dll *.obj <libs> rm -f *.obj
Netgen
Modify the following files:
- libsrc/meshing/improve2.hpp
Add DLL_HEADER to class MeshOptimize2d
- libsrc/meshing/meshclass.hpp
Add DLL_HEADER to CalcSurfacesOfNode
- libsrc/meshing/meshtype.hpp
Add DLL_HEADER to classes SurfaceElementIndex, MeshPoint, Element2d (int anp),
- libsrc/occ/occgeom.hpp
Add DLL_HEADER to classes Line, OCCGeometry, OCCParameters, OCCGenerateMesh
- libsrc/occ/occmeshsurf.hpp
Add DLL_HEADER to classes OCCSurface, Meshing2OCCSurfaces, MeshOptimize2dOCCSurfaces, OCCRefinementSurfaces
Run the configure script with these arguments
./configure --prefix=/usr/local --enable-shared --enable-occ --with-occ=/usr/local --with-tcl=/usr/local/lib --enable-nglib CXXFLAGS="-DNGLIB_EXPORTS -DWNT" make && make install
Building the FreeCAD sources
In order build the FreeCAD sources either get the developer sources from the SVN repository or get one of the .tar.gz tarballs and extract it. Now start cmake-gui.exe from within a MSYS command line window and browse to the FreeCAD sources and also define the build directory. Now run Configure. It may happen that cmake complains about some not found libraries. In this case go through the listed libraries and choose the include directory and/or the path to the library where needed. Once Confgiure accepts all your input create the Makefiles by clicking on Generate. Now close the window and enter
make make install
This will take a couple of minutes. From the command line window change to the FreeCAD bin folder and start the application with ./FreeCAD. In case it complains about some DLLs it cannot find you have to extend your PATH environment variable with
export PATH=$PATH:/usr/local/bin:/usr/local/lib
If no grave problems remains repeating ./FreeCAD should start the application now.
Note
In order to let CMake detect the boost libraries you must make sure that the DLLs are in the system path because the check builds some test applications and tries to start them. If the DLLs are not in path CMake says that it cannot find boost. In this case do a export PATH=/usr/local/lib:$PATH
Have fun!
- Getting started
- Installation: Download, Windows, Linux, Mac, Additional components, Docker, AppImage, Ubuntu Snap
- Basics: About FreeCAD, Interface, Mouse navigation, Selection methods, Object name, Preferences, Workbenches, Document structure, Properties, Help FreeCAD, Donate
- Help: Tutorials, Video tutorials
- Workbenches: Std Base, Arch, Assembly, CAM, Draft, FEM, Inspection, Mesh, OpenSCAD, Part, PartDesign, Points, Reverse Engineering, Robot, Sketcher, Spreadsheet, Start, Surface, TechDraw, Test Framework, Web
- Hubs: User hub, Power users hub, Developer hub