minecraft-again icon indicating copy to clipboard operation
minecraft-again copied to clipboard

Can't build on Intel MBP

Open antoinedenovembre opened this issue 3 years ago • 1 comments

Whenever I try to use 'make' it gives the error : "make[1]: *** No rule to make target `osx-arm64'. Stop." Any ideas ? NB : I already added every submodule I could find.

antoinedenovembre avatar Jan 17 '22 03:01 antoinedenovembre

You need to do a few adjustments both to bimg and bx because their Makefile is broken for osx-x64 (points to incorrect build directory).

Change the following lines in lib/bimg/makefile and lib/bx/makefile:

diff --git a/makefile b/makefile
index c2e23f8..0410858 100644
--- a/makefile
+++ b/makefile
@@ -156,9 +156,9 @@ vs2017: vs2017-debug32 vs2017-release32 vs2017-debug64 vs2017-release64 ## Build
 .build/projects/gmake-osx-x64:
 	$(GENIE) --gcc=osx-x64 gmake
 osx-x64-debug: .build/projects/gmake-osx-x64
-	make -C .build/projects/gmake-osx config=debug
+	make -C .build/projects/gmake-osx-x64 config=debug
 osx-x64-release: .build/projects/gmake-osx-x64
-	make -C .build/projects/gmake-osx config=release
+	make -C .build/projects/gmake-osx-x64 config=release
 osx-x64: osx-x64-debug osx-x64-release

 .build/projects/gmake-ios-arm:

Then update the Makefile in the project root:

diff --git a/Makefile b/Makefile
index dce485d..8eafe7f 100644
--- a/Makefile
+++ b/Makefile
@@ -37,6 +44,11 @@ ifeq ($(UNAME_S), Darwin)
 	# TODO: select based on ($ arch)
 	BGFX_DEPS_TARGET=osx-arm64
 	BGFX_TARGET=osx-arm
+
+	ifeq ($(UNAME_M),x86_64)
+		BGFX_DEPS_TARGET=osx-x64
+		BGFX_TARGET=osx-x64-release
+	endif
 endif

 ifeq ($(UNAME_S), Linux)

Then run make run.

Hint: You can also compile the individual libraries from their project folder with make -j8 instead. Change the Makefile with the following, before running make -j8 run:

diff --git a/Makefile b/Makefile
index dce485d..35de073 100644
--- a/Makefile
+++ b/Makefile
@@ -74,9 +86,9 @@ all: dirs libs shaders build

libs:
	export LD_PATH="$(FRAMEWORKS)"
-	cd lib/bx && make $(BGFX_DEPS_TARGET)
-	cd lib/bimg && make $(BGFX_DEPS_TARGET)
-	cd lib/bgfx && make $(BGFX_TARGET)
+	cd lib/bx && make -j8 $(BGFX_DEPS_TARGET)
+	cd lib/bimg && make -j8 $(BGFX_DEPS_TARGET)
+	cd lib/bgfx && make -j8 $(BGFX_TARGET)
	cd lib/glfw && cmake . && make
	cd lib/noise && make
	export LD_PATH=""

Building for earlier macOS (i.e. Mojave):

Xcode 11 does not come with a version of LLVM that has C++20 support, nor the libraries necessary. You will need to install at least LLVM 13.0.0 to get appropriate support.

This can be done with Homebrew:

brew install llvm

Note: Homebrew does not provide pre-compiled binaries for Mojave. When installing it will compile LLVM from scratch. This will take a long time, so grab a cup of coffee and sit back. Or take a nap. I did the latter.

Once installed, restart your terminal and confirm the versions with the following command:

$ `brew --prefix llvm`/bin/clang++ --version
Homebrew clang version 13.0.0
Target: x86_64-apple-darwin18.7.0
Thread model: posix
InstalledDir: /usr/local/opt/llvm/bin

Verify the Homebrew clang and version number is >=13.0.0

Now update the Makefile in the project root to use the appropriate compiler libraries:

diff --git a/Makefile b/Makefile
index dce485d..35de073 100644
--- a/Makefile
+++ b/Makefile
@@ -2,8 +2,14 @@
 print-%  : ; @echo $* = $($*)

 UNAME_S = $(shell uname -s)
 UNAME_M = $(shell uname -m)

+LLVM_PREFIX=$(shell brew --prefix llvm)
+LLVM_BIN=$(LLVM_PREFIX)/bin
+LLVM_LIB=$(LLVM_PREFIX)/lib
+
-CC = clang++
+CC = $(LLVM_BIN)/clang++

 INCFLAGS  = -iquotesrc
 INCFLAGS += -Ilib/glm
@@ -14,6 +20,7 @@ INCFLAGS += -Ilib/glfw/include
 INCFLAGS += -Ilib/bgfx/3rdparty/fcpp
 INCFLAGS += -Ilib/tomlplusplus
 INCFLAGS += -Ilib/noise
+INCFLAGS += -L $(LLVM_LIB)

 CCFLAGS  = -std=c++20 -O2 -g -Wall -Wextra -Wpedantic -Wno-c99-extensions
 CCFLAGS += -Wno-unused-parameter

fnky avatar Jan 17 '22 12:01 fnky