Open bartgrantham opened 4 years ago
To cross-compile something that uses CGO you need to have a toolchain and compiler for that platform installed. For example, CC=x86_64-w64-mingw32-gcc when you cross compile for Windows, or CC=arm-linux-androideabi-clang for Android etc.
It seems you are just trying to add GOOS=linux and GOARCH=amd64 with your native compiler?
Now that you say this (and after sleeping on it), this makes perfect sense. I did install x86_64-w64-mingw32-gcc
in order to have a Windows cross-compiler, but I haven't installed one for Linux. I guess part of why I was confused is because I was mixing up my native macOS gcc (which I have installed) and a Linux gcc cross-compiler (which I do not).
Is there a homebrew package for linux-gcc? Is x86_64-elf-gcc
what I'm looking for here?
Got the same issue on Linux using (no cross-compilation here):
The previous libraries (with go1.13.8 & gcc 7.5.0) didn't have this issue. Output when go build-ing (-tags static):
# github.com/veandco/go-sdl2/sdl
/usr/bin/ld: ../../../../github.com/veandco/go-sdl2/sdl/../.go-sdl2-libs/libSDL2_linux_amd64.a(SDL.c.o): unable to initialize decompress status for section .debug_info
/usr/bin/ld: ../../../../github.com/veandco/go-sdl2/sdl/../.go-sdl2-libs/libSDL2_linux_amd64.a(SDL.c.o): unable to initialize decompress status for section .debug_info
/usr/bin/ld: ../../../../github.com/veandco/go-sdl2/sdl/../.go-sdl2-libs/libSDL2_linux_amd64.a(SDL_dynapi.c.o): unable to initialize decompress status for section .debug_info
/usr/bin/ld: ../../../../github.com/veandco/go-sdl2/sdl/../.go-sdl2-libs/libSDL2_linux_amd64.a(SDL_dynapi.c.o): unable to initialize decompress status for section .debug_info
../../../../github.com/veandco/go-sdl2/sdl/../.go-sdl2-libs/libSDL2_linux_amd64.a: error adding symbols: File format not recognized
collect2: error: ld returned 1 exit status
After some searching (edit):
The issue might be caused by a bug in elfutils & binutils.
Since I'm using binutils 2.30 I assume a recent elfutils is used for building the static libraries (0.176 or more recent).
References:
I'm having trouble cross-compiling from mac (darwin) to linux, both amd64. I am running go version go1.14.3 darwin/amd64.
The program in question can be statically compiled for macOS (compiler host), and statically cross-compiled from macOS to Windows. But static cross-compiling from macOS to linux gives the following error during linking:
I've read elsewhere that this is a gcc/clang difference, and I can see that the sdl sources include that flag for building linux binaries, but I don't know how to either tell it to use the gcc linker or switch that flag for something clang-appropriate.
Also, when I statically compile on linux for linux:
Dynamic builds under mac->mac and linux->linux work fine.
It might be something silly, I admit that I haven't dug too deep into the options here. Thanks for any help you can provide!
PS - I really like this project... I sure hope I can get a completely cross-platform build process working.