go get fails on FreeBSD CURRENT
wilyarti opened this issue · 8 comments
I have read through #74 but I can't see anything I am doing wrong.
% go get -u github.com/go-gl/gl/v3.2-core/gl
# github.com/go-gl/gl/v3.2-core/gl
./procaddr.go:52:11: fatal error: 'GL/glx.h' file not found
#include <GL/glx.h>
^~~~~~~~~~
1 error generated.
I have tried adding "-I/usr/local/inlcude" to the cgo tag - but the same error occurs.
glx.h exists here: /usr/local/include/GL/glx.h
I am trying to get https://github.com/golang-ui/nuklear installed and this is a dependency.
I am using FreeBSD CURRENT on AMD64.
tried adding "-I/usr/local/inlcude"
There's a typo there. s/inlcude/include
.
I suspect the issue is with your configuration. Something about it isn't letting it find the GL/glx.h
file.
Thanks for your reply. I don't know much about C programming so bear with me.
I have add the "-L/usr/local/include" to each header. But I still get the same error.
undef@lenovo:~/go/src/github.com/go-gl/gl/v3.2-core/gl % go version
go version go1.10 freebsd/amd64
undef@lenovo:~/go/src/github.com/go-gl/gl/v3.2-core/gl % grep freebsd *
package.go:// #cgo linux freebsd LDFLAGS: -L/usr/local/include -lGL
procaddr.go:// linux freebsd: GLX
procaddr.go:#cgo linux freebsd CFLAGS: -DTAG_POSIX
procaddr.go:#cgo linux freebsd LDFLAGS: -L/usr/local/include -lGL
undef@lenovo:~/go/src/github.com/go-gl/gl/v3.2-core/gl % go build
# github.com/go-gl/gl/v3.2-core/gl
./procaddr.go:52:11: fatal error: 'GL/glx.h' file not found
#include <GL/glx.h>
^~~~~~~~~~
1 error generated.
undef@lenovo:~/go/src/github.com/go-gl/gl/v3.2-core/gl % stat /usr/local/include/GL/glx.h
3967910820912322983 46253 -rw-r--r-- 1 root wheel 18446744073709551615 14642 "Jan 1 10:00:00 1970" "Feb 13 18:03:48 2018" "Feb 21 22:22:07 2018" "Feb 13 18:03:48 2018" 14848 17 0x800 /usr/local/include/GL/glx.h
undef@lenovo:~/go/src/github.com/go-gl/gl/v3.2-core/gl % uname -a
FreeBSD lenovo 12.0-CURRENT FreeBSD 12.0-CURRENT #1 r330651: Thu Mar 8 17:28:44 AEST 2018 undef@lenovo:/usr/obj/usr/src/amd64.amd64/sys/GENERIC amd64
undef@lenovo:~/go/src/github.com/go-gl/gl/v3.2-core/gl % ls /usr/local/include/GL
freeglut.h gl_mangle.h glext.h glx.h glxint.h internal
freeglut_ext.h glcorearb.h glu.h glx_mangle.h glxmd.h wglew.h
freeglut_std.h gle.h glu_mangle.h glxew.h glxproto.h
gl.h glew.h glut.h glxext.h glxtokens.h
undef@lenovo:~/go/src/github.com/go-gl/gl/v3.2-core/gl % glinfo | more
GL_VERSION: 3.0 Mesa 17.3.1
<snip>
Thanks for you help.
I have add the "-L/usr/local/include" to each header.
Why did you change -I
to -L
? Try it with -I/usr/local/include
.
I add the include flag to try to point to the libraries as FreeBSD uses different system paths for libraries.
I followed this: https://golang.org/cmd/cgo/
When the cgo directives are parsed, any occurrence of the string ${SRCDIR} will be replaced by the absolute path to the directory containing the source file. This allows pre-compiled static libraries to be included in the package directory and linked properly. For example if package foo is in the directory /go/src/foo:
// #cgo LDFLAGS: -L${SRCDIR}/libs -lfoo
I have tried -I:
% go build
go build github.com/go-gl/gl/v3.2-core/gl: invalid flag in #cgo LDFLAGS: -I/usr/local/include
I have tried on another machine running 11.1 CURRENT and get the same error.
-I
is a flag to the compiler, not linker, so you need to use CFLAGS
variable instead. Try:
// #cgo CFLAGS: -I/usr/local/include
Sorry for the delay. I tried building it with the flags changed. I got an error from the linker saying it couldn't find GL.
undef@lenovo:~/go/src/github.com/go-gl/gl/v3.2-core/gl % go build
# github.com/go-gl/gl/v3.2-core/gl
/usr/bin/ld: cannot find -lGL
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I tried adding the "-L/usr/local/include" flag and got the same error.
# github.com/go-gl/gl/v3.2-core/gl
/usr/bin/ld: cannot find -lGL
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I removed the "-lGL" flag and it seems to try to compile with this error:
# github.com/go-gl/gl/v3.2-core/gl
/tmp/go-build596664409/b001/_x005.o: In function `GlowGetProcAddress_glcore32':
./procaddr.go:54: undefined reference to `glXGetProcAddress'
./procaddr.go:54: undefined reference to `glXGetProcAddress'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Is it an issue that I am using clang? FreeBSD now ships with clang not gcc:
undef@lenovo:~/go/src/github.com/go-gl/gl/v3.2-core/gl % ld -v
GNU ld 2.17.50 [FreeBSD] 2007-07-03
undef@lenovo:~/go/src/github.com/go-gl/gl/v3.2-core/gl % clang -v
FreeBSD clang version 6.0.0 (branches/release_60 324090) (based on LLVM 6.0.0)
Target: x86_64-unknown-freebsd12.0
Thread model: posix
InstalledDir: /usr/bin
If you need a FreeBSD box I can spin you up a VM if that would help.
I tried adding the "-L/usr/local/include" flag and got the same error.
-L
if for specifying paths to look for libraries. /usr/local/include contains headers files, not libraries. You need to give it a different path, perhaps something like /usr/local/lib
or /usr/lib
, one that contains the GL library file.
I'm not a FreeBSD user, so it's hard for me to help. I suggest you seek help from someone who uses FreeBSD. Your problem is simple, the C/C++ compiler (clang
is fine) on your system is not able to locate the OpenGL header and library files by default.
Thanks to dmgk on #freebsd on freenode I got this to build. I will issue patches tonight.
The following line needed to be added:
#cgo linux freebsd pkg-config: gl
This also fixed broken glfw by adding it to the build.go file.