From 0906e010c5d8976b2576e70e806791d4c8de1859 Mon Sep 17 00:00:00 2001 From: Dominik Ochs Date: Thu, 18 Jan 2024 18:42:32 +0100 Subject: [PATCH] Update README.md with new installation instructions --- README.md | 66 +++++++++++++++---------------------------------------- 1 file changed, 18 insertions(+), 48 deletions(-) diff --git a/README.md b/README.md index 77ee5bc..28fad8d 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,11 @@ For a better user experience right from the start use V2 via `go get github.com/ # Installation -## Prerequisites (working [cgo](https://golang.org/cmd/cgo/)) +For the library to work, you need cgo, libedflate (which is used by this library under the hood), and pkg-config (linker): + +## Install [cgo](https://golang.org/cmd/cgo/) + +**TL;DR**: Get **[cgo](https://golang.org/cmd/cgo/)** working. In order to use this library with your Go source code, you must be able to use the Go tool **[cgo](https://golang.org/cmd/cgo/)**, which, in turn, requires a **GCC compiler**. @@ -60,58 +64,24 @@ off of MinGW. Please note that [cgo](https://golang.org/cmd/cgo/) requires the 6 For **any other** the procedure should be about the same. Just google. -**TL;DR**: Get **[cgo](https://golang.org/cmd/cgo/)** working. - -## Download and Installation - -If you want to build for `$GOARCH=amd64` and either **Windows, Linux** or **MacOS** just Go get this library and everything will work right away. - -(You may also use Go modules (available since Go 1.11) to get the version of a specific branch or tag if you want to try out or use experimental features. However, beware that these versions are not necessarily guaranteed to be stable or thoroughly tested.) - -
- - Instructions for building for different GOOS,GOARCH +## Install [pkg-config](https://www.freedesktop.org/wiki/Software/pkg-config/) and [libdeflate](https://github.com/ebiggers/libdeflate) +This SDK uses [libdeflate](https://github.com/ebiggers/libdeflate) under the hood. For the SDK to work, you need to install `libdeflate` on your system which is super easy! +Additionally we require [pkg-config](https://www.freedesktop.org/wiki/Software/pkg-config/) which facilitates linking `libdeflate` with this (cgo) SDK. +How exactly you install these two packages depends on your operating system. -First of all, it is not encouraged to build for non-64-bit archs, as this library works best for 64-bit systems. - -A list of possible GOOS,GOARCH combinations can be viewed [here](https://golang.org/doc/install/source#environment). - -**Instructions:** - -1. You will need to compile and build the C [libdeflate](https://github.com/ebiggers/libdeflate) library for your target system by cloning the [repository](https://github.com/ebiggers/libdeflate) and executing the Makefile (specifying the build). *You should always use GCC for compilation as this produces the fastest libraries.* - -2. Step 1 will yield compiled library files. You are going to want to use the static library (usually ending with .a \[in case of windows, rename .lib to .a\]), give it an adequate name (like `libdeflate_GOOS_GOARCH.a`) and copy it to the native/libs folder of this library. - -3. Go to the native/cgo.go file, which should roughly look like this: -```go -package native - -/* -#cgo CFLAGS: -I${SRCDIR}/libs/ -#cgo windows,amd64 LDFLAGS: ${SRCDIR}/libs/libdeflate_windows_amd64.a -#cgo linux,amd64 LDFLAGS: ${SRCDIR}/libs/libdeflate_linux_amd64.a -#cgo darwin,amd64 LDFLAGS: ${SRCDIR}/libs/libdeflate_darwin_amd64.a -*/ -import "C" -``` -Now you want to add your build of libdeflate to the cgo directives, more specifically, to the linker flags, like this (omit the '+'): -```diff -package native - -/* -#cgo CFLAGS: -I${SRCDIR}/libs/ -+#cgo GOOS,GOARCH LDFLAGS: ${SRCDIR}/libs/libdeflate_GOOS_GOARCH.a -#cgo windows,amd64 LDFLAGS: ${SRCDIR}/libs/libdeflate_windows_amd64.a -#cgo linux,amd64 LDFLAGS: ${SRCDIR}/libs/libdeflate_linux_amd64.a -#cgo darwin,amd64 LDFLAGS: ${SRCDIR}/libs/libdeflate_darwin_amd64.a -*/ -import "C" +#### MacOS (HomeBrew): +```sh +brew install libdeflate +brew install pkg-config ``` -That's it! It should work now! +#### Linux: +Use the package manager available on your distro to install the required packages. -
+#### Windows (MinGW/WSL2): +Here, you can either use [WSL2](https://learn.microsoft.com/en-us/windows/wsl/install) +or [MinGW](https://www.mingw-w64.org/) and from there install the required packages. # Usage