2017-05-27 55 views
0

我正在使用GO-GTK來顯示圖像,該項目在amd64上工作正常,但是當我嘗試爲arm(RaspberryPi)交叉編譯時,它給了我下面的錯誤。 請指教如何交叉編譯go-gtk從amd64到arm(Raspberrypi3)。下面用於RaspberryPi的GO-GTK交叉編譯

github.com/mattn/go-gtk/glib 
# github.com/mattn/go-gtk/glib 
In file included from /usr/lib/x86_64-linux-gnu/glib-2.0/include/glibconfig.h:9:0, 
       from /usr/include/glib-2.0/glib/gtypes.h:32, 
       from /usr/include/glib-2.0/glib/galloca.h:32, 
       from /usr/include/glib-2.0/glib.h:30, 
       from ./glib.go.h:4, 
       from src/github.com/mattn/go-gtk/glib/glib.go:5: 
/usr/include/glib-2.0/glib/gtypes.h: In function '_GLIB_CHECKED_ADD_U64': 
/usr/include/glib-2.0/glib/gmacros.h:232:53: error: size of array '_GStaticAssertCompileTimeAssertion_0' is negative 
#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: note: in definition of macro 'G_PASTE_ARGS' 
#define G_PASTE_ARGS(identifier1,identifier2) identifier1 ## identifier2 
              ^
/usr/include/glib-2.0/glib/gmacros.h:232:44: note: in expansion of macro '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: note: in expansion of macro 'G_STATIC_ASSERT' 
    G_STATIC_ASSERT(sizeof (unsigned long long) == sizeof (guint64)); 
^
github.com/mattn/go-gtk/pango 
# github.com/mattn/go-gtk/pango 
In file included from /usr/lib/x86_64-linux-gnu/glib-2.0/include/glibconfig.h:9:0, 
       from /usr/include/glib-2.0/glib/gtypes.h:32, 
       from /usr/include/glib-2.0/glib/galloca.h:32, 
       from /usr/include/glib-2.0/glib.h:30, 
       from /usr/include/pango-1.0/pango/pango-coverage.h:25, 
       from /usr/include/pango-1.0/pango/pango-font.h:25, 
       from /usr/include/pango-1.0/pango/pango-attributes.h:25, 
       from /usr/include/pango-1.0/pango/pango.h:25, 
       from ./pango.go.h:7, 
       from src/github.com/mattn/go-gtk/pango/pango.go:5: 
/usr/include/glib-2.0/glib/gtypes.h: In function '_GLIB_CHECKED_ADD_U64': 
/usr/include/glib-2.0/glib/gmacros.h:232:53: error: size of array '_GStaticAssertCompileTimeAssertion_0' is negative 
#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: note: in definition of macro 'G_PASTE_ARGS' 
#define G_PASTE_ARGS(identifier1,identifier2) identifier1 ## identifier2 
              ^
/usr/include/glib-2.0/glib/gmacros.h:232:44: note: in expansion of macro '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: note: in expansion of macro '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" 
+0

您是否在某處安裝了一個樹莓派原生版的GTK +,並正確設置了您的$ PKG_CONFIG_PATH指向它?如果你不這樣做,你將無法交叉編譯GTK +程序,並且看起來你正在嘗試在那裏使用系統原生GTK +。 – andlabs

+0

@andlabs,請告訴我如何在Ubuntu上安裝RaspberryPi的GTK +版本並設置$ PKG_CONFIG_PATH。 – JosephCenk

+0

我不知道;抱歉。您必須查閱您在Raspberry Pi上運行的發行版的文檔。你的'en env'輸出表示你已經設置了編譯器,至少 - 查閱使用'arm-linux-gnueabi-gcc'討論的文檔... – andlabs

回答

1

編譯器輸出給定的取出AMD64 GTK庫並重新安裝32位的庫後它工作正常。