d3b343fee4ed0ab7a0cec56a7218a05f156fcdcd
[occt.git] / dox / dev_guides / building / 3rdparty / 3rdparty_linux.md
1  Building 3rd-party libraries on Linux {#occt_dev_guides__building_3rdparty_linux}
2 =========
3
4 @tableofcontents 
5
6 @section dev_guides__building_3rdparty_linux_1 Introduction
7
8 This document presents additional guidelines for building third-party 
9 products used by Open CASCADE Technology and samples on Linux platform. 
10
11 The links for downloading the third-party products are available on the web site 
12 of OPEN CASCADE SAS at 
13 http://www.opencascade.org/getocc/require/. 
14
15 There are two types of third-party products, which are  necessary to build OCCT: 
16   
17 * Mandatory  products: 
18         * Tcl/Tk 8.5 - 8.6;  
19         * FreeType 2.4.10 - 2.4.11;
20 * Optional  products: 
21         * TBB 3.x - 4.x;
22         * gl2ps 1.3.5 - 1.3.8;
23         * FreeImage 3.14.1 - 3.15.4.
24
25 @section dev_guides__building_3rdparty_linux_2 Building Mandatory Third-party Products
26
27 @subsection dev_guides__building_3rdparty_linux_2_1 Tcl/Tk 
28
29 Tcl/Tk is required for DRAW test harness. 
30
31 @subsubsection dev_guides__building_3rdparty_linux_2_1_1 Installation from binaries:
32
33 It is possible to download ready-to-install binaries from 
34 http://www.activestate.com/activetcl/downloads
35
36 1. Download the binaries archive and unpack them to a directory, which is further referred to as *TCL_SRC_DIR*. 
37 2. Enter the directory *TCL_SRC_DIR*.
38
39        cd TCL_SRC_DIR
40
41 3. Run the install command:
42
43        install.sh
44     
45    and follow the instructions. 
46
47 @subsubsection dev_guides__building_3rdparty_linux_2_1_2 Installation from sources: Tcl
48   
49 Download the necessary archive from http://www.tcl.tk/software/tcltk/download.html and unpack it. 
50   
51 1. Enter the unix sub-directory of the directory where the Tcl source  files are located <i>(TCL_SRC_DIR)</i>. 
52
53        cd TCL_SRC_DIR/unix   
54
55 2. Run the *configure* command:
56
57        configure --enable-gcc  --enable-shared --enable-threads --prefix=TCL_INSTALL_DIR   
58
59    For a 64 bit platform also add <i>--enable-64bit</i> option to the command line. 
60   
61 3. If the configure command has finished successfully, start  the building process:
62   
63        make   
64
65 4. If building is finished successfully, start the installation of Tcl. 
66    All binary and service files of the product will be copied to the directory defined by *TCL_INSTALL_DIR* 
67
68        make install   
69
70 @subsubsection dev_guides__building_3rdparty_linux_2_1_3 Installation from sources: Tk
71   
72 Download the necessary archive from http://www.tcl.tk/software/tcltk/download.html and unpack it. 
73   
74 1. Enter the unix sub-directory of the directory where the Tk source files are located <i>(TK_SRC_DIR)</i> 
75
76        cd TK_SRC_DIR/unix   
77
78 2. Run the configure command, where <i>TCL_LIB_DIR</i> is *TCL_INSTALL_DIR/lib*.
79
80        configure --enable-gcc  --enable-shared --enable-threads --with-tcl=TCL_LIB_DIR  --prefix=TK_INSTALL_DIR   
81
82    For a 64 bit platform also add <i>--enable-64bit</i> option to the  command line. 
83
84 3. If the configure command has finished successfully, start the building process: 
85
86        make   
87
88 4. If the building has finished successfully, start the installation of Tk. 
89    All binary and service files of the product will be copied 
90    to the directory defined by *TK_INSTALL_DIR* (usually it is *TCL_INSTALL_DIR*) 
91
92        make install   
93
94 @subsection dev_guides__building_3rdparty_linux_2_2 FreeType
95
96 FreeType is required for text display in the 3D viewer. 
97 Download the necessary archive from http://sourceforge.net/projects/freetype/files/ and unpack it. 
98   
99 1. Enter the directory where the source files of FreeType  are located <i>(FREETYPE_SRC_DIR)</i>. 
100
101        cd FREETYPE_SRC_DIR   
102
103 2. Run the *configure* command: 
104   
105        configure  --prefix=FREETYPE_INSTALL_DIR   
106
107    For a 64 bit platform also add <i>CFLAGS='-m64 -fPIC'  CPPFLAGS='-m64 -fPIC'</i> option to the command line. 
108     
109 3. If the *configure* command has finished successfully, start  the building process: 
110
111        make   
112
113 4. If the building has finished successfully, start the installation of FreeType. 
114    All binary and service files of the product will be copied to the directory defined by *FREETYPE_INSTALL_DIR* 
115     
116        make install   
117
118 @section dev_guides__building_3rdparty_linux_3 Building Optional Third-party Products
119     
120 @subsection dev_guides__building_3rdparty_linux_3_1 TBB
121
122 This third-party product is  installed with binaries from the archive that can be downloaded from http://threadingbuildingblocks.org. 
123 Go to the **Download** page, find the  release version you need and pick the archive for Linux  platform. 
124 To install, unpack the downloaded archive of TBB product.
125
126 @subsection dev_guides__building_3rdparty_linux_3_2 gl2ps
127
128 Download the necessary archive from http://geuz.org/gl2ps/ and unpack it.
129   
130 1. Install or build *cmake* product from the source file. 
131 2. Start *cmake* in GUI mode with the directory where the source files of gl2ps are located:
132
133        ccmake GL2PS_SRC_DIR   
134
135    * Press <i>[c]</i> to make the  initial configuration; 
136    * Define the necessary options in *CMAKE_INSTALL_PREFIX* 
137    * Press <i>[c]</i> to make the final  configuration 
138    * Press <i>[g]</i> to generate  Makefile and exit 
139
140    or just run the following command: 
141
142        cmake  –DCMAKE_INSTALL_PREFIX=GL2PS_INSTALL_DIR –DCMAKE_BUILD_TYPE=Release   
143
144 3. Start the building of gl2ps: 
145
146        make   
147
148 4. Start the installation of gl2ps. Binaries will be  installed according to the *CMAKE_INSTALL_PREFIX* option. 
149
150        make install   
151
152 @subsection dev_guides__building_3rdparty_linux_3_3 FreeImage
153
154 Download the necessary archive from http://sourceforge.net/projects/freeimage/files/Source%20Distribution/
155 and unpack it. The directory with unpacked sources is  further referred to as *FREEIMAGE_SRC_DIR*. 
156   
157 1. Modify *FREEIMAGE_SRC_DIR/Source/OpenEXR/Imath/ImathMatrix.h*: 
158    In line 60 insert the following: 
159
160        #include string.h   
161
162 2. Enter the directory where the source files of FreeImage are located <i>(FREEIMAGE_SRC_DIR)</i>. 
163   
164        cd FREEIMAGE_SRC_DIR   
165
166 3. Run the building process 
167   
168        make   
169
170 4. Run the installation process 
171
172    a. If you have the permission to write into directories <i>/usr/include</i> and <i>/usr/lib</i>, run the following command: 
173
174           make install   
175    b. If you do not have this permission, you need to modify file *FREEIMAGE_SRC_DIR/Makefile.gnu*: 
176   
177       Change lines 7-9 from:
178   
179           DESTDIR ?= /   
180           INCDIR  ?= $(DESTDIR)/usr/include   
181           INSTALLDIR  ?= $(DESTDIR)/usr/lib   
182
183       to: 
184
185           DESTDIR  ?= $(DESTDIR)   
186           INCDIR  ?= $(DESTDIR)/include   
187           INSTALLDIR  ?= $(DESTDIR)/lib   
188
189       Change lines 65-67 from: 
190
191           install  -m 644 -o root -g root $(HEADER) $(INCDIR)   
192           install  -m 644 -o root -g root $(STATICLIB) $(INSTALLDIR)   
193           install  -m 755 -o root -g root $(SHAREDLIB) $(INSTALLDIR)   
194   
195       to:
196
197           install  -m 755 $(HEADER) $(INCDIR)   
198           install  -m 755 $(STATICLIB) $(INSTALLDIR)   
199           install  -m 755 $(SHAREDLIB) $(INSTALLDIR)
200
201       Change line 70 from: 
202
203           ldconfig
204
205       to:
206   
207           \#ldconfig   
208     
209    Then run the installation process by the following command: 
210
211         make DESTDIR=FREEIMAGE_INSTALL_DIR  install   
212
213 5. Clean temporary files
214   
215         make clean   
216
217 @subsection dev_guides__building_3rdparty_linux_3_4 OpenCL ICD Loader
218
219 If you have OpenCL SDK (one provided by Apple, AMD, NVIDIA, Intel, or other 
220 vendor) installed on your system, you should find OpenCL headers and
221 libraries required for building OCCT inside that SDK.
222
223 Alternatively, you can use OpenCL ICD (Installable Client Driver) Loader 
224 provided by Khronos group. The following describes steps used to build OpenCL 
225 ICD Loader version 1.2.11.0.
226
227 1. Download OpenCL ICD Loader sources archive and OpenCL header files from 
228    Khronos OpenCL Registry
229    http://www.khronos.org/registry/cl/
230
231 2. Unpack the archive and put headers in *inc/CL* sub-folder
232
233 3. Print *make* in the root of the unpacked archive to compile OpenCL libraries.
234
235 4. Create installation folder for OpenCL IDL Loader package and put there:
236
237     1. OpenCL header files in *include/CL* subfolder
238
239     2. *libOpenCL.so* (generated in *bin* subfolder of source package) in *lib* subfolder
240
241 @section dev_guides__building_3rdparty_linux_4 Installation From Official Repositories
242
243 @subsection dev_guides__building_3rdparty_linux_4_1 Debian-based distributives
244
245 All 3rd-party products required for building of  OCCT could be installed 
246 from official repositories. You may install them from  console using apt-get utility: 
247
248     sudo apt-get install \   
249     tcllib tklib tcl-dev tk-dev \   
250     libfreetype-dev \   
251     libxt-dev libxmu-dev \   
252     libgl1-mesa-dev \   
253     libfreeimage-dev \   
254     libtbb-dev \   
255     libgl2ps-dev   
256   
257 To launch binaries built with WOK  you need to install C shell and 32-bit libraries on x86_64 distributives: 
258   
259     sudo apt-get install \   
260     csh \   
261     libstdc++5:i386 libxt6:i386   
262
263 Building is possible with any C++  compliant compiler : 
264   
265     sudo apt-get install \   
266     g++