gocraft icon indicating copy to clipboard operation
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

Open hipnusleo opened this issue 6 years ago • 10 comments

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"


hipnusleo avatar Apr 26 '18 08:04 hipnusleo

What's the output of go env and which os distribution do you use?

icexin avatar Apr 28 '18 03:04 icexin

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"

hipnusleo avatar Apr 28 '18 05:04 hipnusleo

Pull master and try build again, maybe you are using a broken code.

icexin avatar Apr 28 '18 06:04 icexin

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?

dasrick avatar Mar 22 '19 07:03 dasrick

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 avatar Mar 29 '19 12:03 byskr

@byskr Thank you, after almost a year - the problem is solved in the same way.

byhaskell avatar Mar 15 '20 21:03 byhaskell

I pulled the latest glfw version and there should be no more compilation errors

icexin avatar Mar 16 '20 02:03 icexin

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"

jjrumi avatar Mar 23 '20 18:03 jjrumi

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

cuiweiqiang avatar Mar 25 '20 03:03 cuiweiqiang

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"

james-lawrence avatar Apr 04 '20 12:04 james-lawrence