]> git.xonotic.org Git - xonotic/xonotic.wiki.git/blob - Shared-libraries-(buildfiles).md
4b9a4637cb3298fe6747f0302742d62b9c4ade3f
[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
73 curl -o x86_64-w64-mingw32.cmake https://raw.githubusercontent.com/zyga/cmake-toolchains/master/Toolchain-Ubuntu-mingw64.cmake
74 d0=$(pwd)
75 rm -rf build
76 mkdir build
77 cd build
78 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"
79 make
80 make install
81 cd "$d0"
82 cp out/bin/libzlib1.dll ~/Games/xonotic/misc/buildfiles/win64/zlib1.dll
83 ```
84
85 ### macOS
86 Darkplaces loads `libz.dylib`
87
88 # libpng
89 libpng is needed to display png images/textures
90
91 ### Windows
92 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`
93
94 Obtainment instructions:
95 * be sure to use a 1.16.X release
96 * download MSYS2 Package [1] in x86 and x64 versions: https://packages.msys2.org/base/mingw-w64-libpng
97 * use dll from `bin` folder
98
99 Cross-compiling: (WARNING: RESULTING LIBRARY DOESN'T LOAD - THIS MUST BE ADJUSTED!)
100
101 ```
102 d0=$(pwd)
103 PNGVER="libpng16"
104 ZLIB_ROOT=$d0/../zlib/out # Location to the zlib compiled library
105
106 git clone -b $PNGVER git://git.code.sf.net/p/libpng/code libpng || true
107 curl -o x86_64-w64-mingw32.cmake https://raw.githubusercontent.com/zyga/cmake-toolchains/master/Toolchain-Ubuntu-mingw64.cmake
108
109 rm -rf build
110 mkdir build
111 cd build
112 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"
113 make
114 make install
115 cd "$d0"
116 cp out/bin/libpng16.dll ~/Games/xonotic/misc/buildfiles/win64/libpng16.dll
117 ```
118
119 ### macOS
120 Darkplaces loads `libpng16.16.dylib` or `libpng15.15.dylib` or `libpng14.14.dylib` or `libpng12.0.dylib`
121
122 # libfreetype
123 Required for the Xolonium font
124
125 ### Windows
126 Darkplaces loads: `libfreetype-6.dll` or `freetype6.dll`
127
128 ```
129 FTVER="2.11.1"
130 curl -L -o freetype-$FTVER.tar.xz https://download.savannah.gnu.org/releases/freetype/freetype-$FTVER.tar.xz || true
131 tar -xf freetype-$FTVER.tar.xz
132 rm freetype-$FTVER.tar.xz
133
134 curl -o x86_64-w64-mingw32.cmake https://raw.githubusercontent.com/zyga/cmake-toolchains/master/Toolchain-Ubuntu-mingw64.cmake
135 d0=$(pwd)
136 rm -rf build
137 mkdir build
138 cd build
139 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"
140 make
141 make install
142 cd "$d0"
143 cp out/bin/libfreetype.dll ~/Games/xonotic/misc/buildfiles/win64/libfreetype-6.dll
144 ```
145
146 ### macOS
147 Darkplaces loads: `libfreetype.6.dylib` or `libfreetype.dylib`
148
149 # libvorbis + libvorbisfile + libvorbisenc
150 libvorbis + libvorbisfile are used to play .ogg audio files while libvorbis + libvorbisenc is used for the audio in video capturing (cl_capturevideo)
151
152 ### Windows
153 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`
154
155 Obtainment instructions:
156 * download MSYS2 Package [1] in x86 and x64 versions: https://packages.msys2.org/base/mingw-w64-libvorbis
157 * use dll from `bin` folder
158
159 ### macOS
160 Darkplaces loads `libvorbis.dylib` and `libvorbisfile.dylib`
161
162 # libtheora
163 libtheora is used for the video in cl_capturevideo
164 libtheoraenc/libtheoradec are not needed, they are the newer API; darkplaces uses the legacy pre 1.0 API (libtheora).
165
166 ### Windows
167 Darkplaces loads `libtheora-0.dll` or `theora-0.dll` or `theora.dll`
168
169 Obtainment instructions:
170 * download MSYS2 Package [1] in x86 and x64 versions: https://packages.msys2.org/base/mingw-w64-libtheora
171 * use dll from `bin` folder
172
173 ### macOS
174 Darkplaces loads `libtheora.dylib`
175
176 # libogg
177 libogg is used for the container in cl_capturevideo
178
179 ### Windows
180 Darkplaces loads `libogg-0.dll` or `libogg.dll` or `ogg.dll`
181
182 Obtainment instructions:
183 * download MSYS2 Package [1] in x86 and x64 versions: https://packages.msys2.org/base/mingw-w64-libogg
184 * use dll from `bin` folder
185
186 ### macOS
187 Darkplaces loads `libogg.dylib`
188
189 # libd0_blind_id-0 & libd0_rijndael-0
190 Internal project, see https://gitlab.com/xonotic/d0_blind_id
191
192 ### Linux
193
194 `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`
195
196 # libgmp
197 A dependency of libd0_blind_id-0
198
199 ### Linux
200
201 `./configure --prefix=$HOME/Games/xonotic/misc/builddeps/linux64/gmp --enable-static --disable-shared --with-pic --enable-fat`
202
203 ### Windows
204 libd0_blind_id-0 loads `libgmp-10.dll`
205
206 Obtainment instructions:
207 * download as MSYS2 Package [1] in x86 and x64 versions: https://packages.msys2.org/base/mingw-w64-gmp
208 * use dll from `bin` folder
209
210 # libode
211 Is not loaded under Windows and crashes the game if it is and a map is loaded up.
212 Also it is not statically linked and thus requires libstdc++-6.dll and libgcc_s_sjlj-1.dll.
213
214 ### Linux:
215
216 `./configure --enable-static --disable-shared --with-libccd=internal --enable-double-precision --prefix=$HOME/Games/xonotic/misc/builddeps/linux64/ode --with-pic`
217
218 # libavw
219 *Note:* Old and not used in Xonotic but also not disabled :) Adding this for the sake of completeness.
220
221 ### Windows
222 Darkplaces loads: `libavw.dll`
223
224 Source code: https://github.com/paulvortex/DpLibAVW
225
226 ### macOS
227 Darkplaces loads: `libavw.dylib`