GO-GTK在树莓派上的交叉编译

huangapple go评论139阅读模式
英文:

GO-GTK Cross Compilation for RaspberryPi

问题

我正在使用GO-GTK来显示图像,该项目在amd64上运行良好,但是当我尝试将其交叉编译为arm(Raspberry Pi)时,出现以下错误。请指导如何将go-gtk从amd64交叉编译到arm(Raspberry Pi 3)。

编译器输出如下所示:

github.com/mattn/go-gtk/glib

github.com/mattn/go-gtk/glib

在文件/usr/lib/x86_64-linux-gnu/glib-2.0/include/glibconfig.h:9:0中包含,
来自/usr/include/glib-2.0/glib/gtypes.h:32,
来自/usr/include/glib-2.0/glib/galloca.h:32,
来自/usr/include/glib-2.0/glib.h:30,
来自./glib.go.h:4,
来自src/github.com/mattn/go-gtk/glib/glib.go:5:
/usr/include/glib-2.0/glib/gtypes.h: 在函数‘_GLIB_CHECKED_ADD_U64’中:
/usr/include/glib-2.0/glib/gmacros.h:232:53: 错误:数组‘_GStaticAssertCompileTimeAssertion_0’的大小为负
#define G_STATIC_ASSERT(expr) typedef char G_PASTE (GStaticAssertCompileTimeAssertion, COUNTER)[(expr) ? 1 : -1] G_GNUC_UNUSED
^
/usr/include/glib-2.0/glib/gmacros.h:229:47: 注意:在宏‘G_PASTE_ARGS’的定义中
#define G_PASTE_ARGS(identifier1,identifier2) identifier1 ## identifier2
^
/usr/include/glib-2.0/glib/gmacros.h:232:44: 注意:在宏‘G_PASTE’的扩展中
#define G_STATIC_ASSERT(expr) typedef char G_PASTE (GStaticAssertCompileTimeAssertion, COUNTER)[(expr) ? 1 : -1] G_GNUC_UNUSED
^
/usr/include/glib-2.0/glib/gtypes.h:422:3: 注意:在宏‘G_STATIC_ASSERT’的扩展中
G_STATIC_ASSERT(sizeof (unsigned long long) == sizeof (guint64));
^
github.com/mattn/go-gtk/pango

github.com/mattn/go-gtk/pango

在文件/usr/lib/x86_64-linux-gnu/glib-2.0/include/glibconfig.h:9:0中包含,
来自/usr/include/glib-2.0/glib/gtypes.h:32,
来自/usr/include/glib-2.0/glib/galloca.h:32,
来自/usr/include/glib-2.0/glib.h:30,
来自/usr/include/pango-1.0/pango/pango-coverage.h:25,
来自/usr/include/pango-1.0/pango/pango-font.h:25,
来自/usr/include/pango-1.0/pango/pango-attributes.h:25,
来自/usr/include/pango-1.0/pango/pango.h:25,
来自./pango.go.h:7,
来自src/github.com/mattn/go-gtk/pango/pango.go:5:
/usr/include/glib-2.0/glib/gtypes.h: 在函数‘_GLIB_CHECKED_ADD_U64’中:
/usr/include/glib-2.0/glib/gmacros.h:232:53: 错误:数组‘_GStaticAssertCompileTimeAssertion_0’的大小为负
#define G_STATIC_ASSERT(expr) typedef char G_PASTE (GStaticAssertCompileTimeAssertion, COUNTER)[(expr) ? 1 : -1] G_GNUC_UNUSED
^
/usr/include/glib-2.0/glib/gmacros.h:229:47: 注意:在宏‘G_PASTE_ARGS’的定义中
#define G_PASTE_ARGS(identifier1,identifier2) identifier1 ## identifier2
^
/usr/include/glib-2.0/glib/gmacros.h:232:44: 注意:在宏‘G_PASTE’的扩展中
#define G_STATIC_ASSERT(expr) typedef char G_PASTE (GStaticAssertCompileTimeAssertion, COUNTER)[(expr) ? 1 : -1] G_GNUC_UNUSED
^
/usr/include/glib-2.0/glib/gtypes.h:422:3: 注意:在宏‘G_STATIC_ASSERT’的扩展中
G_STATIC_ASSERT(sizeof (unsigned long long) == sizeof (guint64));

环境变量

GOARCH="arm"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/minhaj/GoLang"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
GOARM=""
CC="arm-linux-gnueabi-gcc"
GOGCCFLAGS="-fPIC -marm -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build977266484=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
PKG_CONFIG="pkg-config"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"

英文:

I am using GO-GTK to display images, the project is working fine on amd64 but when I try to cross compile it for arm (RaspberryPi), it gives me below error.
Please advise how to cross-compile go-gtk from amd64 to arm (Raspberrypi3).

Compiler Output given below

  1. github.com/mattn/go-gtk/glib
  2. # github.com/mattn/go-gtk/glib
  3. In file included from /usr/lib/x86_64-linux-gnu/glib-2.0/include/glibconfig.h:9:0,
  4. from /usr/include/glib-2.0/glib/gtypes.h:32,
  5. from /usr/include/glib-2.0/glib/galloca.h:32,
  6. from /usr/include/glib-2.0/glib.h:30,
  7. from ./glib.go.h:4,
  8. from src/github.com/mattn/go-gtk/glib/glib.go:5:
  9. /usr/include/glib-2.0/glib/gtypes.h: In function '_GLIB_CHECKED_ADD_U64':
  10. /usr/include/glib-2.0/glib/gmacros.h:232:53: error: size of array '_GStaticAssertCompileTimeAssertion_0' is negative
  11. #define G_STATIC_ASSERT(expr) typedef char G_PASTE (_GStaticAssertCompileTimeAssertion_, __COUNTER__)[(expr) ? 1 : -1] G_GNUC_UNUSED
  12. ^
  13. /usr/include/glib-2.0/glib/gmacros.h:229:47: note: in definition of macro 'G_PASTE_ARGS'
  14. #define G_PASTE_ARGS(identifier1,identifier2) identifier1 ## identifier2
  15. ^
  16. /usr/include/glib-2.0/glib/gmacros.h:232:44: note: in expansion of macro 'G_PASTE'
  17. #define G_STATIC_ASSERT(expr) typedef char G_PASTE (_GStaticAssertCompileTimeAssertion_, __COUNTER__)[(expr) ? 1 : -1] G_GNUC_UNUSED
  18. ^
  19. /usr/include/glib-2.0/glib/gtypes.h:422:3: note: in expansion of macro 'G_STATIC_ASSERT'
  20. G_STATIC_ASSERT(sizeof (unsigned long long) == sizeof (guint64));
  21. ^
  22. github.com/mattn/go-gtk/pango
  23. # github.com/mattn/go-gtk/pango
  24. In file included from /usr/lib/x86_64-linux-gnu/glib-2.0/include/glibconfig.h:9:0,
  25. from /usr/include/glib-2.0/glib/gtypes.h:32,
  26. from /usr/include/glib-2.0/glib/galloca.h:32,
  27. from /usr/include/glib-2.0/glib.h:30,
  28. from /usr/include/pango-1.0/pango/pango-coverage.h:25,
  29. from /usr/include/pango-1.0/pango/pango-font.h:25,
  30. from /usr/include/pango-1.0/pango/pango-attributes.h:25,
  31. from /usr/include/pango-1.0/pango/pango.h:25,
  32. from ./pango.go.h:7,
  33. from src/github.com/mattn/go-gtk/pango/pango.go:5:
  34. /usr/include/glib-2.0/glib/gtypes.h: In function '_GLIB_CHECKED_ADD_U64':
  35. /usr/include/glib-2.0/glib/gmacros.h:232:53: error: size of array '_GStaticAssertCompileTimeAssertion_0' is negative
  36. #define G_STATIC_ASSERT(expr) typedef char G_PASTE (_GStaticAssertCompileTimeAssertion_, __COUNTER__)[(expr) ? 1 : -1] G_GNUC_UNUSED
  37. ^
  38. /usr/include/glib-2.0/glib/gmacros.h:229:47: note: in definition of macro 'G_PASTE_ARGS'
  39. #define G_PASTE_ARGS(identifier1,identifier2) identifier1 ## identifier2
  40. ^
  41. /usr/include/glib-2.0/glib/gmacros.h:232:44: note: in expansion of macro 'G_PASTE'
  42. #define G_STATIC_ASSERT(expr) typedef char G_PASTE (_GStaticAssertCompileTimeAssertion_, __COUNTER__)[(expr) ? 1 : -1] G_GNUC_UNUSED
  43. ^
  44. /usr/include/glib-2.0/glib/gtypes.h:422:3: note: in expansion of macro 'G_STATIC_ASSERT'
  45. G_STATIC_ASSERT(sizeof (unsigned long long) == sizeof (guint64));

ENVIRONMENT VARIABLES

  1. GOARCH="arm"
  2. GOBIN=""
  3. GOEXE=""
  4. GOHOSTARCH="amd64"
  5. GOHOSTOS="linux"
  6. GOOS="linux"
  7. GOPATH="/home/minhaj/GoLang"
  8. GORACE=""
  9. GOROOT="/usr/local/go"
  10. GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
  11. GCCGO="gccgo"
  12. GOARM=""
  13. CC="arm-linux-gnueabi-gcc"
  14. GOGCCFLAGS="-fPIC -marm -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build977266484=/tmp/go-build -gno-record-gcc-switches"
  15. CXX="g++"
  16. CGO_ENABLED="1"
  17. PKG_CONFIG="pkg-config"
  18. CGO_CFLAGS="-g -O2"
  19. CGO_CPPFLAGS=""
  20. CGO_CXXFLAGS="-g -O2"
  21. CGO_FFLAGS="-g -O2"
  22. CGO_LDFLAGS="-g -O2"

答案1

得分: 1

删除amd64 gtk库并重新安装32位库后,它正常工作。

英文:

After removing amd64 gtk libraries and reinstalling 32bit libraries it works fine.

huangapple
  • 本文由 发表于 2017年5月27日 22:10:17
  • 转载请务必保留本文链接:https://go.coder-hub.com/44217852.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定