gocraft
gocraft copied to clipboard
vendor/github.com/go-gl/glfw/v3.2/glfw/c_glfw.go:4:10: fatal error: 'glfw/src/context.c' file not found
gocraft/vendor/github.com/go-gl/glfw/v3.2/glfw
vendor/github.com/go-gl/glfw/v3.2/glfw/c_glfw.go:4:10: fatal error: 'glfw/src/context.c' file not found #include "glfw/src/context.c" ^~~~~~~~~~~~~~~~~~~~ 1 error generated.
Compilation finished with exit code 2
---- go env
GOARCH="amd64" GOBIN="" GOCACHE="/Users/hipnusleo/Library/Caches/go-build" GOEXE="" GOHOSTARCH="amd64" GOHOSTOS="darwin" GOOS="darwin" GOPATH="/Users/hipnusleo/Workspace/packages/golang" GORACE="" GOROOT="/opt/local/lib/go" GOTMPDIR="" GOTOOLDIR="/opt/local/lib/go/pkg/tool/darwin_amd64" GCCGO="gccgo" CC="/usr/bin/clang" CXX="clang++" CGO_ENABLED="1" 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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/s_/db9sxfb91xd7k59f1l9cfwl00000gn/T/go-build426875879=/tmp/go-build -gno-record-gcc-switches -fno-common"
What's the output of go env
and which os distribution do you use?
GOARCH="amd64" GOBIN="" GOCACHE="/Users/hipnusleo/Library/Caches/go-build" GOEXE="" GOHOSTARCH="amd64" GOHOSTOS="darwin" GOOS="darwin" GOPATH="/Users/hipnusleo/Workspace/packages/golang" GORACE="" GOROOT="/opt/local/lib/go" GOTMPDIR="" GOTOOLDIR="/opt/local/lib/go/pkg/tool/darwin_amd64" GCCGO="gccgo" CC="/usr/bin/clang" CXX="clang++" CGO_ENABLED="1" 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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/s_/db9sxfb91xd7k59f1l9cfwl00000gn/T/go-build426875879=/tmp/go-build -gno-record-gcc-switches -fno-common"
Pull master and try build again, maybe you are using a broken code.
Same problem here ...
vendor/github.com/go-gl/glfw/v3.2/glfw/c_glfw.go:4:10: fatal error: 'glfw/src/context.c' file not found
#include "glfw/src/context.c"
^~~~~~~~~~~~~~~~~~~~
my go env:
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/tox/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/tox/.go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/opt/go/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/opt/go/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/dk/l3j2snzn58j2nn5h7b_l8m5m0000gn/T/go-build830825457=/tmp/go-build -gno-record-gcc-switches -fno-common"
@hipnusleo Have you been able to solve the problem?
Not a solution but a workarround, download the zip file from https://github.com/go-gl/glfw and extract the archive into the folder vendor/github.com/go-gl/glfw/v3.2
@byskr Thank you, after almost a year - the problem is solved in the same way.
I pulled the latest glfw version and there should be no more compilation errors
Directories without .go
files are not copied with modules and vendoring:
https://github.com/golang/go/wiki/Modules#some-needed-files-may-not-be-present-in-populated-vendor-directory
A working alternative would be installing https://github.com/goware/modvendor and copy all needed files:
$ go mod vendor
$ modvendor -copy="**/*.c **/*.h **/*.m"
Directories without
.go
files are not copied with modules and vendoring:https://github.com/golang/go/wiki/Modules#some-needed-files-may-not-be-present-in-populated-vendor-directory
A working alternative would be installing https://github.com/goware/modvendor and copy all needed files:
$ go mod vendor $ modvendor -copy="**/*.c **/*.h **/*.m"
I have same issue, solve it with your way. Thx ! @jjrumi
this should be solvable automatically?
iirc the solution is to add glfw/src/context.go as an empty file.
then somewhere in the package import it.
i.e.)
// ensure c source are not lost when vendoring import _ "glfw/src"