Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getting error while go get github.com/pixiv/go-libjpeg/jpeg #65

Open
ashu171996 opened this issue Jun 7, 2021 · 3 comments
Open

getting error while go get github.com/pixiv/go-libjpeg/jpeg #65

ashu171996 opened this issue Jun 7, 2021 · 3 comments

Comments

@ashu171996
Copy link

ashu171996 commented Jun 7, 2021

# github.com/pixiv/go-libjpeg/jpeg
go/pkg/mod/github.com/pixiv/[email protected]/jpeg/compress.go:6:10: fatal error: jpeglib.h: No such file or directory
 #include "jpeglib.h"
          ^~~~~~~~~~~
compilation terminated.

The above block appears while executing go get, any idea what to do next.
Any help would be appreciated.
Best regards
Ashutosh

@ashu171996
Copy link
Author

My go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/ashutoshp/.cache/go-build"
GOENV="/home/ashutoshp/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/ashutoshp/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/ashutoshp/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.16"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build2380541700=/tmp/go-build -gno-record-gcc-switches"

@ivanovaleksey
Copy link

@ashu171996 you have to specify location of the header file (also I guess the library).
You do that by setting CGO_LDFLAGS and CGO_CPPFLAGS variables
See similar issue

@scaszoo
Copy link

scaszoo commented Oct 13, 2021

@ashu171996
'sudo apt-get install libjpeg-dev' should solve your issue :-)

For mac e.g. brew install jpeg helps to retrieve the neccessary includes and libs.
Running e.g. CGO_LDFLAGS="-L/opt/homebrew/Cellar/jpeg/9d/lib -lm" CGO_CPPFLAGS="-I/opt/homebrew/Cellar/jpeg/9d/include" go get github.com/pixiv/go-libjpeg would be able to load the package.
Adjust the version (9d) if it has changed.

Edit:
It's also possible to just use CGO_LDFLAGS="-L/opt/homebrew/lib -lm" CGO_CPPFLAGS="-I/opt/homebrew/include" go get github.com/pixiv/go-libjpeg

Or executing in your shell: export CPATH=/opt/homebrew/include export LIBRARY_PATH=/opt/homebrew/lib or adding it to your shell rc file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants