-
Notifications
You must be signed in to change notification settings - Fork 2
/
INSTALL.TXT
274 lines (173 loc) · 9.62 KB
/
INSTALL.TXT
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
*********************************************************************
* INSTALLING MTOOLS *
* *
* Copyright 2015 Arvind Singh *
* *
* This file is part of the mtools library. *
* *
* mtools is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published *
* by the Free Software Foundation, either version 3 of the License, *
* or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with mtools If not, see <http://www.gnu.org/licenses/>. *
*********************************************************************
The library depend on a few external libraries:
- CImg (http://cimg.eu)
- fltk (http://www.fltk.org)
- zlib (http://www.zlib.net)
- libpng (http://www.libpng.org)
- libjpeg (http://www.ijg.org/)
- TinyXML2 (https://github.com/leethomason/tinyxml2)
and optionally
- openCL (https://www.khronos.org/opencl/)
- openGL (https://www.opengl.org/)
- cairo (http://cairographics.org/)
*********************************************************************
* CMAKE OPTIONS *
*********************************************************************
The library project files are generated with CMake (https://cmake.org/)
A recent version of CMake is required (>= 3.10).
Several flag can be set to configure the library:
- USE_COTIRE [default 0]
If set, use precompiled headers.
- CONSOLE_ONLY [default 0]
If set to 1, this flag disable mtools::cout console.
- USE_SSE [default = 0]
Experimental, if set to 1, use SSE specific code.
- USE_CAIRO [default = 1 if Cairo found]
If set to 1, use the Cairo library.
- USE_OPENGL [default = 1 if OpenGL found]
If set to 1, use OpenGL.
- USE_OPENCL [default = 0]
If set to 1, use OpenCL for specific GPU accelerated code.
- USE_OPENMP [default = 0]
If set to 1, use OpenMP.
- LOCAL_INSTALL [default = 1]
By default the library in not installed but used directly from
the build tree. If LOCAL_INSTALL=0, then the library will be
installed inside the directory pointed by CMAKE_INSTALL_PREFIX.
The compiler to use to build the library can be specified by setting
the environment variable CMAKE_CXX_COMPILER
Examples:
cmake-mtools [default build]
cmake-mtools -DCONSOLE_ONLY=1 -DUSE_OPENGL=0 [no graphics and do not use OpenGL]
cmake-mtools -DLOCAL_INSTALL=0 [default build, install at default location]
cmake-mtools -DCMAKE_CXX_COMPILER=/usr/bin/g++-9 [se G++9 to build the library]
cmake-mtools -DLOCAL_INSTALL=0 -DCMAKE_INSTALL_PREFIX=/usr/local [custom install dir]
*********************************************************************
* Building the library on Linux (and co) *
*********************************************************************
1) Make sure you use a recent version of gcc. Version 9 or later should do.
2) Make sure that cmake, python, pkg-config and the required libraries are
installed (at least Zlib, libPNG, libJPEG, FLTK, Cimg and TinyXML2)
- FLTK version should be at least 1.3.5.
- CImg is header only: just copy CImg.h somewhere the compiler can find it.
3) Generate the makefiles
cd mtools
./cmake-mtools [-DOPTION1 -DOPTION2 ...]
4) Build the library
make [-j N]
5) If LOCAL_INSTALL=0, install the library with
[sudo] make install
4) build the examples
cd examples
make [-j N]
*******************************************************************
* Building the library on OSX *
*******************************************************************
1) All the support libraries can be installed with homebrew
(http://brew.sh). For instance:
brew install cmake python pkg-config glib libpng jpeg-turbo freetype cimg pixman cairo fltk tinyxml2
2) gcc is recommended over clang (although both compiler should
work). It can be installed with
brew install gcc
3) Generate the makefiles, select the correct compiler with the
CMAKE_CXX_COMPILER variable.
cd mtools
./cmake-mtools [-DCMAKE_CXX_COMPILER=/usr/local/g++-9 -D...]
-> Make sure to enable OpenGL (i.e. option -DUSE_OPENGL=1 which is on by default)
otherwise plotting will be very slow on Mac OS.
4) Build the library
make [-j N]
5) If LOCAL_INSTALL=0, install the library with
[sudo] make install
4) build the examples
cd examples
make [-j N]
*******************************************************************
* Building on Windows, with VS 2015/17 *
*******************************************************************
1) Install CMake (and optionally Git for updating vcpkg).
2) Install python 3. In order to use for command line argument
to be correctly parsed when a python script is called from the windows shell,
the registry key [HKEY_CLASSES_ROOT\Applications\python.exe\shell\open\command]
should have value something like ["C:\Users\Vindar\Anaconda3\python.exe" "%1" %*]
if %* is missing, add it.
3) Installing the support libraries:
The easiest way it to use Microsoft's vcpkg package manager.
Installation is straightforward: open a powershell where vcpkg
should go and type:
git clone https://github.com/Microsoft/vcpkg
cd vcpkg
.\bootstrap-vcpkg.bat
.\vcpkg.exe integrate install
.\vcpkg.exe integrate powershell
The library should be build for the triplet [x64-windows]. To make
it the default triplet, create a system environment variable:
VCPKG_DEFAULT_TRIPLET=x64-windows
You MUST also create the system environment variable:
VCPKG_DIR="path\to\vcpkg\root\dir"
the external librairies can now be installed with, for instance,
.\vcpkg.exe install zlib libpng libjpeg-turbo fltk opengl pixman cairo cimg tinyxml2
All set !
4) BUG (September 2019).
There is a problem with FLTK built by vcpkg. Built it separately and then
replace the corresponding libraries and headers files in the vcpkg tree.
2) Generate the Visual studio solution files:
cd mtools
./cmake-mtools [-DOPTION1 -DOPTION2 ...]
4) Use mtools/build/mtools.sln VS solution file to build the library.
If LOCAL_INSTALL=0 was given to cmake, the library is installed by
running the project labelled INSTALL inside the solution.
5) Use mtools/build/examples/examples.sln to build the examples.
*******************************************************************
* Using mtools in a new project *
*******************************************************************
The library can be found by CMake using the usual find_package()
function. However, the simplest way to create a new project that is
cross-platform is to use the script mtools-project.py located in
the /tools sub-directory (it is convenient to export mtools/tools/ to
PATH so that the script can be called from anywhere). Then type:
mtools-project.py [projectname] create projectname
cd [projectname]/build enter the build directory
cmake .. configure the project
On linux/OSX, use
make
and on windows, use the VS solution file
/build/[projectname].sln
Then, as the project grows, customize the CMakeLists.txt located in
the root directory to suit your needs.
*******************************************************************
* ABOUT THE MTOOLS_SWAP_THREAD() MACRO *
*******************************************************************
The macro
MTOOLS_SWAP_THREADS(argc, argv)
should be the first line inside the main(int argc, char *argv[])
function. it is a dirty dirty hack to deal with the restriction that
only the main thread can handle graphics on OSX. this macro preempt
the main thread and use it on the background for drawing graphics
while an alternate thread is created to run the main() function.
Remarks:
- The macro is disabled on Linux and Windows and it can be
removed safely. However, it does no harm to keep it and it
make the code cross-plaftorm.
- Beware that, on OSX, the macro is active hence the global
objects are constructed with the main thread which is NOT
the one that runs the main() function !