I am trying to import and use cbrotli
implementation from google as below:
import (
"fmt"
"io/ioutil"
cbrotli "github.com/google/brotli/go/cbrotli"
)
But I am getting the below error while trying to run the program:
learn-go [master●●] % CGO_CFLAGS="-I /dev/projects/go/learn-go/src/brotli/c/include/brotli" go run cmd/compress/main.go
# github.com/google/brotli/go/cbrotli
src/github.com/google/brotli/go/cbrotli/reader.go:13:10: fatal error: 'brotli/decode.h' file not found
#include <brotli/decode.h>
I am not sure how to pass some C flags to make sure that I can use the brotli implementation
Assuming you already have built brotli
, if not, there is an installation instructions in their Github page:
$ mkdir out && cd out
$ ../configure-cmake
$ make
$ make test
$ make install
When building your Go app, you only need to pass -I ~<prefix>/include
, where <prefix>
is where you installed the header files for brotli
. If you did not configure this prefix, it is usually in /usr/local
.
After this, you can run using:
$ CGO_FLAGS='-I <prefix>/include' CGO_FLAGS='-L <prefix>/lib' LD_LIBRARY_PATH='<prefix>/lib' go run cmd/compress/main.go
Note: You don't need to add "brotli" at the end of your CGO_FLAGS
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With