README.md
1Fork init'ed from 19553209436ae7b9e036641f4013246111192d5c.
2
3This directory is NOT a crate. It contains heavily forked code from the
4libslirp-rs project that has been tightly integrated with `net_util`.
5
6libslirp-rs depends on a bunch of libraries (libslirp and its dependencies).
7Run `upload_libslirp_prebuilts.ps1` helps to setup msys, fetch sources, build and
8upload prebuilts given the version of the prebuilts.
9
10
11
12## Manually building dependencies
13
14### On windows
15
16Install [Msys2](https://www.msys2.org) which is used for building libslirp, a third party library
17used by the emulator. Open a msys2 window, install necessary packages with the following commands:
18
19```sh
20pacman -S mingw-w64-x86_64-meson ninja git mingw-w64-x86_64-gcc mingw-w64-x86_64-glib2 mingw-w64-x86_64-pkg-config
21```
22
23Note: You may need to add msys locations(which by default is C:\\msys64\\mingw64\\bin) to your PATH.
24
25Following commands should build the libslirp library and place it in `build` directory.
26
27```sh
28git clone https://gitlab.freedesktop.org/slirp/libslirp.git
29cd libslirp
30meson build
31ninja -C build
32```
33
34### Building on linux for windows
35
36libslirp depends on msys2's package that provides
37[libglib-2.0-0.dll](https://packages.msys2.org/package/mingw-w64-x86_64-glib2) and glib inturn
38depends on a few other libraries. On linux libglib-2.0-0.dll is not available as a dll with mingw
39setup or in another other apt packages. So you need to build dependent libraries either manually or
40get them prebuilt from somewhere. Once you have those, create a file name `cross-compile` in
41libslirp directory that looks something like
42
43```
44c = 'x86_64-w64-mingw32-gcc'
45cpp = 'x86_64-w64-mingw32-g++'
46ar = 'x86_64-w64-mingw32-ar'
47strip = 'x86_64-w64-mingw32-strip'
48pkgconfig = 'x86_64-w64-mingw32-pkg-config'
49exe_wrapper = 'wine64'
50
51[built-in options]
52pkg_config_path = ['/tmp/x86_64-w64-mingw32/lib/', '/tmp/x86_64-w64-mingw32/', '/tmp/mingw64/lib/pkgconfig']
53
54[host_machine]
55system = 'windows'
56cpu_family = 'x86_64'
57cpu = 'x86_64'
58endian = 'little'
59```
60
61and then run the following command to build
62
63```sh
64meson build --cross-file=cross-compile
65ninja -C build
66```
67
68Note: Above steps highly depends on how you have setup your cross-compiling environment.
69