ba06f8bb |
1 | Building 3rd-party libraries on Windows {#occt_dev_guides__building_3rdparty_windows} |
e5bd0d98 |
2 | ============================================== |
3 | @tableofcontents |
4 | |
5 | @section dev_guides__building_3rdparty_win_1 Introduction |
6 | |
77906c4c |
7 | This document presents guidelines for building third-party products used by Open CASCADE Technology (OCCT) and samples on Windows platform. It is assumed that you are already familiar with MS Visual Studio / Visual C++. |
e5bd0d98 |
8 | |
77906c4c |
9 | You need to use the same version of MS Visual Studio for building all third-party products and OCCT itself, in order to receive a consistent set of run-time binaries. |
e5bd0d98 |
10 | |
d3013f55 |
11 | The links for downloading the third-party products are available on the web site of OPEN CASCADE SAS at http://www.opencascade.com/content/3rd-party-components. |
12 | |
13 | There are two types of third-party products used by OCCT: |
e5bd0d98 |
14 | |
77906c4c |
15 | * Mandatory products: |
3f812249 |
16 | * Tcl/Tk 8.5 -- 8.6; |
17 | * FreeType 2.4.10 -- 2.5.3. |
77906c4c |
18 | * Optional products: |
3f812249 |
19 | * TBB 3.x -- 4.x; |
20 | * gl2ps 1.3.5 -- 1.3.8; |
21 | * FreeImage 3.14.1 -- 3.16.0; |
18006a0f |
22 | * VTK 6.1.0. |
e5bd0d98 |
23 | |
77906c4c |
24 | It is recommended to create a separate new folder on your workstation, where you will unpack the downloaded archives of the third-party products, and where you will build these products (for example, *c:\\occ3rdparty*). |
e5bd0d98 |
25 | |
79d580f2 |
26 | Further in this document, this folder is referred to as *3rdparty*. |
e5bd0d98 |
27 | |
28 | @section dev_guides__building_3rdparty_win_2 Building Mandatory Third-party Products |
29 | |
79d580f2 |
30 | @subsection dev_guides__building_3rdparty_win_2_1 Tcl/Tk |
e5bd0d98 |
31 | |
64215435 |
32 | Tcl/Tk is required for DRAW test harness. |
e5bd0d98 |
33 | |
64215435 |
34 | @subsubsection dev_guides__building_3rdparty_win_2_1_1 Installation from sources: Tcl |
35 | |
36 | Download the necessary archive from http://www.tcl.tk/software/tcltk/download.html and unpack it. |
37 | |
38 | 1. In the *win* sub-directory, edit file *buildall.vc.bat*: |
e5bd0d98 |
39 | |
64215435 |
40 | * Edit the line "call ... vcvars32.bat" to have correct path to the version of Visual Studio to be used for building, for instance: |
e5bd0d98 |
41 | |
64215435 |
42 | call "%VS80COMNTOOLS%\vsvars32.bat" |
e5bd0d98 |
43 | |
64215435 |
44 | If you are building 64-bit version, set environment accordingly, e.g.: |
45 | |
46 | call "%VS80COMNTOOLS%\..\..\VC\vcvarsall.bat" amd64 |
47 | |
48 | * Define variable *INSTALLDIR* pointing to directory where Tcl/Tk will be installed, e.g.: |
49 | |
50 | set INSTALLDIR=D:\OCCT\3rdparty\tcltk-86-32 |
51 | |
52 | * Add option *install* to the first command line calling *nmake*: |
53 | |
54 | nmake -nologo -f makefile.vc release htmlhelp install %1 |
55 | |
56 | * Remove second call to *nmake* (building statically linked executable) |
57 | |
58 | 2. Edit file *rules.vc* replacing line |
59 | |
60 | SUFX = tsgx |
61 | |
62 | by |
63 | |
64 | SUFX = sgx |
65 | |
66 | This is to avoid extra prefix 't' in the library name, which is not recognized by default by OCCT build tools. |
67 | |
21087d91 |
68 | |
69 | 3. By default, Tcl uses dynamic version of run-time library (MSVCRT), which must be installed on the system where Tcl will be used. |
70 | You may wish to link Tcl library with static version of run-time to avoid this dependency. |
71 | For that: |
72 | |
73 | * Edit file *makefile.vc* replacing strings "crt = -MD" by "crt = -MT" |
74 | |
75 | * Edit source file *tclMain.c* (located in folder *generic*) commenting out forward declaration of function *isatty()*. |
76 | |
77 | |
78 | 4. In the command prompt, run *buildall.vc.bat* |
64215435 |
79 | |
80 | You might need to run this script twice to have *tclsh* executable installed; check subfolder *bin* of specified installation path to verify this. |
81 | |
21087d91 |
82 | 5. For convenience of use, we recommend making a copy of *tclsh* executable created in subfolder *bin* of *INSTALLDIR* and named with Tcl version number suffix, as *tclsh.exe* (with no suffix) |
64215435 |
83 | |
84 | > cd D:\OCCT\3rdparty\tcltk-86-32\bin |
85 | > cp tclsh86.exe tclsh.exe |
86 | |
87 | @subsubsection dev_guides__building_3rdparty_win_2_1_2 Installation from sources: Tk |
88 | |
89 | Download the necessary archive from http://www.tcl.tk/software/tcltk/download.html and unpack it. |
90 | |
91 | Apply the same steps as described for building Tcl above, with the same INSTALLDIR. |
92 | Note that Tk produces its own executable, called *wish*. |
93 | |
94 | You might need to edit default value of *TCLDIR* variable defined in *buildall.vc.bat* (should be not necessary if you unpack both Tcl and Tk sources in the same folder). |
e5bd0d98 |
95 | |
79d580f2 |
96 | @subsection dev_guides__building_3rdparty_win_2_2 FreeType |
e5bd0d98 |
97 | |
77906c4c |
98 | FreeType is required for text display in a 3D viewer. You can download its sources from http://sourceforge.net/projects/freetype/files/ |
e5bd0d98 |
99 | |
77906c4c |
100 | ### The building procedure |
e5bd0d98 |
101 | |
77906c4c |
102 | 1. Unpack the downloaded archive of FreeType product into the *3rdparty* folder. As a result, you will get a folder named, for example, *3rdparty\\freetype-2.4.10*. Further in this document, this folder is referred to as *freetype*. |
103 | |
104 | 2. Open the solution file *freetype\\builds\\win32\\vc20xx\\freetype.sln* in Visual Studio. Here *vc20xx* stands for your version of Visual Studio. |
e5bd0d98 |
105 | |
77906c4c |
106 | 3. Select the configuration to build: either Debug or Release. |
e5bd0d98 |
107 | |
79d580f2 |
108 | 4. Build the *freetype* project. |
e5bd0d98 |
109 | |
77906c4c |
110 | As a result, you will get a freetype import library (.lib) in the *freetype\\obj\\win32\\vc20xx* folder. |
e5bd0d98 |
111 | |
77906c4c |
112 | |
113 | 5. If you build FreeType for a 64 bit platform, select in the main menu **Build - Configuration Manager** and add *x64* platform to the solution configuration by copying the settings from Win32 platform: |
e5bd0d98 |
114 | |
79d580f2 |
115 | @image html /dev_guides/building/3rdparty/images/3rdparty_image001.png |
116 | @image latex /dev_guides/building/3rdparty/images/3rdparty_image001.png |
e5bd0d98 |
117 | |
79d580f2 |
118 | Update the value of the Output File for x64 configuration: |
e5bd0d98 |
119 | |
79d580f2 |
120 | @image html /dev_guides/building/3rdparty/images/3rdparty_image003.png |
121 | @image latex /dev_guides/building/3rdparty/images/3rdparty_image003.png |
122 | |
123 | Build the *freetype* project. |
e5bd0d98 |
124 | |
77906c4c |
125 | As a result, you will obtain a 64 bit import library (.lib) file in the *freetype\\x64\\vc20xx* folder. |
e5bd0d98 |
126 | |
77906c4c |
127 | To build FreeType as a dynamic library (.dll) follow steps 6, 7 and 8 of this procedure. |
79d580f2 |
128 | |
77906c4c |
129 | 6. Open menu Project-> Properties-> Configuration Properties-> General and change option **Configuration Type** to *Dynamic Library (.dll)*. |
79d580f2 |
130 | 7. Edit file *freetype\\include\\freetype\\config\\ftoption.h*: |
e5bd0d98 |
131 | |
77906c4c |
132 | in line 255, uncomment the definition of macro *FT_EXPORT* and change it as follows: |
e5bd0d98 |
133 | |
79d580f2 |
134 | #define FT_EXPORT(x) __declspec(dllexport) x |
e5bd0d98 |
135 | |
79d580f2 |
136 | 8. Build the *freetype* project. |
e5bd0d98 |
137 | |
77906c4c |
138 | As a result, you will obtain the files of the import library (.lib) and the dynamic library (.dll) in folders <i>freetype \\objs\\release</i> or <i>\\objs\\debug </i>. |
139 | |
140 | If you build for a 64 bit platform, follow step 5 of the procedure. |
e5bd0d98 |
141 | |
77906c4c |
142 | To facilitate the use of FreeType libraries in OCCT with minimal adjustment of build procedures, it is recommended to copy the include files and libraries of FreeType into a separate folder, named according to the pattern: *freetype-compiler-bitness-building mode*, where: |
143 | * **compiler** is *vc8* or *vc9* or *vc10* or *vc11*; |
144 | * **bitness** is *32* or *64*; |
145 | * **building mode** is *opt* (for Release) or *deb* (for Debug). |
e5bd0d98 |
146 | |
77906c4c |
147 | The *include* subfolder should be copied as is, while libraries should be renamed to *freetype.lib* and *freetype.dll* (suffixes removed) and placed to subdirectories *lib *and *bin*, respectively. If the Debug configuration is built, the Debug libraries should be put into subdirectories *libd* and *bind*. |
e5bd0d98 |
148 | |
149 | @section dev_guides__building_3rdparty_win_3 Building Optional Third-party Products |
150 | |
79d580f2 |
151 | @subsection dev_guides__building_3rdparty_win_3_1 TBB |
152 | |
77906c4c |
153 | This third-party product is installed with binaries |
79d580f2 |
154 | from the archive that can be downloaded from http://threadingbuildingblocks.org/. |
77906c4c |
155 | Go to the **Download** page, find the release version you need (e.g. *tbb30_018oss*) and pick the archive for Windows platform. |
156 | |
79d580f2 |
157 | Unpack the downloaded archive of TBB product into the *3rdparty* folder. |
77906c4c |
158 | |
79d580f2 |
159 | Further in this document, this folder is referred to as *tbb*. |
160 | |
161 | @subsection dev_guides__building_3rdparty_win_3_2 gl2ps |
162 | |
163 | This third-party product should be built as a dynamically loadable library (dll file). |
77906c4c |
164 | You can download its sources from http://geuz.org/gl2ps/src/. |
79d580f2 |
165 | |
77906c4c |
166 | ### The building procedure |
79d580f2 |
167 | |
168 | 1. Unpack the downloaded archive of gl2ps product (e.g. *gl2ps-1.3.5.tgz*) into the *3rdparty* folder. |
e5bd0d98 |
169 | |
77906c4c |
170 | As a result, you will get a folder named, for example, *3rdparty\\gl2ps-1.3.5-source*. |
e5bd0d98 |
171 | |
77906c4c |
172 | Rename it into <i>gl2ps-platform-compiler-building mode</i>, where |
3f812249 |
173 | * **platform** -- *win32* or *win64*; |
174 | * **compiler** -- *vc8*, *vc9* or *vc10*; |
175 | * **building mode** -- *opt* (for release) or *deb* (for debug). |
77906c4c |
176 | |
177 | For example, <i>gl2ps-win64-vc10-deb</i> |
e5bd0d98 |
178 | |
79d580f2 |
179 | Further in this document, this folder is referred to as *gl2ps*. |
e5bd0d98 |
180 | |
79d580f2 |
181 | 2. Download (from http://www.cmake.org/cmake/resources/software.html) |
182 | and install the *CMake* build system. |
e5bd0d98 |
183 | |
79d580f2 |
184 | 3. Edit the file *gl2ps\\CMakeLists.txt*. |
e5bd0d98 |
185 | |
77906c4c |
186 | After line 113 in *CMakeLists.txt*: |
e5bd0d98 |
187 | |
79d580f2 |
188 | set_target_properties(shared PROPERTIES COMPILE_FLAGS \"-DGL2PSDLL -DGL2PSDLL_EXPORTS\") |
e5bd0d98 |
189 | |
190 | add the following line: |
191 | |
79d580f2 |
192 | add_definitions(-D_USE_MATH_DEFINES) |
e5bd0d98 |
193 | |
77906c4c |
194 | Attention: If Cygwin was installed on your computer, make sure that there is no path to it in the *PATH* variable to avoid possible conflicts during the configuration. |
e5bd0d98 |
195 | |
77906c4c |
196 | 4. Launch CMake <i>(cmake-gui.exe)</i> using the Program menu. |
79d580f2 |
197 | |
198 | In CMake: |
e5bd0d98 |
199 | |
79d580f2 |
200 | * Define where the source code is. |
201 | This path must point to *gl2ps* folder. |
202 | |
203 | * Define where to build the binaries. |
204 | This path must point to the folder where generated gl2ps project binaries will be placed |
205 | (for example, *gl2ps\\bin*). |
206 | Further in this document, this folder is referred to as *gl2ps_bin*. |
207 | |
77906c4c |
208 | * Press **Configure** button. |
209 | |
79d580f2 |
210 | @image html /dev_guides/building/3rdparty/images/3rdparty_image004.png |
211 | @image latex /dev_guides/building/3rdparty/images/3rdparty_image004.png |
212 | |
3f812249 |
213 | * Select the generator (the compiler and the target platform -- 32 or 64 bit) in the pop-up window. |
77906c4c |
214 | |
79d580f2 |
215 | @image html /dev_guides/building/3rdparty/images/3rdparty_image005.png |
216 | @image latex /dev_guides/building/3rdparty/images/3rdparty_image005.png |
217 | |
77906c4c |
218 | * Press **Finish** button to return to the main CMake window. |
79d580f2 |
219 | Expand the ENABLE group and uncheck ENABLE_PNG and ENABLE_ZLIB check boxes. |
77906c4c |
220 | |
79d580f2 |
221 | @image html /dev_guides/building/3rdparty/images/3rdparty_image006.png |
222 | @image latex /dev_guides/building/3rdparty/images/3rdparty_image006.png |
223 | |
77906c4c |
224 | * Expand the CMAKE group and define *CMAKE_INSTALL_PREFIX* which is the path where you want to install the build results, for example, *c:\\occ3rdparty\\gl2ps-1.3.5*. |
225 | |
79d580f2 |
226 | @image html /dev_guides/building/3rdparty/images/3rdparty_image007.png |
227 | @image latex /dev_guides/building/3rdparty/images/3rdparty_image007.png |
228 | |
77906c4c |
229 | * Press **Configure** button again, then press **Generate** button to generate Visual Studio projects. After completion, close CMake application. |
e5bd0d98 |
230 | |
79d580f2 |
231 | 5. Open the solution file *gl2ps_bin\\gl2ps.sln* in Visual Studio. |
232 | |
77906c4c |
233 | * Select a configuration to build |
234 | * Choose **Release** to build Release binaries. |
235 | * Choose **Debug** to build Debug binaries. |
236 | * Select a platform to build. |
237 | * Choose **Win32** to build for a 32 bit platform. |
238 | * Choose **x64** to build for a 64 bit platform. |
79d580f2 |
239 | * Build the solution. |
240 | * Build the *INSTALL* project. |
e5bd0d98 |
241 | |
77906c4c |
242 | As a result, you should have the installed gl2ps product in the *CMAKE_INSTALL_PREFIX* path. |
e5bd0d98 |
243 | |
79d580f2 |
244 | @subsection dev_guides__building_3rdparty_win_3_3 FreeImage |
e5bd0d98 |
245 | |
79d580f2 |
246 | This third-party product should be built as a dynamically loadable library (.dll file). |
247 | You can download its sources from |
248 | http://sourceforge.net/projects/freeimage/files/Source%20Distribution/ |
e5bd0d98 |
249 | |
77906c4c |
250 | ### The building procedure: |
e5bd0d98 |
251 | |
79d580f2 |
252 | 1. Unpack the downloaded archive of FreeImage product into *3rdparty* folder. |
253 | |
77906c4c |
254 | As a result, you should have a folder named *3rdparty\\FreeImage*. |
e5bd0d98 |
255 | |
77906c4c |
256 | Rename it according to the rule: *freeimage-platform-compiler-building mode*, where |
79d580f2 |
257 | |
77906c4c |
258 | * **platform** is *win32* or *win64*; |
259 | * **compiler** is *vc8* or *vc9* or *vc10* or *vc11*; |
260 | * **building mode** is *opt* (for release) or *deb* (for debug) |
79d580f2 |
261 | |
262 | Further in this document, this folder is referred to as *freeimage*. |
263 | |
77906c4c |
264 | 2. Open the solution file *freeimage\\FreeImage.*.sln* in your Visual Studio. |
e5bd0d98 |
265 | |
77906c4c |
266 | If you use a Visual Studio version higher than VC++ 2008, apply conversion of the workspace. |
79d580f2 |
267 | Such conversion should be suggested automatically by Visual Studio. |
e5bd0d98 |
268 | |
79d580f2 |
269 | 3. Select a configuration to build. |
270 | |
77906c4c |
271 | - Choose **Release** if you are building Release binaries. |
272 | - Choose **Debug** if you are building Debug binaries. |
79d580f2 |
273 | |
e5bd0d98 |
274 | *Note:* |
79d580f2 |
275 | |
77906c4c |
276 | If you want to build a debug version of FreeImage binaries then you need to rename the following files in FreeImage and FreeimagePlus projects: |
277 | |
278 | Project -> Properties -> Configuration Properties -> Linker -> General -> Output File |
e5bd0d98 |
279 | |
77906c4c |
280 | FreeImage*d*.dll to FreeImage.dll |
281 | FreeImagePlus*d*.dll to FreeImagePlus.dll |
e5bd0d98 |
282 | |
77906c4c |
283 | Project -> Properties -> Configuration Properties -> Linker -> Debugging-> Generate Program Database File |
e5bd0d98 |
284 | |
77906c4c |
285 | FreeImage*d*.pdb to FreeImage.pdb |
286 | FreeImagePlus*d*.pdb to FreeImagePlus.pdb |
e5bd0d98 |
287 | |
77906c4c |
288 | Project -> Properties -> Configuration Properties -> Linker -> Advanced-Import Library |
e5bd0d98 |
289 | |
77906c4c |
290 | FreeImage*d*.lib to FreeImage.lib |
291 | FreeImagePlus*d*.lib to FreeImagePlus.lib |
e5bd0d98 |
292 | |
77906c4c |
293 | Project -> Properties -> Configuration Properties -> Build Events -> Post -> Build Event -> Command Line |
e5bd0d98 |
294 | |
77906c4c |
295 | FreeImage*d*.dll to FreeImage.dll |
296 | FreeImage*d*.lib to FreeImage.lib |
297 | FreeImagePlus*d*.dll to FreeImagePlus.dll |
298 | FreeImagePlus*d*.lib to FreeImagePlus.lib |
e5bd0d98 |
299 | |
77906c4c |
300 | Additionally, rename in project FreeImagePlus |
301 | |
302 | Project -> Properties -> Configuration Properties -> Linker -> Input -> Additional Dependencies |
e5bd0d98 |
303 | |
79d580f2 |
304 | from FreeImage*d*.lib to FreeImage.lib |
e5bd0d98 |
305 | |
79d580f2 |
306 | 4. Select a platform to build. |
e5bd0d98 |
307 | |
77906c4c |
308 | - Choose *Win32* if you are building for a 32 bit platform. |
309 | - Choose *x64* if you are building for a 64 bit platform. |
e5bd0d98 |
310 | |
79d580f2 |
311 | 5. Start the building process. |
e5bd0d98 |
312 | |
77906c4c |
313 | As a result, you should have the library files of FreeImage product in *freeimage\\Dist* folder (*FreeImage.dll* and *FreeImage.lib*) and in *freeimage\\Wrapper\\FreeImagePlus\\dist* folder (*FreeImagePlus.dll* and *FreeImagePlus.lib*). |
e5bd0d98 |
314 | |
18006a0f |
315 | @subsection dev_guides__building_3rdparty_win_3_4 VTK |
e5bd0d98 |
316 | |
18006a0f |
317 | VTK is an open-source, freely available software system for 3D computer graphics, image processing and visualization. VTK Integration Services component provides adaptation functionality for visualization of OCCT topological shapes by means of VTK library. |
79d580f2 |
318 | |
18006a0f |
319 | ### The building procedure: |
79d580f2 |
320 | |
18006a0f |
321 | 1. Download the necessary archive from http://www.vtk.org/VTK/resources/software.html and unpack it into *3rdparty* folder. |
79d580f2 |
322 | |
18006a0f |
323 | As a result, you will get a folder named, for example, <i>3rdparty\VTK-6.1.0.</i> |
79d580f2 |
324 | |
18006a0f |
325 | Further in this document, this folder is referred to as *VTK*. |
77906c4c |
326 | |
18006a0f |
327 | 2. Use CMake to generate VS projects for building the library: |
328 | - Start CMake-GUI and select VTK folder as source path, and the folder of your choice for VS project and intermediate build data. |
329 | - Click **Configure**. |
330 | - Select the VS version to be used from the ones you have installed (we recommend using VS 2010) and the architecture (32 or 64-bit). |
331 | - Generate VS projects with default CMake options. The open solution *VTK.sln* will be generated in the build folder. |
79d580f2 |
332 | |
18006a0f |
333 | 3. Build project VTK in Release mode. |