]> de.git.xonotic.org Git - xonotic/xonotic.wiki.git/blob - Shared-libraries-(buildfiles).md
Update Shared libraries (buildfiles)
[xonotic/xonotic.wiki.git] / Shared-libraries-(buildfiles).md
1 darkplaces/Xonotic on Linux uses system libraries. For Windows and macOS external dlls and dylibs are needed. Those reside in xonotic/misc/buildfiles
2
3 Because at the time of writing there is no automatism to build or update the games dependencies for those 2 platforms and the current dlls/dylibs are VERY outdated and thus also contain vulnerabilities, this page should document on where to obtain or how to build them, retaining API compatibility to darkplaces and also older OS platform versions like Windows XP.
4
5 For Windows, all libraries can/should be obtained from https://packages.msys2.org/ [1] with the exception of an official DLL release from the upstream being available (this is the case for jpeg-turbo and freetype) or if it has to be compiled on under Windows for some reason (eg. libcurl for Schannel (Windows crypto for HTTPS) support).
6
7 A handy tool to check dll deps on Windows is https://github.com/lucasg/Dependencies
8
9 TODO: macOS
10
11 # libcurl
12 libcurl is used for downloading *.pk3 files from servers
13
14 ### Windows
15
16 ```
17 git clone -b curl-7_80_0 https://github.com/curl/curl || true
18 curl -o x86_64-w64-mingw32.cmake https://raw.githubusercontent.com/zyga/cmake-toolchains/master/Toolchain-Ubuntu-mingw64.cmake
19 d0=$(pwd)
20 rm -rf build
21 mkdir build
22 cd build
23 cmake -DCMAKE_TOOLCHAIN_FILE="$d0/x86_64-w64-mingw32.cmake" -DCMAKE_INSTALL_PREFIX="$d0/out" -DCURL_USE_SCHANNEL=YES -G"Unix Makefiles" "$d0/curl"
24 make
25 make install
26 cd "$d0"
27 cp out/bin/libcurl.dll ~/Games/xonotic/misc/buildfiles/win64/libcurl-4.dll
28 ```
29
30 ### macOS
31 Darkplaces loads `libcurl.4.dylib` or `libcurl.3.dylib` or `libcurl.2.dylib`
32
33 # libjpeg-turbo
34 libjpeg-turbo is needed to display jpeg images/textures
35
36 ### Windows
37
38 ```
39 git clone https://github.com/libjpeg-turbo/libjpeg-turbo.git || true
40 curl -o x86_64-w64-mingw32.cmake https://raw.githubusercontent.com/zyga/cmake-toolchains/master/Toolchain-Ubuntu-mingw64.cmake
41 d0=$(pwd)
42 rm -rf build
43 mkdir build
44 cd build
45 cmake -DCMAKE_TOOLCHAIN_FILE="$d0/x86_64-w64-mingw32.cmake" -DCMAKE_SYSTEM_PROCESSOR=x86_64 -DCMAKE_INSTALL_PREFIX="$d0/out" -G"Unix Makefiles" "$d0/libjpeg-turbo"
46 make
47 make install
48 cd "$d0"
49 cp out/bin/libjpeg-62.dll ~/Games/xonotic/misc/buildfiles/win64/libjpeg.dll
50 ```
51
52 ### macOS
53 Darkplaces loads `libjpeg.62.dylib`
54
55 # zlib
56 zlib is required to read *.pk3 files. Also it is a dependency of libpng and probably some other libraries.
57
58 ### Windows
59 Darkplaces loads: ifdef ZLIB_USES_WINAPI `zlibwapi.dll` or `zlib.dll` else `zlib1.dll`. We use `zlib1.dll`!
60
61 Obtainment instructions:
62 * download as MSYS2 Package [1] in x86 and x64 versions: https://packages.msys2.org/base/mingw-w64-zlib
63 * use dll from `bin` folder
64
65 Cross-compiling:
66
67 ```
68 ZLIBVER="1.2.11"
69 curl -L -o zlib-$ZLIBVER.tar.xz https://zlib.net/zlib-$ZLIBVER.tar.xz || true
70 tar -xf zlib-$ZLIBVER.tar.xz
71 rm zlib-$ZLIBVER.tar.xz
72 curl -o x86_64-w64-mingw32.cmake https://raw.githubusercontent.com/zyga/cmake-toolchains/master/Toolchain-Ubuntu-mingw64.cmake
73
74 d0=$(pwd)
75 rm -rf build
76 mkdir build
77 cd build
78 sed -i '/zlib PROPERTIES SUFFIX/i     set_target_properties(zlib PROPERTIES PREFIX "")' "$d0/zlib-$ZLIBVER/CMakeLists.txt" # Remove the "lib" prefix. TODO Do this through the cmake cache?
79 cmake -DCMAKE_TOOLCHAIN_FILE="$d0/x86_64-w64-mingw32.cmake" -DBUILD_SHARED_LIBS=true -DCMAKE_SYSTEM_PROCESSOR=x86_64 -DCMAKE_INSTALL_PREFIX="$d0/out" -G"Unix Makefiles" "$d0/zlib-$ZLIBVER"
80 make
81 make install
82 cd "$d0"
83 cp out/bin/zlib1.dll ~/Games/xonotic/misc/buildfiles/win64/zlib1.dll
84 ```
85
86 ### macOS
87 Darkplaces loads `libz.dylib`
88
89 # libpng
90 libpng is needed to display png images/textures
91
92 ### Windows
93 Darkplaces loads `libpng16.dll` or `libpng16-16.dll` or `libpng15-15.dll` or `libpng15.dll` or `libpng14-14.dll` or `libpng14.dll` or `libpng12.dll`
94
95 Obtainment instructions:
96 * be sure to use a 1.16.X release
97 * download MSYS2 Package [1] in x86 and x64 versions: https://packages.msys2.org/base/mingw-w64-libpng
98 * use dll from `bin` folder
99
100 Cross-compiling (requires zlib):
101
102 ```
103 d0=$(pwd)
104 PNGVER="libpng16"
105 ZLIB_ROOT=$d0/../zlib/out # Location to the zlib compiled library
106
107 git clone -b $PNGVER git://git.code.sf.net/p/libpng/code libpng || true
108 curl -o x86_64-w64-mingw32.cmake https://raw.githubusercontent.com/zyga/cmake-toolchains/master/Toolchain-Ubuntu-mingw64.cmake
109
110 rm -rf build
111 mkdir build
112 cd build
113 cmake -DCMAKE_TOOLCHAIN_FILE="$d0/x86_64-w64-mingw32.cmake" -DPNG_STATIC=false -DPNG_TESTS=false -DPNG_EXECUTABLES=false -DCMAKE_SYSTEM_PROCESSOR=x86_64 -DZLIB_INCLUDE_DIR=$ZLIB_ROOT/include -DZLIB_LIBRARY=$ZLIB_ROOT/lib/libzlib.dll.a -DCMAKE_INSTALL_PREFIX="$d0/out" -G"Unix Makefiles" "$d0/libpng"
114 make
115 make install
116 cd "$d0"
117 cp out/bin/libpng16.dll ~/Games/xonotic/misc/buildfiles/win64/libpng16.dll
118 ```
119
120 ### macOS
121 Darkplaces loads `libpng16.16.dylib` or `libpng15.15.dylib` or `libpng14.14.dylib` or `libpng12.0.dylib`
122
123 # libfreetype
124 Required for the Xolonium font
125
126 ### Windows
127 Darkplaces loads: `libfreetype-6.dll` or `freetype6.dll`
128
129 ```
130 FTVER="2.11.1"
131 curl -L -o freetype-$FTVER.tar.xz https://download.savannah.gnu.org/releases/freetype/freetype-$FTVER.tar.xz || true
132 tar -xf freetype-$FTVER.tar.xz
133 rm freetype-$FTVER.tar.xz
134
135 curl -o x86_64-w64-mingw32.cmake https://raw.githubusercontent.com/zyga/cmake-toolchains/master/Toolchain-Ubuntu-mingw64.cmake
136 d0=$(pwd)
137 rm -rf build
138 mkdir build
139 cd build
140 cmake -DCMAKE_TOOLCHAIN_FILE="$d0/x86_64-w64-mingw32.cmake" -DBUILD_SHARED_LIBS=true -DCMAKE_BUILD_TYPE=Release -DCMAKE_SYSTEM_PROCESSOR=x86_64 -DCMAKE_INSTALL_PREFIX="$d0/out" -G"Unix Makefiles" "$d0/freetype-$FTVER"
141 make
142 make install
143 cd "$d0"
144 cp out/bin/libfreetype.dll ~/Games/xonotic/misc/buildfiles/win64/libfreetype-6.dll
145 ```
146
147 ### macOS
148 Darkplaces loads: `libfreetype.6.dylib` or `libfreetype.dylib`
149
150 # libogg
151 libogg is used for the container in cl_capturevideo
152
153 ### Windows
154 Darkplaces loads `libogg-0.dll` or `libogg.dll` or `ogg.dll`
155
156 Obtainment instructions:
157 * download MSYS2 Package [1] in x86 and x64 versions: https://packages.msys2.org/base/mingw-w64-libogg
158 * use dll from `bin` folder
159
160 Cross-compiling:
161
162 ```
163 d0=$(pwd)
164 OGGVER="v1.3.5"
165 git clone -b $OGGVER https://gitlab.xiph.org/xiph/ogg.git
166 sed -i 's/^LIBRARY ogg$/LIBRARY libogg/' "$d0/ogg/win32/ogg.def" # Call it libogg
167 curl -o x86_64-w64-mingw32.cmake https://raw.githubusercontent.com/zyga/cmake-toolchains/master/Toolchain-Ubuntu-mingw64.cmake
168 rm -rf build
169 mkdir build
170 cd build
171 cmake -DCMAKE_TOOLCHAIN_FILE="$d0/x86_64-w64-mingw32.cmake" -DBUILD_SHARED_LIBS=true -DCMAKE_SYSTEM_PROCESSOR=x86_64 -DCMAKE_INSTALL_PREFIX="$d0/out" -G"Unix Makefiles" "$d0/ogg"
172 make
173 make install
174 cd "$d0"
175 cp out/bin/libogg.dll ~/Games/xonotic/misc/buildfiles/win64/libogg.dll
176 ```
177
178 ### macOS
179 Darkplaces loads `libogg.dylib`
180
181 # libvorbis + libvorbisfile + libvorbisenc
182 libvorbis + libvorbisfile are used to play .ogg audio files while libvorbis + libvorbisenc is used for the audio in video capturing (cl_capturevideo)
183
184 ### Windows
185 Darkplaces loads `libvorbis-0.dll` or `libvorbis.dll` or `vorbis.dll` and `libvorbisfile-3.dll` or `libvorbisfile.dll` or `vorbisfile.dll` and `libvorbisenc-2.dll` or `vorbisenc-2.dll` or `vorbisenc.dll`
186
187 Obtainment instructions:
188 * download MSYS2 Package [1] in x86 and x64 versions: https://packages.msys2.org/base/mingw-w64-libvorbis
189 * use dll from `bin` folder
190
191 Cross-compiling (requires libogg):
192
193 ```
194 d0=$(pwd)
195 VORBISVER="v1.3.7"
196 OGG_ROOT=$d0/../ogg/out
197
198 git clone -b $VORBISVER https://gitlab.xiph.org/xiph/vorbis.git
199
200 # Fix win32 def files
201 sed -i 's/^LIBRARY$/LIBRARY libvorbis/' "$d0/vorbis/win32/vorbis.def"
202 sed -i 's/^LIBRARY$/LIBRARY libvorbisenc/' "$d0/vorbis/win32/vorbisenc.def"
203 sed -i 's/^LIBRARY$/LIBRARY libvorbisfile/' "$d0/vorbis/win32/vorbisfile.def"
204
205 curl -o x86_64-w64-mingw32.cmake https://raw.githubusercontent.com/zyga/cmake-toolchains/master/Toolchain-Ubuntu-mingw64.cmake
206 rm -rf build
207 mkdir build
208 cd build
209 cmake -DCMAKE_TOOLCHAIN_FILE="$d0/x86_64-w64-mingw32.cmake" -DBUILD_SHARED_LIBS=true -DOGG_INCLUDE_DIR=$OGG_ROOT/include -DOGG_LIBRARY=$OGG_ROOT/lib/libogg.dll.a -DCMAKE_SYSTEM_PROCESSOR=x86_64 -DCMAKE_INSTALL_PREFIX="$d0/out" -G"Unix Makefiles" "$d0/vorbis"
210 make
211 make install
212 cd "$d0"
213 cp out/bin/libvorbis.dll ~/Games/xonotic/misc/buildfiles/win64/libvorbis.dll
214 cp out/bin/libvorbisfile.dll ~/Games/xonotic/misc/buildfiles/win64/libvorbisfile.dll
215 cp out/bin/libvorbisenc.dll ~/Games/xonotic/misc/buildfiles/win64/libvorbisenc.dll
216 ```
217
218 ### macOS
219 Darkplaces loads `libvorbis.dylib` and `libvorbisfile.dylib`
220
221 # libtheora
222 libtheora is used for the video in cl_capturevideo
223 libtheoraenc/libtheoradec are not needed, they are the newer API; darkplaces uses the legacy pre 1.0 API (libtheora).
224
225 ### Windows
226 Darkplaces loads `libtheora-0.dll` or `theora-0.dll` or `theora.dll`
227
228 Obtainment instructions:
229 * download MSYS2 Package [1] in x86 and x64 versions: https://packages.msys2.org/base/mingw-w64-libtheora
230 * use dll from `bin` folder
231
232 Cross-compiling (requires libogg and libvorbis):
233
234 ```
235 d0=$(pwd)
236 THEORAVER="v1.1.1"
237 OGG_ROOT="$d0/../ogg/out"
238 VORBIS_ROOT="$d0/../vorbis/out"
239
240 git clone -b $THEORAVER https://gitlab.xiph.org/xiph/theora.git
241
242 # Fix mingw32 defs
243 sed -i '1iLIBRARY libtheoradec' "$d0/theora/win32/xmingw32/libtheoradec-all.def"
244 sed -i '1iLIBRARY libtheoraenc' "$d0/theora/win32/xmingw32/libtheoraenc-all.def"
245 sed -i '/TH_VP31_QUANT_INFO/d' "$d0/theora/win32/xmingw32/libtheoraenc-all.def"
246 sed -i '/TH_VP31_HUFF_CODES/d' "$d0/theora/win32/xmingw32/libtheoraenc-all.def"
247
248 # Start build
249 mkdir out
250 mkdir build
251 cd build
252 $d0/theora/autogen.sh --host=x86_64-w64-mingw32 --prefix="$d0/out" --with-ogg="$OGG_ROOT" --with-vorbis="$VORBIS_ROOT" --enable-shared --disable-examples --disable-sdltest --disable-vorbistest --disable-oggtest
253 make
254 make install
255 cd "$d0"
256 cp out/bin/libtheora-0.dll ~/Games/xonotic/misc/buildfiles/win64/libtheora-0.dll
257 ```
258
259 ### macOS
260 Darkplaces loads `libtheora.dylib`
261
262 # libd0_blind_id-0 & libd0_rijndael-0
263 Internal project, see https://gitlab.com/xonotic/d0_blind_id
264
265 ### Linux
266
267 `LDFLAGS='-L$HOME/Games/xonotic/misc/builddeps/linux64/gmp/lib' CPPFLAGS='-I$HOME/Games/xonotic/misc/builddeps/linux64/gmp/include' ./configure --prefix=$HOME/Games/xonotic/misc/builddeps/linux64/d0_blind_id  --enable-static --disable-shared --with-pic`
268
269 # libgmp
270 A dependency of libd0_blind_id-0
271
272 ### Linux
273
274 `./configure --prefix=$HOME/Games/xonotic/misc/builddeps/linux64/gmp --enable-static --disable-shared --with-pic --enable-fat`
275
276 ### Windows
277 libd0_blind_id-0 loads `libgmp-10.dll`
278
279 Obtainment instructions:
280 * download as MSYS2 Package [1] in x86 and x64 versions: https://packages.msys2.org/base/mingw-w64-gmp
281 * use dll from `bin` folder
282
283 Cross-compiling:
284
285 ```
286 d0=$(pwd)
287 GMPVER="6.2.1"
288
289 curl -o gmp-$GMPVER.tar.xz https://gmplib.org/download/gmp/gmp-$GMPVER.tar.xz
290 tar xf gmp-$GMPVER.tar.xz
291 rm gmp-$GMPVER.tar.xz
292
293 mkdir out
294 mkdir build
295 cd build
296 "$d0/gmp-$GMPVER/configure" --prefix="$d0/out" --host=x86_64-w64-mingw32 --with-pic --enable-fat --disable-static --enable-shared
297 make
298 make install
299 cd "$d0"
300 cp out/bin/libgmp-10.dll ~/Games/xonotic/misc/buildfiles/win64/libgmp-10.dll
301 ```
302
303 # libode
304 Is not loaded under Windows and crashes the game if it is and a map is loaded up.
305 Also it is not statically linked and thus requires libstdc++-6.dll and libgcc_s_sjlj-1.dll.
306
307 ### Linux:
308
309 `./configure --enable-static --disable-shared --with-libccd=internal --enable-double-precision --prefix=$HOME/Games/xonotic/misc/builddeps/linux64/ode --with-pic`
310
311 # libavw
312 *Note:* Old and not used in Xonotic but also not disabled :) Adding this for the sake of completeness.
313
314 ### Windows
315 Darkplaces loads: `libavw.dll`
316
317 Source code: https://github.com/paulvortex/DpLibAVW
318
319 ### macOS
320 Darkplaces loads: `libavw.dylib`