Why do I receive the message "ld: warning dynamic shared library: /usr/lib/libm.dylib not made a weak..." when building a MEX-file in MATLAB?

1 view (last 30 days)
Why do I receive the message "ld: warning dynamic shared library: /usr/lib/libm.dylib not made a weak..." when building a MEX-file in MATLAB?
I have a MEX-file that I am trying to compile on Mac OS X 10.2. The file compiles fine on Windows 2000 and produces the appropriate DLL. On Mac OS X 10.2, I try to compile the file using the following command:
mex -I/usr/include/sys file.c
and I get the following message:
ld: warning dynamic shared library:
/usr/lib/libm.dylib not made a weak library in output with
MACOSX_DEPLOYMENT_TARGET environment variable set to: 10.1

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
The following information, shown on the Apple website, addresses this issue:
Here is what is happening: the framework or library (call it library A) listed by ld is linked by your application, but you use no symbols directly from it. Another framework or library (call it library B) that you link against and use DOES use symbols from library A. The linker gets confused, and tries to weak link library A, when it should instead be linking it strongly. Since by default the MACOSX_DEPLOYMENT_TARGET environment variable (which controls binary features introduced in specific OS versions) is set to 10.1, and weak linking was introduced in 10.2, the warning is generated.
Here are two suggested workarounds in the meantime:
1) If you do not mind weak linking against library A and do not mind requiring Mac OS X 10.2 or higher to run, you can set the MACOSX_DEPLOYMENT_TARGET to 10.2 in a target build setting in Project Builder. Note that after doing this, if you are using cpp-precomp precompiled header technology (instead of newer precompiled header technology like the PFE) you may see lots of warnings about your precompiled headers being broken. To fix this, you need to rebuild your precompiled headers like so from Terminal:
setenv MACOSX_DEPLOYMENT_TARGET 10.2
sudo fixPrecomps -force
2) If you do in fact need to continue building for Mac OS X 10.1 and higher, or don't wish to start weak linking against library A, then you can make a gratuitous reference to a symbol in the library to get the linker to strongly link against it.

More Answers (0)

Categories

Find more on MATLAB Compiler SDK in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!