Skip to content

Commit

Permalink
Merge pull request #1 from kolesa-team/cgo-link
Browse files Browse the repository at this point in the history
link C library without manually linking and add installation instructions
  • Loading branch information
iborodikhin authored Mar 20, 2020
2 parents 49ce674 + 6dae6a3 commit e21f445
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 4 deletions.
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,16 @@ sudo apt-get install libwebp-dev
`go get -u github.com/kolesa-team/go-webp`

## Example
#### Before run
#### Install libwebp library
For MacOs:
```bash
export CGO_CFLAGS="-I /usr/local/opt/webp/include"
export CGO_LDFLAGS="-L /usr/local/opt/webp/lib -lwebp"
export LD_LIBRARY_PATH=/usr/local/opt/webp/lib
brew update
brew install webp
```
For Ubuntu:
```bash
apt update
apt install libwebp-dev
```

#### Decode:
Expand Down
1 change: 1 addition & 0 deletions decoder/decoder.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package decoder

/*
#cgo LDFLAGS: -lwebp
#include <stdlib.h>
#include <webp/decode.h>
*/
Expand Down
1 change: 1 addition & 0 deletions decoder/options.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package decoder

/*
#cgo LDFLAGS: -lwebp
#include <webp/decode.h>
*/
import "C"
Expand Down
1 change: 1 addition & 0 deletions encoder/encoder.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package encoder

/*
#cgo LDFLAGS: -lwebp
#include <stdlib.h>
#include <webp/encode.h>
static uint8_t* encodeNRBBA(WebPConfig* config, const uint8_t* rgba, int width, int height, int stride, size_t* output_size) {
Expand Down
1 change: 1 addition & 0 deletions encoder/options.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package encoder

/*
#cgo LDFLAGS: -lwebp
#include <webp/encode.h>
*/
import "C"
Expand Down

0 comments on commit e21f445

Please sign in to comment.