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