0

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

    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));

ENVIRONMENT VARIABLES

    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"
3
  • Did you install a raspberry pi-native version of GTK+ somewhere and set your $PKG_CONFIG_PATH properly to point to it? If you don't do that, you won't be able to cross-compile GTK+ programs, and it looks like you're trying to use the system-native GTK+ there.
    – andlabs
    May 27, 2017 at 19:24
  • @andlabs , please advise how do I install GTK+ version of RaspberryPi on Ubuntu and set $PKG_CONFIG_PATH.
    – JosephCenk
    May 28, 2017 at 5:50
  • I don't know; sorry. You'll have to consult the documentation for the distro you're running on your Raspberry Pi. Your go env output says you already have the compiler set up, at least — look up the docs that talked about using arm-linux-gnueabi-gcc...
    – andlabs
    May 28, 2017 at 17:01

1 Answer 1

1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.