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

Error with Mathematica 12.3.1 Apple ARM version #8

Open
RobR16 opened this issue Sep 16, 2021 · 2 comments
Open

Error with Mathematica 12.3.1 Apple ARM version #8

RobR16 opened this issue Sep 16, 2021 · 2 comments

Comments

@RobR16
Copy link

RobR16 commented Sep 16, 2021

Hello,
I think 12.3.1 was the first macOS Mathematica version with native ARM/Silicon support, and after upgrading to it I get the following error in a program that uses FindMathematica in its cmake-list:

"could NOT find Mathematica_WolframLibrary (missing: Mathematica_WolframLibrary_LIBRARY) (found version "6")
-- Could NOT find Mathematica (missing: Mathematica_WolframLibrary_LIBRARY) (found version "12.3.1")"

After looking in the cmakeCACHE file, I found that it did not find the Wolfram Runtime Library (correct path: "/Applications/Mathematica.app/Contents/SystemFiles/Libraries/MacOSX-ARM64/libWolframRTL.dylib" ),

and the cache file contains the entry
//Last value of Mathematica_SYSTEM_IDS.
Mathematica_SYSTEM_IDS_LAST:INTERNAL=MacOSX-x86-64

which I guess could be problematic. It seems like in most other relevant paths it correctly replaced MacOSX-x86-64 by /MacOSX-ARM64. I will try to fix it by myself, but if you could make FindMathematica compatible with the 12.3.1 version in a clean way, I guess it would be greatly appreciated by many.

@windfolgen
Copy link

windfolgen commented Nov 4, 2021

Hello,
I have exactly the same problem with you and I don't know how to solve it. Is it OK to replace the wrong KEYs manually? Have you found a clean way to solve it? I really appreciate it if you or someone else could help.

@windfolgen
Copy link

windfolgen commented Nov 5, 2021

I think I may find how to resolve this problem. The solution is simple: just add below syntax in the CMakeList.txt before compiling it
set(CMAKE_OSX_ARCHITECTURE arm64)
The reason may be that default value for CMAKE_OSX_ARCHITECTURE is null, so you should set it first. In the FindMathematica.cmake you can find the following macro
macro (_get_system_IDs _outSystemIDs)
if (WIN32 OR CYGWIN)
...
elseif (APPLE)
set (${_outSystemIDs} "")
if (CMAKE_OSX_ARCHITECTURES)
# determine System ID from specified architectures
...
else()
# determine System ID by checking endianness and pointer size
TEST_BIG_ENDIAN(_isBigEndian)
if (_isBigEndian)
...
else ()
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
set (${_outSystemIDs} "MacOSX-x86-64")
else ()
set (${_outSystemIDs} "MacOSX-x86")
endif()
endif()
endif()
elseif (UNIX)
...
else()
...
endmacro(_get_system_IDs)
If you don't set CMAKE_OSX_ARCHITECTURES, then it will determine by checking endianness and pointer size. Since apple M1 is little endian, it will check CMAKE_SIZEOF_VOID_P and further determine the result. However, it only provide two choices "MacOSX-x86-64" and "MacOSX-x86". So this will give you a wrong value on a MacOSX-ARM64 machine. If CMAKE_OSX_ARCHITECTURES is set, this problem won't appear. I hope this can help explain why it may go wrong on apple ARM machine.

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