### Basic Window Creation in raylib-go Source: https://github.com/gen2brain/raylib-go/blob/master/README.md This snippet demonstrates how to initialize a window, set the target FPS, and draw text within the main game loop. It's a fundamental example for starting with raylib-go. ```go package main import rl "github.com/gen2brain/raylib-go/raylib" func main() { rl.InitWindow(800, 450, "raylib [core] example - basic window") defer rl.CloseWindow() rl.SetTargetFPS(60) for !rl.WindowShouldClose() { rl.BeginDrawing() rl.ClearBackground(rl.RayWhite) rl.DrawText("Congrats! You created your first window!", 190, 200, 20, rl.LightGray) rl.EndDrawing() } } ``` -------------------------------- ### Cross-compile for Windows (64-bit) Source: https://github.com/gen2brain/raylib-go/blob/master/README.md Builds a 64-bit Windows executable from Linux using MinGW. Ensure the MinGW toolchain is installed. ```bash $ CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc GOOS=windows GOARCH=amd64 go build -ldflags "-s -w" $ file basic_window.exe basic_window.exe: PE32+ executable (console) x86-64 (stripped to external PDB), for MS Windows, 11 sections ``` -------------------------------- ### Export Android SDK Path Source: https://github.com/gen2brain/raylib-go/blob/master/examples/others/android/example/README.md Set the ANDROID_HOME environment variable to the Android SDK installation directory. ```bash export ANDROID_HOME=/opt/android-sdk ``` -------------------------------- ### Cross-compile for Windows (32-bit) Source: https://github.com/gen2brain/raylib-go/blob/master/README.md Builds a 32-bit Windows executable from Linux using MinGW. Ensure the MinGW toolchain is installed. ```bash $ CGO_ENABLED=1 CC=i686-w64-mingw32-gcc GOOS=windows GOARCH=386 go build -ldflags "-s -w" $ file basic_window.exe basic_window.exe: PE32 executable (console) Intel 80386 (stripped to external PDB), for MS Windows, 9 sections ``` -------------------------------- ### Cross-compile for macOS (64-bit) Source: https://github.com/gen2brain/raylib-go/blob/master/README.md Builds a 64-bit macOS executable from Linux using the OSXCross toolchain. Ensure OSXCross is installed. ```bash $ CGO_ENABLED=1 CC=x86_64-apple-darwin21.1-clang GOOS=darwin GOARCH=amd64 go build -ldflags "-linkmode external -s -w '-extldflags=-mmacosx-version-min=10.15'" $ file basic_window basic_window: Mach-O 64-bit x86_64 executable, flags: ``` -------------------------------- ### Export Android NDK Path Source: https://github.com/gen2brain/raylib-go/blob/master/examples/others/android/example/README.md Set the ANDROID_NDK_HOME environment variable to the NDK installation directory. Ensure NDK version 27 is not used. ```bash export ANDROID_NDK_HOME=/opt/android-ndk ``` -------------------------------- ### Cross-compile for macOS (ARM 64-bit) Source: https://github.com/gen2brain/raylib-go/blob/master/README.md Builds an ARM 64-bit macOS executable from Linux using the OSXCross toolchain. Ensure OSXCross is installed. ```bash $ CGO_ENABLED=1 CC=aarch64-apple-darwin21.1-clang GOOS=darwin GOARCH=arm64 go build -ldflags "-linkmode external -s -w '-extldflags=-mmacosx-version-min=12.0.0'" $ file basic_window basic_window: Mach-O 64-bit arm64 executable, flags: ``` -------------------------------- ### Add NDK Toolchain to PATH Source: https://github.com/gen2brain/raylib-go/blob/master/examples/others/android/example/README.md Add the NDK's toolchain binary directory to your system's PATH for compilation. ```bash export PATH=${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin:${PATH} ``` -------------------------------- ### Build Android APK Source: https://github.com/gen2brain/raylib-go/blob/master/examples/others/android/example/README.md Build a debuggable Android application package (APK) using Gradle. ```bash ./gradlew assembleDebug ``` -------------------------------- ### Compile Shared Library for Android (AArch64) Source: https://github.com/gen2brain/raylib-go/blob/master/examples/others/android/example/README.md Instructions for compiling a C-shared library for Android AArch64 (ARM64) architecture. Use a minimum ANDROID_API of 21 and adjust toolchain and GOARCH accordingly. ```bash # For aarch64/arm64 replace `arm-linux-androideabi` with `aarch64-linux-android`, set GOARCH to arm64 and use minimum `ANDROID_API=21`. ``` -------------------------------- ### Export Android API Version Source: https://github.com/gen2brain/raylib-go/blob/master/examples/others/android/example/README.md Set the minimum Android API level for compilation. ```bash export ANDROID_API=16 ``` -------------------------------- ### Compile Shared Library for Android (ARMv7) Source: https://github.com/gen2brain/raylib-go/blob/master/examples/others/android/example/README.md Compile a C-shared library for Android ARMv7 architecture. Requires setting C compiler flags, linker flags, and build environment variables. ```bash CC="armv7a-linux-androideabi${ANDROID_API}-clang" \ CGO_CFLAGS="-I${ANDROID_SYSROOT}/usr/include -I${ANDROID_SYSROOT}/usr/include/arm-linux-androideabi --sysroot=${ANDROID_SYSROOT} -D__ANDROID_API__=${ANDROID_API}" \ CGO_LDFLAGS="-L${ANDROID_SYSROOT}/usr/lib/arm-linux-androideabi/${ANDROID_API} -L${ANDROID_TOOLCHAIN}/arm-linux-androideabi/lib --sysroot=${ANDROID_SYSROOT}" \ CGO_ENABLED=1 GOOS=android GOARCH=arm \ go build -buildmode=c-shared -ldflags="-s -w -extldflags=-Wl,-soname,libexample.so" \ -o=android/libs/armeabi-v7a/libexample.so ``` -------------------------------- ### Export Android Sysroot and Toolchain Source: https://github.com/gen2brain/raylib-go/blob/master/examples/others/android/example/README.md Define ANDROID_SYSROOT and ANDROID_TOOLCHAIN variables pointing to the NDK sysroot and toolchain directories. ```bash export ANDROID_SYSROOT=${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/sysroot export ANDROID_TOOLCHAIN=${ANDROID_NDK_HOME}/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64 ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.