Skip to content
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

mgba 0.10.0 build failure on apple m1 #2700

Closed
chenrui333 opened this issue Oct 21, 2022 · 9 comments
Closed

mgba 0.10.0 build failure on apple m1 #2700

chenrui333 opened this issue Oct 21, 2022 · 9 comments

Comments

@chenrui333
Copy link

Got some build failure as follows when trying to build on apple m1

  undef: _mSDLGLCreate
  Undefined symbols for architecture arm64:
    "_mSDLGLCreate", referenced from:
        _main in lto.o
  ld: symbol(s) not found for architecture arm64
  clang: error: linker command failed with exit code 1 (use -v to see invocation)
  make[2]: *** [sdl/mgba] Error 1
  make[1]: *** [sdl/CMakeFiles/mgba-sdl.dir/all] Error 2
  make[1]: *** Waiting for unfinished jobs....

relates to Homebrew/homebrew-core#112961

@endrift
Copy link
Member

endrift commented Oct 21, 2022

Please give me your CMakeCache.txt. It builds fine on M1 with the right flags.

@endrift
Copy link
Member

endrift commented Oct 21, 2022

It's worth noting that BUILD_GL, the define gating using that function, is forced off if the SDK is 10.14 or newer. Which Includes the M1 SDK. Not really sure how you wound up with it enabled.

@endrift
Copy link
Member

endrift commented Oct 21, 2022

I see the problem. You're relying on libepoxy. You shouldn't do that on macOS; that's only needed on Windows.

@chenrui333
Copy link
Author

ok, let me give that a try.

@endrift
Copy link
Member

endrift commented Oct 21, 2022

If you want to keep epoxy, please test this patch:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index ce8e4d687..a8116d3ea 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -718,8 +718,13 @@ if (USE_LZMA)
 endif()
 
 if(USE_EPOXY)
-	list(APPEND FEATURE_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/platform/opengl/gl.c ${CMAKE_CURRENT_SOURCE_DIR}/src/platform/opengl/gles2.c)
-	list(APPEND FEATURE_DEFINES BUILD_GL BUILD_GLES2 BUILD_GLES3)
+	if(APPLE AND MACOSX_SDK VERSION_GREATER 10.14)
+		list(APPEND FEATURE_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/platform/opengl/gles2.c)
+		list(APPEND FEATURE_DEFINES BUILD_GLES2 BUILD_GLES3)
+	else()
+		list(APPEND FEATURE_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/platform/opengl/gl.c ${CMAKE_CURRENT_SOURCE_DIR}/src/platform/opengl/gles2.c)
+		list(APPEND FEATURE_DEFINES BUILD_GL BUILD_GLES2 BUILD_GLES3)
+	endif()
 	list(APPEND FEATURES EPOXY)
 	include_directories(AFTER ${EPOXY_INCLUDE_DIRS})
 	link_directories(${EPOXY_LIBRARY_DIRS})

which I will commit upstream if it works.

@chenrui333
Copy link
Author

yeah, that build patch works for me, I also added the lua and libelf dependencies

@endrift
Copy link
Member

endrift commented Oct 21, 2022

I'll commit a variant of it then. Gimme a sec.

@endrift
Copy link
Member

endrift commented Oct 21, 2022

I've cherry-picked the patch into 0.10.1, so it'll be in the next stable release.

@chenrui333
Copy link
Author

Sounds good, thanks!

rtomasa pushed a commit to rtomasa/mgba that referenced this issue Sep 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants