From bb7b13ef3c1c06e39ef57df55757f811771e6666 Mon Sep 17 00:00:00 2001 From: Damien Pitard Date: Tue, 21 Dec 2021 19:03:25 +0100 Subject: [PATCH] fixed cross-compilation from x86-64 (debian buster) to Raspberry Pi (raspbian) (#2233) --- examples/Makefile | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/examples/Makefile b/examples/Makefile index 93b943ab4..657da6209 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -61,6 +61,15 @@ USE_EXTERNAL_GLFW ?= FALSE # by default it uses X11 windowing system USE_WAYLAND_DISPLAY ?= FALSE +# Use cross-compiler for PLATFORM_RPI +ifeq ($(PLATFORM),PLATFORM_RPI) + USE_RPI_CROSS_COMPILER ?= FALSE + ifeq ($(USE_RPI_CROSS_COMPILER),TRUE) + RPI_TOOLCHAIN ?= C:/SysGCC/Raspberry + RPI_TOOLCHAIN_SYSROOT ?= $(RPI_TOOLCHAIN)/arm-linux-gnueabihf/sysroot + endif +endif + # Determine PLATFORM_OS in case PLATFORM_DESKTOP selected ifeq ($(PLATFORM),PLATFORM_DESKTOP) # No uname.exe on MinGW!, but OS=Windows_NT on Windows! @@ -243,9 +252,9 @@ INCLUDE_PATHS = -I. -I$(RAYLIB_PATH)/src -I$(RAYLIB_PATH)/src/external -I$(RAYLI # Define additional directories containing required header files ifeq ($(PLATFORM),PLATFORM_RPI) # RPI required libraries - INCLUDE_PATHS += -I/opt/vc/include - INCLUDE_PATHS += -I/opt/vc/include/interface/vmcs_host/linux - INCLUDE_PATHS += -I/opt/vc/include/interface/vcos/pthreads + INCLUDE_PATHS += -I$(RPI_TOOLCHAIN_SYSROOT)/opt/vc/include + INCLUDE_PATHS += -I$(RPI_TOOLCHAIN_SYSROOT)/opt/vc/include/interface/vmcs_host/linux + INCLUDE_PATHS += -I$(RPI_TOOLCHAIN_SYSROOT)/opt/vc/include/interface/vcos/pthreads endif ifeq ($(PLATFORM),PLATFORM_DRM) # DRM required libraries @@ -310,7 +319,7 @@ ifeq ($(PLATFORM),PLATFORM_WEB) EXT = .html endif ifeq ($(PLATFORM),PLATFORM_RPI) - LDFLAGS += -L/opt/vc/lib + LDFLAGS += -L$(RPI_TOOLCHAIN_SYSROOT)/opt/vc/lib endif # Define any libraries required on linking @@ -364,6 +373,9 @@ ifeq ($(PLATFORM),PLATFORM_RPI) # Libraries for Raspberry Pi compiling # NOTE: Required packages: libasound2-dev (ALSA) LDLIBS = -lraylib -lbrcmGLESv2 -lbrcmEGL -lpthread -lrt -lm -lbcm_host -ldl + ifeq ($(USE_RPI_CROSS_COMPILER),TRUE) + LDLIBS += -lvchiq_arm -lvcos + endif endif ifeq ($(PLATFORM),PLATFORM_DRM) # Libraries for DRM compiling