How Can I MEX a dynamic library (libraw) with my own C++ code on an M2 Mac?

조회 수: 7 (최근 30일)
Darral Freund
Darral Freund 2023년 6월 30일
댓글: Rik 2023년 7월 1일
I have existing C++ code compiled with Clang++ that uses libraw on my M2 Mac. But the dynamic libraries are arm64 and won’t work when I try to use the dynamic library with MEX. I get the following error message:
Error using mex
ld: warning: ignoring file /usr/local/lib/libraw.dylib, building for macOS-x86_64 but attempting to link with file built for
macOS-arm64
Undefined symbols for architecture x86_64:
"LibRaw::LibRaw(unsigned int)", referenced from:
MexFunction::operator()(matlab::mex::MexIORange<std::__1::__wrap_iter<matlab::data::Array*>>,
matlab::mex::MexIORange<std::__1::__wrap_iter<matlab::data::Array*>>) in rawtest4.o
and more…
I wasn’t able to figure out how to create the x86_64 libraries on my M2, so I used an Intel Mac and created the dynamic libraries on it. I then copied them to the M2 and tried again, but got this message:
ld: warning: ignoring file /Users/darral/MATLAB-Drive/libraw_darral/lib/libraw.dylib, building for macOS-x86_64 but attempting
to link with file built for unknown-unsupported file format ( 0x62 0x6F 0x6F 0x6B 0x00 0x00 0x00 0x00 0x6D 0x61 0x72 0x6B 0x00
0x00 0x00 0x00 )
Undefined symbols for architecture x86_64:
"LibRaw::LibRaw(unsigned int)", referenced from:
MexFunction::operator()(matlab::mex::MexIORange<std::__1::__wrap_iter<matlab::data::Array*>>,
matlab::mex::MexIORange<std::__1::__wrap_iter<matlab::data::Array*>>) in rawtest4.o
and more….
Can anyone advise me if there is a way to do this and how I might go about it?
Thanks

채택된 답변

Rik
Rik 2023년 6월 30일
이동: Rik 2023년 7월 1일
If you're eligible for the prerelease you could give R2023b-prerelease a try, since that is native ARM.
  댓글 수: 8
Darral Freund
Darral Freund 2023년 6월 30일
이동: Rik 2023년 7월 1일
Thanks again. I installed the JRE and the 2023b pre release and the mex function successfully compiled my code and linked the dynamic libraries. This is a great solution!
Rik
Rik 2023년 7월 1일
You're welcome, glad to be of help

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Introduction to Installation and Licensing에 대해 자세히 알아보기

제품


릴리스

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by