-
-
Notifications
You must be signed in to change notification settings - Fork 227
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CGO enabled Cross build from BSD AMD64 to FreeBSD armv7 fails #573
Comments
I forgot to say local run and compilation on FreeBSD AMD/64 work as expected. I add the go source file in the thread. I would try to compile this file directly on target but go doesn't seems available on FreeBSD12. (And Xorg or wayland are not working on FreeBSD13 ) https://www.freshports.org/lang/go // main.go
package main
import (
"github.com/veandco/go-sdl2/sdl"
)
func main() {
if err := sdl.Init(sdl.INIT_EVERYTHING); err != nil {
panic(err)
}
defer sdl.Quit()
println("create window")
window, err := sdl.CreateWindow(
"test",
sdl.WINDOWPOS_UNDEFINED,
sdl.WINDOWPOS_UNDEFINED,
800, 600, sdl.WINDOW_SHOWN,
)
if err != nil {
panic(err)
}
defer window.Destroy()
surface, err := window.GetSurface()
if err != nil {
panic(err)
}
surface.FillRect(nil, 0)
rect := sdl.Rect{50, 50, 200, 200}
colour := sdl.Color{R: 255, G: 80, B: 150, A: 255}
pixel := sdl.MapRGBA(surface.Format, colour.R, colour.G, colour.B, colour.A)
surface.FillRect(&rect, pixel)
window.UpdateSurface()
running := true
for running {
for event := sdl.PollEvent(); event != nil; event = sdl.PollEvent() {
switch event.(type) {
case *sdl.QuitEvent:
println("Quit")
running = false
break
}
}
}
} |
I succeed to x-compile with clang using my sysroot so I don't think it comes from that: #include <SDL2/SDL.h>
#include <stdio.h>
#define SCREEN_WIDTH 640
#define SCREEN_HEIGHT 480
int main(int argc, char* args[]) {
SDL_Window* window = NULL;
SDL_Surface* screenSurface = NULL;
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
fprintf(stderr, "could not initialize sdl2: %s\n", SDL_GetError());
return 1;
}
window = SDL_CreateWindow(
"hello_sdl2",
SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
SCREEN_WIDTH, SCREEN_HEIGHT,
SDL_WINDOW_SHOWN
);
if (window == NULL) {
fprintf(stderr, "could not create window: %s\n", SDL_GetError());
return 1;
}
screenSurface = SDL_GetWindowSurface(window);
SDL_FillRect(screenSurface, NULL, SDL_MapRGB(screenSurface->format, 0xFF, 0xFF, 0xFF));
SDL_UpdateWindowSurface(window);
SDL_Delay(2000);
SDL_DestroyWindow(window);
SDL_Quit();
return 0;
}
If I try to x-compile the go program with the same options I get an error about sdl go module:
|
Hi @MikHulk, unfortunately we don't have static libraries built for FreeBSD so the static compilation would fail but please let me know if the Linux one works for you. |
Hi @veeableful, thank you ! I will try and keep you update. |
I thought maybe I could build this missing lib. |
Go version: go1.20.3 freebsd/amd64
Go-SDL2 version: github.com/veandco/go-sdl2 v0.4.35
SDL2 version:
on host:
on target
OS: FreeBSD
Architecture: armv7
When I try to build some program from Freebsd amd64 for FreeBSD armv7 I get errors.
With gcc as compiler:
As this error is related to some system headers I thought I had to give location of this header. So I have made an extract of the target system file:
I tried with clang as cgo compiler too:
without sysroot I get the same error above with gcc but given by clang:
I don't know if the problem comes from BSD or GO or else.
I think I going to try with a linux target, see if it works. But Help is very welcome.
The text was updated successfully, but these errors were encountered: