Niels Horn's Blog
Random thoughts, tips & tricks about Slackware-Linux, Lego and Star WarsFreeCAD, OpenCASCADE and Pivy updated - Slackware packages available
August 14th, 2011 by Niels Horn in CAD, FreeCAD, OpenCASCADE, Pivy, Slackware
Updating FreeCAD was long over due - the last package I built was for 0.9.2646 and they're currently in the 0.11 series. But it is not a simple package to build - it requires some time and patience to get it all right…
Dependencies
FreeCAD is based on OpenCASCADE, which has been updated a few times since the last time I built a package for it. FreeCAD also depends on a few other libraries: Pivy, SoQt, Coin and xerxes-c. Of these, Pivy also needed an update, so I started with this one.
Updating Pivy
This update was simple. I just got the latest "tag" from the Mercurial repository (there are no tarballs for Pivy) and cleaned up the SlackBuild a bit. Pivy needs Coin and SoQt to build. It takes some time to build, but all went fine.
The updated script was submitted and the new packages were uploaded. I also put a tarball with the snapshot from the Mercurial repository on my site, to make it easier to build and to guarantee that the correct version is used.
OpenCASCADE
OpenCASCADE has never been a simple package to compile. It is huge (sources are > 200MB) and takes some time to build (two hours on my desktop). And worst: it never builds the first time without errors
First it gave some of those dreaded "not declared in this scope" errors.
These errors are caused by stricter checking in the newer gcc versions (actually since 4.3, and Slackware 13.37 is already on 4.5). As usual, they were easily fixed with a small patch putting an extra "include" in the source code.
This is the patch:
--- OpenCASCADE-6.5.1/ros/src/OSD/OSD_MAllocHook.cxx 2011-05-19 08:24:52.000000000 -0300 +++ OpenCASCADE-6.5.1_patched/ros/src/OSD/OSD_MAllocHook.cxx 2011-08-10 12:39:39.000000000 -0300 @@ -10,6 +10,7 @@ #define __STDC_LIMIT_MACROS #endif #include <stdint.h> +#include <stdlib.h> #endif #include <set>
But that was not all. I soon discovered (after compilation complaining that FTFont.h
was missing) that OpenCASCADE now depends on ftgl. Well, that should have been simple to resolve, as there is a ftgl SlackBuild on SlackBuilds.org.
OK, not that simple - it did not work.
Researching a bit on the internet, I found that they used an older version of ftgl, but the guys from OpenSUSE had already written a patch to solve this and can be found here.
After this, I was able to successfully build OpenCASCADE 6.5.1
I just added one thing to the SlackBuild - an option to include all the documentation. Most of it is available online and only interesting if your writing your own programs based on OpenCASCADE, not for users of FreeCAD for example. And we're talking about 600MB of documentation…
So, the new script was also submitted and the pre-built packages uploaded.
Finally, FreeCAD
OK, so now I could start building FreeCAD, having all the dependencies ready on my machine!
The old problem with the boost libraries continued in the 0.11.3729 sources, to my surprise, but I substituted the original patch with a sed command, to make it easier to maintain:
sed -i "/-lboost/s/-mt\"/\"/g" configure
And two new problems appeared: the name of a function in OpenCASCADE had changed in 6.5.0 and a code for an error condition (according to OpenCASCADE never used) was removed.
I managed to write a small patch to get FreeCAD to compile with OpenCASCADE 6.5.0:
--- FreeCAD-0.11.3729/src/3rdParty/salomesmesh/src/SMESH/SMESH_MeshEditor.cpp 2010-10-17 05:59:46.000000000 -0200 +++ FreeCAD-0.11.3729_patched/src/3rdParty/salomesmesh/src/SMESH/SMESH_MeshEditor.cpp 2011-08-10 20:04:59.000000000 -0300 @@ -2205,8 +2205,8 @@ if ( projector.IsDone() ) { double u, v, minVal = DBL_MAX; for ( int i = projector.NbExt(); i > 0; i-- ) - if ( projector.Value( i ) < minVal ) { - minVal = projector.Value( i ); + if ( projector.SquareDistance( i ) < minVal ) { + minVal = projector.SquareDistance( i ); projector.Point( i ).Parameter( u, v ); } result.SetCoord( u, v ); --- FreeCAD-0.11.3729/src/3rdParty/salomesmesh/src/SMESH/SMESH_Pattern.cpp 2010-10-17 05:59:46.000000000 -0200 +++ FreeCAD-0.11.3729_patched/src/3rdParty/salomesmesh/src/SMESH/SMESH_Pattern.cpp 2011-08-10 20:06:21.000000000 -0300 @@ -436,8 +436,8 @@ } double u, v, minVal = DBL_MAX; for ( int i = theProjectorPS.NbExt(); i > 0; i-- ) - if ( theProjectorPS.Value( i ) < minVal ) { - minVal = theProjectorPS.Value( i ); + if ( theProjectorPS.SquareDistance( i ) < minVal ) { + minVal = theProjectorPS.SquareDistance( i ); theProjectorPS.Point( i ).Parameter( u, v ); } return gp_XY( u, v ); --- FreeCAD-0.11.3729/src/Mod/Part/App/PrimitiveFeature.cpp 2010-08-27 11:22:14.000000000 -0300 +++ FreeCAD-0.11.3729_patched/src/Mod/Part/App/PrimitiveFeature.cpp 2011-08-10 20:41:35.000000000 -0300 @@ -141,9 +141,6 @@ case BRepBuilderAPI_ParametersOutOfRange: error = "parameters out of range"; break; - case BRepBuilderAPI_SurfaceNotC2: - error = "surface not C2"; - break; default: error = "unknown error"; break; --- FreeCAD-0.11.3729/src/Mod/Part/App/TopoShape.cpp 2010-11-14 06:53:08.000000000 -0200 +++ FreeCAD-0.11.3729_patched/src/Mod/Part/App/TopoShape.cpp 2011-08-10 20:43:03.000000000 -0300 @@ -139,8 +139,6 @@ return "Curve projection failed"; case BRepBuilderAPI_ParametersOutOfRange: return "Parameters out of range"; - case BRepBuilderAPI_SurfaceNotC2: - return "Surface not C2-continous"; default: return "Unknown creation error"; }
With this, I successfully build FreeCAD 0.11.3729 on Slackware!
Extra package
OpenCASCADE now has an optional dependency called gl2ps so I built a package for this as well.
Doing so, I needed to write a small patch to put the libraries in the correct /usr/lib64 directory on Slackware64:
--- gl2ps-1.3.5-source/CMakeLists.txt 2009-10-16 16:14:07.000000000 -0300 +++ gl2ps-1.3.5-source_patched/CMakeLists.txt 2011-08-10 17:24:43.000000000 -0300 @@ -113,7 +113,7 @@ set_target_properties(shared PROPERTIES COMPILE_FLAGS "-DGL2PSDLL -DGL2PSDLL_EXPORTS") endif(MSVC) - install(TARGETS lib shared DESTINATION lib) + install(TARGETS lib shared DESTINATION lib${LIB_SUFFIX}) endif(OPENGL_FOUND) if(WIN32)
Where to get it
All scripts have been submitted to SlackBuilds.org.
If you don't feel like spending about three hours building packages, you can get them ready-to-install from my site.