Browse Source

add instructions on cross compilation (#2817)

pull/2820/head
Alessandro Ros 1 year ago committed by GitHub
parent
commit
b0ca00fca6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 42
      README.md

42
README.md

@ -138,6 +138,8 @@ _rtsp-simple-server_ has been rebranded as _MediaMTX_. The reason is pretty obvi @@ -138,6 +138,8 @@ _rtsp-simple-server_ has been rebranded as _MediaMTX_. The reason is pretty obvi
* [Standard](#standard)
* [Raspberry Pi](#raspberry-pi)
* [OpenWrt](#openwrt-1)
* [Cross compile](#cross-compile)
* [Compile for all supported platforms](#compile-for-all-supported-platforms)
* [Specifications](#specifications)
* [Related projects](#related-projects)
@ -1750,6 +1752,46 @@ CGO_ENABLED=0 go build . @@ -1750,6 +1752,46 @@ CGO_ENABLED=0 go build .
The command will produce the `mediamtx` binary.
If the OpenWrt device doesn't have enough resources to compile, you can [cross compile](#cross-compile) from another machine.
### Cross compile
Cross compilation allows to build an executable for a target machine from another machine with different operating system or architecture. This is useful in case the target machine doesn't have enough resources for compilation or if you don't want to install the compilation dependencies on it.
On the machine you want to use to compile, install git and Go ≥ 1.21. Clone the repository, enter into the folder and start the building process:
```sh
git clone https://github.com/bluenviron/mediamtx
cd mediamtx
CGO_ENABLED=0 GOOS=my_os GOARCH=my_arch go build .
```
Replace `my_os` and `my_arch` with the operating system and architecture of your target machine. A list of all supported combinations can be obtained with:
```sh
go tool dist list
```
For instance:
```sh
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build .
```
In case of the `arm` architecture, there's an additional flag available, `GOARM`, that allows to set the ARM version:
```sh
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 GOARM=7 go build .
```
In case of the `mips` architecture, there's an additional flag available, `GOMIPS`, that allows to set additional parameters:
```sh
CGO_ENABLED=0 GOOS=linux GOARCH=mips GOMIPS=softfloat go build .
```
The command will produce the `mediamtx` binary.
### Compile for all supported platforms
Install Docker and launch:

Loading…
Cancel
Save