Cor*_*son 11 opengl go mingw-w64 cgo
我试图在Go程序中使用OpenGL.我想我已经完成了所有的工作,但我仍然无法让它运行起来.
我的C编译器是mingw的64位版本.它在我的%PATH%变量中,我已经验证它使用cgo文档中的随机数示例.
我通过将bin,lib和include文件夹应用到\mingw\x86_64-w64-mingw32mingw-w64安装中的等效文件来安装64位GLEW 1.9.0 .
当我尝试运行时go get github.com/go-gl/gl,请回复以下内容:
In file included from attriblocation.go:7:0:
gl.h:5:25: error: enumerator value for '__cgo_enum__5' is not an integer constant
#define GLEW_GET_FUN(x) (*x)
^
d:\programs\mingw64\x86_64-w64-mingw32\include\gl\glew.h:1956:26: note: in expansion of macro 'GLEW_GET_FUN'
#define glVertexAttrib3f GLEW_GET_FUN(__glewVertexAttrib3f)
^
gl.h:5:25: error: enumerator value for '__cgo_enum__6' is not an integer constant
#define GLEW_GET_FUN(x) (*x)
Run Code Online (Sandbox Code Playgroud)
对于值达到的值,这些错误以类似的方式继续__cgo_enum__15.我也从每个条目的Go方面得到一些匹配错误.
关于我缺少什么的想法让这个工作?
编辑:以下是来自Go方面的"匹配"日志.
attriblocation.go:42:2: error: initializer element is not constant
func (indx AttribLocation) Attrib4fv(values *[4]float32) {
^
attriblocation.go:42:2: error: (near initialization for '__cgodebug_data[5]')
attriblocation.go:43:2: error: initializer element is not constant
C.glVertexAttrib4fv(C.GLuint(indx), (*C.GLfloat)(&values[0]))
^
attriblocation.go:43:2: error: (near initialization for '__cgodebug_data[6]')
attriblocation.go:44:2: error: initializer element is not constant
}
Run Code Online (Sandbox Code Playgroud)
每__cgodebug_data[]5-15人就有一人.
编辑2:我被要求附上一些日志.这是我用GCC 4.8编译时会发生的事情,这是我用4.7和4.6得到的.
看起来这是 Go 以及 C/Go 编译器之间通信方式的缺陷。解决方法是设置CGO_CFLAGS=-ftrack-macro-expansion=0 go build. 您还可以使用go-1.2rc5或更新版本来解决该问题。此错误已通过之前指定的解决方法/修复解决。
| 归档时间: |
|
| 查看次数: |
2211 次 |
| 最近记录: |