icexin / gocraft

A Minecraft like game written in go
MIT License
1.88k stars 131 forks source link

Build failed on FreeBSD #16

Closed Martinfx closed 5 years ago

Martinfx commented 5 years ago

Hello i would like compile engine but i have problem with dependencies

go mod init go build

go: extracting golang.org/x/image v0.0.0-20171214225156-12117c17ca67
go: downloading github.com/hashicorp/yamux v0.0.0-20171219165022-683f49123a33
go: extracting github.com/hashicorp/yamux v0.0.0-20171219165022-683f49123a33
# github.com/go-gl/glfw/v3.2/glfw
In file included from ../../go/pkg/mod/github.com/go-gl/glfw@v0.0.0-20170814180746-513e4f2bf85c/v3.2/glfw/c_glfw.go:4:
In file included from ./glfw/src/context.c:28:
In file included from ./glfw/src/internal.h:169:
./glfw/src/x11_platform.h:36:10: fatal error: 'X11/Xlib.h' file not found
#include <X11/Xlib.h>
         ^~~~~~~~~~~~
1 error generated.
# github.com/go-gl/gl/v3.3-core/gl
../../go/pkg/mod/github.com/go-gl/gl@v0.0.0-20170915061432-ac0d3d2af0fe/v3.3-core/gl/procaddr.go:52:11: fatal error: 'GL/glx.h' file not found
        #include <GL/glx.h>
                 ^~~~~~~~~~
icexin commented 5 years ago

I have not tested on FreeBSD. The error message shows that X Window Header is missing. You may try installing the X development library on the machine.

Martinfx commented 5 years ago

Yes i know. I have this headers in my machine.

/usr/local/include/X11/Xlib.h
/usr/local/include/GL/glx.h
icexin commented 5 years ago

Maybe /usr/local/include is not in the default include path, try CGO_CFLAGS="-I/usr/local/include" go build

Martinfx commented 5 years ago

Thank you for fot the path but failed linker with go build

# github.com/go-gl/gl/v3.3-core/gl
/usr/bin/ld: cannot find -lGL
clang: error: linker command failed with exit code 1 (use -v to see invocation)
# github.com/go-gl/gl/v3.3-core/gl
../../go/pkg/mod/github.com/go-gl/gl@v0.0.0-20170915061432-ac0d3d2af0fe/v3.3-core/gl/procaddr.go:54:28: warning: passing 'const char *' to parameter of type 'const GLubyte *' (aka 'const unsigned char *') converts between pointers to integer types with different sign [-Wpointer-sign]
/usr/local/include/GL/glx.h:325:48: note: passing argument to parameter 'procname' here
# github.com/go-gl/glfw/v3.2/glfw
/usr/bin/ld: cannot find -lGL
clang: error: linker command failed with exit code 1 (use -v to see invocation)
icexin commented 5 years ago

trying CGO_CFLAGS="-I/usr/local/include" CGO_LDFLAGS="-L/usr/local/lib" go build

Martinfx commented 5 years ago

Thank you go build

go build
# github.com/go-gl/glfw/v3.2/glfw
In file included from ../../go/pkg/mod/github.com/go-gl/glfw@v0.0.0-20170814180746-513e4f2bf85c/v3.2/glfw/c_glfw.go:4:
In file included from ./glfw/src/context.c:28:
In file included from ./glfw/src/internal.h:169:
./glfw/src/x11_platform.h:36:10: fatal error: 'X11/Xlib.h' file not found
#include <X11/Xlib.h>
         ^~~~~~~~~~~~
1 error generated.
^[[B# github.com/go-gl/gl/v3.3-core/gl
../../go/pkg/mod/github.com/go-gl/gl@v0.0.0-20170915061432-ac0d3d2af0fe/v3.3-core/gl/procaddr.go:52:11: fatal error: 'GL/glx.h' file not found
        #include <GL/glx.h>
Martinfx commented 5 years ago

OK i found problem, this is right command only some warnings. Last problem i have with fish. Thank you M.

$ CGO_CFLAGS="-I/usr/local/include" CGO_LDFLAGS="-L/usr/local/lib" go build
# github.com/go-gl/gl/v3.3-core/gl
../../go/pkg/mod/github.com/go-gl/gl@v0.0.0-20170915061432-ac0d3d2af0fe/v3.3-core/gl/procaddr.go:54:28: warning: passing 'const char *' to parameter of type 'const GLubyte *' (aka 'const unsigned char *') converts between pointers to integer types with different sign [-Wpointer-sign]
/usr/local/include/GL/glx.h:325:48: note: passing argument to parameter 'procname' here