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

Issues with M1 chip #8

Open
weizhi-lin opened this issue May 20, 2022 · 6 comments
Open

Issues with M1 chip #8

weizhi-lin opened this issue May 20, 2022 · 6 comments

Comments

@weizhi-lin
Copy link

Hi, thank you very much for the wonderful solutions on the geodesic distance computation toolbox. It works with windows and old macOS perfectly. However, I encountered issues with new Apple model with M1 chip. The error was:

"... (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')), ..."

I would appreciate it sincerely if you can help with this issue. Many thanks!

@zishun
Copy link
Owner

zishun commented May 20, 2022

Hi! I suppose you met the error when compiling the code. Could you provide more details like a screenshot?
I am not able to test it myself since I do not have an M1 computer. It is neither supported in Github Actions as I know.

@weizhi-lin
Copy link
Author

Hi, thank you for replying! Attached please find all the information I have when compiling the codes. Thanks!

Warning Messages when compiling the codes in the terminal:

weizhilin@Tobys-MacBook-Air src % make debug
g++ -c ./geodesic_matlab_api.cpp -o ./geodesic_matlab_api.o -Wall -O2 -fPIC -DDEBUG -g
In file included from ./geodesic_matlab_api.cpp:14:
./geodesic_algorithm_subdivision.h:22:3: warning: field 'm_previous' will be initialized after field 'm_distance' [-Wreorder-ctor]
m_previous(NULL),
^~~~~~~~~~~~~~~~
m_distance(0.0)
./geodesic_algorithm_subdivision.h:29:3: warning: field 'm_previous' will be initialized after field 'm_distance' [-Wreorder-ctor]
m_previous(NULL),
^~~~~~~~~~~~~~~~
m_distance(0.0)
In file included from ./geodesic_matlab_api.cpp:15:
./geodesic_algorithm_exact.h:449:19: warning: array subscript is of type 'char' [-Wchar-subscripts]
double x = inter[i];
^~
./geodesic_algorithm_exact.h:452:14: warning: array subscript is of type 'char' [-Wchar-subscripts]
good_start[Ngood_start++] = x;
^~~~~~~~~~~~~~
./geodesic_algorithm_exact.h:455:12: warning: array subscript is of type 'char' [-Wchar-subscripts]
good_start[Ngood_start++] = right;
^~~~~~~~~~~~~~
./geodesic_algorithm_exact.h:460:27: warning: array subscript is of type 'char' [-Wchar-subscripts]
double mid = (good_start[i] + good_start[i+1])*0.5;
^~
./geodesic_algorithm_exact.h:461:10: warning: array subscript is of type 'char' [-Wchar-subscripts]
mid_map[i] = zero->signal(mid) <= one->signal(mid) ? OLD : NEW;
^~
./geodesic_algorithm_exact.h:565:16: warning: unused variable 'list' [-Wunused-variable]
list_pointer list = interval_list(edge);
^
./geodesic_matlab_api.cpp:37:1: warning: non-void function does not return a value in all control paths [-Wreturn-type]
}
^
./geodesic_matlab_api.cpp:45:14: warning: unused variable 'mesh_id' [-Wunused-variable]
std::size_t mesh_id = find_mesh_id(algorithm->mesh());
^
In file included from ./geodesic_matlab_api.cpp:14:
./geodesic_algorithm_subdivision.h:22:3: warning: field 'm_previous' will be initialized after field 'm_distance' [-Wreorder-ctor]
m_previous(NULL),
^~~~~~~~~~~~~~~
m_distance(0.0
./geodesic_algorithm_subdivision.h:102:22: note: in instantiation of function template specialization 'geodesic::SubdivisionNode::SubdivisionNode<geodesic::Vertex *>' requested here
m_nodes.push_back(Node(v)); //!!
^
./geodesic_algorithm_subdivision.h:29:3: warning: field 'm_previous' will be initialized after field 'm_distance' [-Wreorder-ctor]
m_previous(NULL),
^~~~~~~~~~~~~~~
m_distance(0.0
./geodesic_algorithm_subdivision.h:126:23: note: in instantiation of function template specialization 'geodesic::SubdivisionNode::SubdivisionNode<geodesic::Edge *, double>' requested here
m_nodes.push_back(Node(e, offset));
^
12 warnings generated.
g++ -shared -o ./geodesic_debug.so ./geodesic_matlab_api.o

Error when run example1 in the MATLAB

Error using loadlibrary
There was an error loading the library
"/Users/weizhilin/Downloads/geodesic_matlab-master/matlab/geodesic_debug.so"
dlopen(/Users/weizhilin/Downloads/geodesic_matlab-master/matlab/geodesic_debug.so,
0x0006): tried:
'/Users/weizhilin/Downloads/geodesic_matlab-master/matlab/geodesic_debug.so'
(mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')),
'/usr/local/lib/geodesic_debug.so' (no such file), '/usr/lib/geodesic_debug.so'
(no such file)

Error in geodesic_new_mesh (line 9)
loadlibrary([geodesic_library '.so'], hfile);

Error in example1 (line 13)
mesh = geodesic_new_mesh(vertices,faces); %initilize new mesh

Caused by:
Error using loaddefinedlibrary
dlopen(/Users/weizhilin/Downloads/geodesic_matlab-master/matlab/geodesic_debug.so,
0x0006): tried:
'/Users/weizhilin/Downloads/geodesic_matlab-master/matlab/geodesic_debug.so'
(mach-o file, but is an incompatible architecture (have 'arm64', need
'x86_64')), '/usr/local/lib/geodesic_debug.so' (no such file),
'/usr/lib/geodesic_debug.so' (no such file)

@zishun
Copy link
Owner

zishun commented May 20, 2022

Looks like you have finished:

cd src
make debug
cp ./geodesic_debug.so ../matlab/

Can you try:

cd src
make example0
./example0.out hedgehog_mesh.txt 3 14

It is highly possible to be a matlab issue if example0 exits successfully.

@weizhi-lin
Copy link
Author

weizhi-lin commented May 20, 2022 via email

@zishun
Copy link
Owner

zishun commented May 21, 2022

I see. I think the problem happens inside loadlibrary. We can do nothing with the C++ code here. You may already come up with several potential solutions like

  • building the geodesic solver as a stand-alone executable and calling it with matlab.
  • using the python-binding of this implementation and calling it with matlab.
    • Even entirely shift to python to enjoy more tools from the open-source community.
  • finding out what happens inside loadlibrary.

Good luck with your work!

@andersonwinkler
Copy link

I was having the same problem. What happens is that when we compile on M1, we get an arm64 binary, but currently (as of 2023a), Matlab is still x86_64 (even when we install on Apple Silicon).

The workaround, therefore, is to compile in an old Intel Mac, then transfer the geodesic_debug.so file to the newer M1 Mac. I just did that and it worked. If it helps, I'm attaching the file here (gzipped; use at your own risk).

geodesic_debug.so.gz

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

3 participants