Hi.
I'm trying to compile functions previously compiled with mex in MATLAB
>> mex Cbetabinornd.cpp
Now gives the following error message:
Renamed options file '/Users/lfslbx/Library/Application Support/MathWorks/MATLAB/R2025b/mex_C++_maca64.xml' to '/Users/lfslbx/Library/Application Support/MathWorks/MATLAB/R2025b/mex_C++_maca64_backup.xml'.
Building with 'Xcode Clang++'.
Error using mex
Undefined symbols for architecture arm64:
"_mexCreateMexFunction", referenced from:
<initial-undefines>
"_mexDestroyMexFunction", referenced from:
<initial-undefines>
"_mexFunctionAdapter", referenced from:
<initial-undefines>
ld: symbol(s) not found for architecture arm64
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
If I use the -v option there is a lot of information, I can paste it here if required.
I think this has happened since my last MacOS upgrade (to Sequoia 15.7) and/or xcode command line tools update (clang++ version 17.0.0).
I have tried uninstalling and reinstalling the xcode command line tools and have installed MATLAB 2025b (it was failing on 2023b also).
Any suggestions welcomed.
Thanks.

 채택된 답변

Ron Crump
Ron Crump 2025년 10월 8일
이동: Torsten 2025년 10월 8일

1 개 추천

The two .cpp files in question were using the C API. We have recoded them to use the C++ API and they now compile.

댓글 수: 3

The problem seems to be caused by a bug in the latest version of xcode command line tools. For those who can't (or don't want to) switch to the C++ API, a temporary workaround is to pass the -ld_classic flag to the linker. When using the mex command, the right invocation should be something like
mex LINKFLAGS='$LINKFLAGS -ld_classic' source.cpp
Ron Crump
Ron Crump 2025년 10월 10일
Thanks, Bruno. Good to know.
Robert
Robert 2025년 10월 28일
Thanks Bruno, fixed my problem with this message as well, for now.
FYI, on my 2024b LINKFLAGS didnt' work, I had to use LDFLAGS
also note the: ld: warning: -ld_classic is deprecated and will be removed in a future release

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Write C Functions Callable from MATLAB (MEX Files)에 대해 자세히 알아보기

제품

릴리스

R2025b

질문:

2025년 9월 30일

댓글:

2025년 10월 28일

Community Treasure Hunt

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

Start Hunting!

Translated by