Edubuntu 14.04 LTS でFreeCADのビルド

Edubuntu 14.04 LTS x64版でFreeCAD 次期リリース予定の0.14系をビルドする時のメモ。

Edubuntu 14.04 LTSをインストールしたばかりの状態のときに

sudo apt-get build-dep

で導入される依存関係

  autotools-dev build-essential cmake cmake-data debhelper dh-apparmor
  dpkg-dev g++ g++-4.8 gfortran gfortran-4.8 gir1.2-gtk-2.0 icu-devtools
  libatk1.0-dev libavcodec-dev libavformat-dev libavutil-dev
  libboost-atomic1.54-dev libboost-atomic1.54.0 libboost-chrono1.54-dev
  libboost-chrono1.54.0 libboost-date-time-dev libboost-date-time1.54-dev
  libboost-dev libboost-filesystem-dev libboost-filesystem1.54-dev
  libboost-filesystem1.54.0 libboost-graph-dev libboost-graph1.54-dev
  libboost-graph1.54.0 libboost-iostreams-dev libboost-iostreams1.54-dev
  libboost-iostreams1.54.0 libboost-program-options-dev
  libboost-program-options1.54-dev libboost-python-dev libboost-python1.54-dev
  libboost-regex-dev libboost-regex1.54-dev libboost-regex1.54.0
  libboost-serialization-dev libboost-serialization1.54-dev
  libboost-serialization1.54.0 libboost-signals-dev libboost-signals1.54-dev
  libboost-signals1.54.0 libboost-system1.54-dev libboost-test1.54-dev
  libboost-test1.54.0 libboost-thread-dev libboost-thread1.54-dev
  libboost1.54-dev libcairo-script-interpreter2 libcairo2-dev libcoin80
  libcoin80-dev libcv-dev libdc1394-22-dev libdrm-dev libeigen3-dev
  libexpat1-dev libf2c2 libf2c2-dev libfltk-cairo1.3 libfltk-forms1.3
  libfltk-gl1.3 libfltk-images1.3 libfltk1.3 libfltk1.3-dev libfontconfig1-dev
  libfreeimage-dev libfreeimage3 libfreetype6-dev libgdk-pixbuf2.0-dev
  libgfortran-4.8-dev libgl1-mesa-dev libgl2ps-dev libglib2.0-dev
  libglu1-mesa-dev libgtk2.0-dev libgts-0.7-5 libgts-bin libgts-dev
  libharfbuzz-dev libharfbuzz-gobject0 libice-dev libicu-dev libilmbase-dev
  libjasper-dev libjbig-dev libjpeg-dev libjpeg-turbo8-dev libjpeg8-dev
  liblzma-dev liboce-foundation-dev liboce-foundation8 liboce-modeling-dev
  liboce-modeling8 liboce-ocaf-dev liboce-ocaf-lite-dev liboce-ocaf-lite8
  liboce-ocaf8 liboce-visualization-dev liboce-visualization8 libode-dev
  libode1 libopencv-calib3d-dev libopencv-core-dev libopencv-features2d-dev
  libopencv-flann-dev libopencv-highgui-dev libopencv-imgproc-dev
  libopencv-legacy-dev libopencv-ml-dev libopencv-objdetect-dev
  libopencv-ocl-dev libopencv-ocl2.4 libopencv-video-dev libopenexr-dev
  libpango1.0-dev libpcre3-dev libpcrecpp0 libpixman-1-dev libpng12-dev
  libpthread-stubs0-dev libpython-dev libpython2.7-dev libqt4-dev
  libqt4-dev-bin libqt4-opengl-dev libqtwebkit-dev libraw1394-dev libsm-dev
  libsoqt-dev-common libsoqt4-20 libsoqt4-dev libspnav-dev libspnav0
  libstdc++-4.8-dev libswscale-dev libtcl8.5 libtiff5-dev libtiffxx5 libtk8.5
  libtool libx11-dev libx11-xcb-dev libxau-dev libxcb-dri2-0-dev
  libxcb-dri3-dev libxcb-glx0-dev libxcb-present-dev libxcb-randr0-dev
  libxcb-render0-dev libxcb-shape0-dev libxcb-shm0-dev libxcb-sync-dev
  libxcb-xfixes0-dev libxcb1-dev libxcomposite-dev libxcursor-dev
  libxdamage-dev libxdmcp-dev libxerces-c-dev libxext-dev libxfixes-dev
  libxft-dev libxi-dev libxinerama-dev libxmu-dev libxmu-headers libxpm-dev
  libxrandr-dev libxrender-dev libxshmfence-dev libxss-dev libxt-dev
  libxxf86vm-dev libzipios++-dev libzipios++0c2a mesa-common-dev oce-draw
  po-debconf python-cxx-dev python-dev python2.7-dev qt4-dev-tools
  qt4-linguist-tools qt4-qmake swig swig2.0 tcl8.5 tcl8.5-dev tk8.5 tk8.5-dev
  x11proto-composite-dev x11proto-core-dev x11proto-damage-dev
  x11proto-dri2-dev x11proto-fixes-dev x11proto-gl-dev x11proto-input-dev
  x11proto-kb-dev x11proto-randr-dev x11proto-render-dev
  x11proto-scrnsaver-dev x11proto-xext-dev x11proto-xf86vidmode-dev
  x11proto-xinerama-dev xorg-sgml-doctools xtrans-dev zlib1g-dev

apt-get build-dep だけでは解決されない依存関係にあるパッケージ

$ apt-cache show shibokenPackage: shiboken
Priority: optional
Section: universe/devel
Installed-Size: 1854
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Original-Maintainer: Debian Python Modules Team <python-modules-team@lists.alioth.debian.org>
Architecture: amd64
Version: 1.2.1-3build1
Depends: libc6 (>= 2.14), libgcc1 (>= 1:4.1.1), libqt4-xml (>= 4:4.7.0), libqt4-xmlpatterns (>= 4:4.7.0), libqtcore4 (>= 4:4.8.0), libstdc++6 (>= 4.4.0), libxml2 (>= 2.7.4), libxslt1.1 (>= 1.1.25)
Filename: pool/universe/s/shiboken/shiboken_1.2.1-3build1_amd64.deb
Size: 626160
MD5sum: 6a14ffb3840954374037fa6ce8685aa5
SHA1: 47c2062824ebda37c84e78184ce8f90300d8a058
SHA256: ad7a5e3979232dde9a9a59fe4898b105a5fa7bd4486bf4264a21fd4b8c36b986
Description-en: CPython bindings generator for C++ libraries
 Shiboken is a bindings generator for C++ libraries that outputs CPython
 source code. It collects information from library headers, and then
 merges modifications and handwritten code defined in the typesystem
 description.
 .
 Shiboken is the binding generator used to create the PySide bindings.
Description-md5: 33001ed1fff8558f414b5f6812c495b1
Homepage: http://www.pyside.org/
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Origin: Ubuntu
$ apt-cache search shibokenlibshiboken-dev - development files for the shiboken bindings generator library
libshiboken-py3-1.2 - CPython3 bindings generator for C++ libraries - shared library
libshiboken1.2 - CPython bindings generator for C++ libraries - shared library
shiboken - CPython bindings generator for C++ libraries
shiboken-dbg - debugging symbols for shiboken and its library
shiboken-doc - CPython bindings generator for C++ libraries documentation
maho-maho@kasago432:~/src/freecad/Build-Freecad$ apt-cache show libshiboken-devPackage: libshiboken-dev
Priority: optional
Section: universe/libdevel
Installed-Size: 165
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Original-Maintainer: Debian Python Modules Team <python-modules-team@lists.alioth.debian.org>
Architecture: amd64
Source: shiboken
Version: 1.2.1-3build1
Depends: python-dev, libshiboken1.2 (= 1.2.1-3build1), libshiboken-py3-1.2 (= 1.2.1-3build1)
Filename: pool/universe/s/shiboken/libshiboken-dev_1.2.1-3build1_amd64.deb
Size: 21138
MD5sum: 628ce62abea9a07e110eb1799e6705f6
SHA1: 99a0548792ff27208c527a81648dbc41150e1079
SHA256: e41283891a08467a6ff4cceefe05c977a469ff46bec8fe4a1dee9d2e7fb00190
Description-en: development files for the shiboken bindings generator library
 Shiboken is a bindings generator for C++ libraries that outputs CPython
 source code. It collects information from library headers, and then
 merges modifications and handwritten code defined in the typesystem
 description.
 .
 This package contains the development files for the library.
Description-md5: 98e6f77fc817edc44e7c3f9a9d9de7f1
Homepage: http://www.pyside.org/
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Origin: Ubuntu
$ apt-cache show libpyside-dev
Package: libpyside-dev
Priority: optional
Section: universe/libdevel
Installed-Size: 1204
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Original-Maintainer: Debian Python Modules Team <python-modules-team@lists.alioth.debian.org>
Architecture: amd64
Source: pyside
Version: 1.2.1-4build1
Replaces: libpyside0.3 (<< 0.4.0)
Depends: libpyside1.2 (= 1.2.1-4build1), libpyside-py3-1.2 (= 1.2.1-4build1), libqt4-dev (>= 4:4.7.0)
Breaks: libpyside0.3 (<< 0.4.0)
Filename: pool/universe/p/pyside/libpyside-dev_1.2.1-4build1_amd64.deb
Size: 103658
MD5sum: 7d93dc8f62741120cc8b36df37c43e1f
SHA1: 531745cf37eb735f5371d2b8d5d01f03a6866809
SHA256: f03f12a2129e4ade471e4f7617a97c4386cf1edd7dcd389c3d4c83087f2ab221
Description-ja: Qt 4 用 Python バインディング (開発用ファイル)
 Qt は、クロスプラットフォームな C++ アプリケーションフレームワークです。Qt の一番の特徴は、cmake-qt-gui標準的な GUI
 機能を提供する豊富なウィジェットセットです。
 .
 このパッケージは libpyside ライブラリの開発用ヘッダを提供します。
Description-md5: 6faf275ae65de581cef049209922a69a
Homepage: http://www.pyside.org/
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Origin: Ubuntu
$ apt-cache show python-matplotlib
Package: python-matplotlib
Priority: optional
Section: universe/python
Installed-Size: 7653
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Original-Maintainer: Debian Python Modules Team <python-modules-team@lists.alioth.debian.org>
Architecture: amd64
Source: matplotlib
Version: 1.3.1-1ubuntu5
Depends: python-dateutil, python-matplotlib-data (>= 1.3.1-1ubuntu5), python-pyparsing, python-tz, python (<< 2.8), python (>= 2.7), python-numpy (>= 1:1.8.0), python-numpy-abi9, python-support (>= 0.90.0), libc6 (>= 2.14), libfreetype6 (>= 2.2.1), libgcc1 (>= 1:4.1.1), libgdk-pixbuf2.0-0 (>= 2.22.0), libglib2.0-0 (>= 2.12.0), libgtk2.0-0 (>= 2.8.0), libpng12-0 (>= 1.2.13-4), libstdc++6 (>= 4.6), libtcl8.6 (>= 8.6.0), libtk8.6 (>= 8.6.0)
Recommends: python-glade2, python-imaging, python-tk (>= 2.5.2-1.1)
Suggests: dvipng, gir1.2-gtk-3.0, ghostscript, inkscape, ipython (>= 0.6.3), librsvg2-common, python-cairo, python-configobj, python-excelerator, python-gobject, python-gtk2, python-matplotlib-doc, python-nose, python-qt4, python-scipy, python-sip, python-tornado, python-traits (>= 2.0), python-wxgtk2.8, texlive-extra-utils, texlive-latex-extra, ttf-staypuft
Filename: pool/universe/m/matplotlib/python-matplotlib_1.3.1-1ubuntu5_amd64.deb
Size: 1421320
MD5sum: 6a712780a745b4c7cda5a07f59874d58
SHA1: b6d423f66729ffb8721af1f323c9afc38ae7f655
SHA256: 9e8aa35315dce32a4c1979fdd8b4dbbdac360ca653ef5fe23a14df51146561e3
Description-en: Python based plotting system in a style similar to Matlab
 Matplotlib is a pure Python plotting library designed to bring
 publication quality plotting to Python with a syntax familiar to
 Matlab users. All of the plotting commands in the pylab interface can
 be accessed either via a functional interface familiar to Matlab
 users or an object oriented interface familiar to Python users.
Description-md5: 2fece2cb7cd156344f82cc6d7070bac0
Enhances: ipython
Homepage: http://matplotlib.org/
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Origin: Ubuntu
Supported: 3y
Task: ubuntustudio-video

デバックシンボルの導入

sudo apt-get install libboost-dbg libc6-dbg \
libcairo2-dbg libdc1394-22-dbg libdrm-nouveau2-dbg \
libdrm2-dbg libegl1-mesa-drivers-dbg libfltk1.3-dbg \
libfontconfig1-dbg libfreeimage3-dbg libgcc1-dbg \
libgdk-pixbuf2.0-0-dbg libgfortran3-dbg \
libgl1-mesa-dri-dbg libgl1-mesa-glx-dbg libgl2ps0-dbg \
libglib2.0-0-dbg libgtk2.0-0-dbg libgts-dbg \
libice6-dbg libicu52-dbg libjpeg-turbo8-dbg \
libjpeg8-dbg libpango1.0-0-dbg libpcre3-dbg \
libpixman-1-0-dbg libqt4-dbg libqt4-webkit-dbg \
libqtwebkit4-dbg libraw1394-11-dbg libsm6-dbg \
libstdc++6-4.8-dbg libtcl8.6-dbg libwayland-egl1-mesa-dbg \
libx11-xcb1-dbg libxau6-dbg libxcb-dri2-0-dbg \
libxcb-dri3-0-dbg libxcb-glx0-dbg libxcb-present0-dbg \
libxcb-randr0-dbg libxcb-render0-dbg libxcb-shape0-dbg \
libxcb-sync1-dbg libxcb-xfixes0-dbg libxcb1-dbg \
libxcomposite1-dbg libxcursor1-dbg libxdamage1-dbg \
libxdmcp6-dbg libxext6-dbg libxfixes3-dbg libxft2-dbg \
libxi6-dbg libxinerama1-dbg libxmu6-dbg libxpm4-dbg \
libxrandr2-dbg libxrender1-dbg libxss1-dbg libxt6-dbg \
libxxf86vm1-dbg python-dbg python-qt4-dbg python-tk-dbg \
xserver-xorg-core-dbg zlib1g-dbg

ビルド作業ディレクトリで実行する cmake のコマンドライン(QTのIDEプロジェクトを生成する場合の例)。

cmake -DCMAKE_BUILD_TYPE=Debug -G'KDevelop3 - Unix Makefiles' \
-DCOIN3D_DOC_PATH=/usr/share/doc/libcoin80-doc \
-DFREECAD_USE_EXTERNAL_PIVY=true ../FreeCAD_sf_master/

このとき、FreeCADのソースツリーにあるPivyコードを弄りたくない場合は、 FREECAD_USE_EXTERNAL_PIVY=true で、Pivyコードのビルドをさせないようにする。

FREECAD_USE_EXTERNAL_PIVY=true の問題点

FREECAD_USE_EXTERNAL_PIVY=true で、システムにインストールされたPython-pivy を参照するように指定してみたところ、なぜかドラフト・ワークベンチが起動しない。

Error: Pivy not found, Draft workbench will be disabled.

というエラーメッセージがターミナルにあった。そこでFreeCADのPythonコンソールを開いて、

import pivy

ステートメントを打ち込んでみると、トレースバックが帰ってきた。

Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/home/username/src/freecad/Build-Freecad/bin/pivy/__init__.py", line 28, in <module>
    from coin import SoDB, SoNodeKit, SoInteraction
  File "/home/username/src/freecad/Build-Freecad/bin/pivy/coin.py", line 14, in <module>
    import _coin
ImportError: No module named _coin

といった具合に、内部コードのPATHを検索しているので、若干の修正が必要であるが、システムにインストールされているpythonインタープリタにて同様のエラーが再現される場合はシステムの環境設定に問題がある。
解決方法が見つかるまでの回避策として、FreeCADの起動オプションでモジュールのパスを指定する方法がある。

./FreeCAD -M /usr/lib/python2.7/dist-packages/

libcoin80-devを用いたときに内部Pivyコードで検討すること

libcoin60 にあった Inventor/scxml/ScXMLInvoke.h*1 が、libcoin80には存在しない。
もっともメソッド名が似ているヘッダファイルは Inventor/scxml/ScXMLInvokeElt.h*2 である。
そのほか、Inventor/elements/SoGLTexture3EnabledElement.h*3 が、廃止予定にあがっているとプリプロセッサが指摘してくる。
代わりにInventor/elements/SoMultiTextureEnabledElement.h*4をつかうようだ。

diff --git a/src/3rdParty/Pivy-0.5/coin_header_includes.h b/src/3rdParty/Pivy-0.
index af048fd..9cb9ed0 100644
--- a/src/3rdParty/Pivy-0.5/coin_header_includes.h
+++ b/src/3rdParty/Pivy-0.5/coin_header_includes.h
@@ -142,7 +142,14 @@
 #include <Inventor/elements/SoGLProjectionMatrixElement.h>
 #include <Inventor/elements/SoGLRenderPassElement.h>
 #include <Inventor/elements/SoGLShapeHintsElement.h>
-#include <Inventor/elements/SoGLTexture3EnabledElement.h>
+
+#if COIN_MAJOR_VERSION < 4 // For Deprecated
+ #include <Inventor/elements/SoGLTexture3EnabledElement.h>
+#else // use instead
+ #include <Inventor/elements/SoMultiTextureEnabledElement.h>
+ #include <Inventor/elements/SoLazyElement.h>
+#endif
+
 #include <Inventor/elements/SoGLTextureCoordinateElement.h>
 #include <Inventor/elements/SoGLTextureEnabledElement.h>
 #include <Inventor/elements/SoGLTextureImageElement.h>
@@ -665,10 +672,15 @@
 #include <Inventor/SoRenderManager.h>
 #include <Inventor/scxml/ScXMLEvent.h>
 #include <Inventor/scxml/ScXML.h>
-#include <Inventor/scxml/ScXMLInvoke.h>
+ #if COIN_MAJOR_VERSION > 3 // instead
+  #include <Inventor/scxml/ScXMLInvokeElt.h>
+ #else // obsolete
+  #include <Inventor/scxml/ScXMLInvoke.h>
+ #endif
 #include <Inventor/scxml/ScXMLObject.h>
 #include <Inventor/scxml/ScXMLStateMachine.h>
 #include <Inventor/scxml/ScXMLSubObject.h>
 #include <Inventor/scxml/SoScXMLEvent.h>
 #include <Inventor/scxml/SoScXMLStateMachine.h>
 #endif
+

ビルドエラーが出るファイル /FreeCAD_sf_master/src/3rdParty/Pivy-0.5/coin_wrap.cpp には

/* ----------------------------------------------------------------------------
 * This file was automatically generated by SWIG (http://www.swig.org).
 * Version 1.3.36
 * 
 * This file is not intended to be easily readable and contains a number of 
 * coding conventions designed to improve portability and efficiency. Do not make
 * changes to this file unless you know what you are doing--modify the SWIG 
 * interface file instead. 
 * ----------------------------------------------------------------------------- */

とあるので、生成方法を学習するまでは手出しできない。

ちなみに自動生成ファイルを検索してみると

 grep automatically\ generated -r ../FreeCAD_sf_master/src/3rdParty/Pivy/
../FreeCAD_sf_master/src/3rdParty/Pivy/soqt_wrap.cpp: * This file was automatically generated by SWIG (http://www.swig.org).
../FreeCAD_sf_master/src/3rdParty/Pivy/coin.py:# This file was automatically generated by SWIG (http://www.swig.org).
../FreeCAD_sf_master/src/3rdParty/Pivy/gui/soqt.py:# This file was automatically generated by SWIG (http://www.swig.org).
../FreeCAD_sf_master/src/3rdParty/Pivy/coin_wrap.cpp: * This file was automatically generated by SWIG (http://www.swig.org).

がヒットした。

脚注