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

Building MATLAB wrapper "__OSX_AVAILABLE_BUT_DEPRECATED" #915

Closed
damro opened this issue Aug 12, 2014 · 38 comments
Closed

Building MATLAB wrapper "__OSX_AVAILABLE_BUT_DEPRECATED" #915

damro opened this issue Aug 12, 2014 · 38 comments

Comments

@damro
Copy link

damro commented Aug 12, 2014

Hey there!
I hope someone can help me with this issue. When compiling the MATLAB wrapper with 'make matcaffe' I get the following error.

Building with 'Xcode Clang++'.
In file included from /Users/damian/workspace/caffe/matlab/caffe/matcaffe.cpp:12:
In file included from ./include/caffe/caffe.hpp:8:
In file included from ./include/caffe/blob.hpp:8:
In file included from ./include/caffe/syncedmem.hpp:9:
In file included from ./include/caffe/util/math_functions.hpp:12:
In file included from ./include/caffe/util/mkl_alternate.hpp:13:
/System/Library/Frameworks/vecLib.framework/Versions/Current/Headers/cblas.h:640:40: error: expected function body after function declarator
extern void ATLU_DestroyThreadMemory() __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2, __MAC_10_9, __IPHONE_4_0, __IPHONE_NA);
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/usr/include/Availability.h:155:53: note: expanded from macro '__OSX_AVAILABLE_BUT_DEPRECATED'
__AVAILABILITY_INTERNAL##_osxIntro##_DEP##_osxDep
^
:106:1: note: expanded from here
__AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_9
^
1 error generated.

make: *** [matlab/caffe/caffe.mexmaci64] Error 255

The MATLAB version 2014a and I'm trying to get it working on a MAC OSX 10.9. I'm already on the dev branch using the fix provided in the previous issues with MATLAB 2014a but this didn't solve it.
Does anybody has an idea how to fix this issue?

Thank you for your help!

@vimalthilak
Copy link

You are getting a warning that states that the function is deprecated on your version of OS X. If you can figure out a way to ignore the warning then you should be able to progress to the next error message :). Perhaps patch cblas.h if you are inclined to do so.

Another alternative is to use Intel MKL and forget using BLAS shipped with Xcode.

I do not know how to change options in the Makefile to ignore this warning message.

@dgolden1
Copy link
Contributor

Specifically, in the file /System/Library/Frameworks/vecLib.framework/Versions/Current/Headers/cblas.h, I changed line 640 from

extern void ATLU_DestroyThreadMemory() __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2, __MAC_10_9, __IPHONE_4_0, __IPHONE_NA);

to

extern void ATLU_DestroyThreadMemory();// __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2, __MAC_10_9, __IPHONE_4_0, __IPHONE_NA);

Note that the function definition has been commented out.

This was actually @vimalthilak's idea, but I'm making it more explicit.

@damro
Copy link
Author

damro commented Aug 14, 2014

Thanks! This did the trick!

But now I get the following error while linking:

Building with 'Xcode Clang++'.
ld: warning: directory not found for option '-L/usr/local/cuda/lib64'
Undefined symbols for architecture x86_64:
"_mxArrayToString", referenced from:
init(int, mxArray_tag**, int, mxArray_tag const**) in matcaffe.o
_mexFunction in matcaffe.o
"_mxCreateCellArray_700", referenced from:
get_weights(int, mxArray_tag**, int, mxArray_tag const**) in matcaffe.o
"_mxCreateCellMatrix_700", referenced from:
forward(int, mxArray_tag**, int, mxArray_tag const**) in matcaffe.o
backward(int, mxArray_tag**, int, mxArray_tag const**) in matcaffe.o
"_mxCreateDoubleScalar", referenced from:
init(int, mxArray_tag**, int, mxArray_tag const**) in matcaffe.o
is_initialized(int, mxArray_tag**, int, mxArray_tag const**) in matcaffe.o
get_init_key(int, mxArray_tag**, int, mxArray_tag const**) in matcaffe.o
"_mxCreateNumericArray_700", referenced from:
forward(int, mxArray_tag**, int, mxArray_tag const**) in matcaffe.o
backward(int, mxArray_tag**, int, mxArray_tag const**) in matcaffe.o
get_weights(int, mxArray_tag**, int, mxArray_tag const**) in matcaffe.o
"_mxCreateString", referenced from:
get_weights(int, mxArray_tag**, int, mxArray_tag const**) in matcaffe.o
"_mxCreateStructArray_700", referenced from:
get_weights(int, mxArray_tag**, int, mxArray_tag const**) in matcaffe.o
"_mxFree", referenced from:
init(int, mxArray_tag**, int, mxArray_tag const**) in matcaffe.o
_mexFunction in matcaffe.o
"_mxGetCell_700", referenced from:
forward(int, mxArray_tag**, int, mxArray_tag const**) in matcaffe.o
backward(int, mxArray_tag**, int, mxArray_tag const**) in matcaffe.o
"_mxGetDimensions_700", referenced from:
forward(int, mxArray_tag**, int, mxArray_tag const**) in matcaffe.o
backward(int, mxArray_tag**, int, mxArray_tag const**) in matcaffe.o
"_mxGetPr", referenced from:
forward(int, mxArray_tag**, int, mxArray_tag const**) in matcaffe.o
backward(int, mxArray_tag**, int, mxArray_tag const**) in matcaffe.o
get_weights(int, mxArray_tag**, int, mxArray_tag const**) in matcaffe.o
"_mxGetScalar", referenced from:
set_device(int, mxArray_tag**, int, mxArray_tag const**) in matcaffe.o
"_mxSetCell_700", referenced from:
forward(int, mxArray_tag**, int, mxArray_tag const**) in matcaffe.o
backward(int, mxArray_tag**, int, mxArray_tag const**) in matcaffe.o
get_weights(int, mxArray_tag**, int, mxArray_tag const**) in matcaffe.o
"_mxSetField_700", referenced from:
get_weights(int, mxArray_tag**, int, mxArray_tag const**) in matcaffe.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Looks like something's wrong with mex.
Do I link against the wrong library or what's the problem here?

@vimalthilak
Copy link

You are missing a path to matlab's Mex binaries. Libmx.dylib and limb ex.dylib . You can add the path in Makefile.config to see if you can progress forward.

@damro
Copy link
Author

damro commented Aug 14, 2014

I had to do this to get mex working:

http://www.mathworks.com/matlabcentral/answers/103904-can-i-use-xcode-5-as-my-c-or-c-compiler-in-matlab-8-1-r2013a-or-matlab-8-2-r2013b

Thanks for the help! Everything compiled successfully now! What a great community!

@damro damro closed this as completed Aug 14, 2014
@dgolden1
Copy link
Contributor

@damro, regarding your errors like Undefined symbols for architecture x86_64: "_mxArrayToString", referenced from..., my solution was to change the LIBRARY_DIRS section of Makefile.config to read:

LIBRARY_DIRS := $(PYTHON_LIB) /Applications/MATLAB_R2014a.app/bin/maci64 /usr/local/lib /usr/lib

You can replace MATLAB_R2014a.app with whatever Matlab version you're running. Again, @vimalthilak gets credit for this hack. But it sounds like you got everything working via a different method.

@damro
Copy link
Author

damro commented Aug 14, 2014

I should mention that I had to do both, setting the path and following the mathworks solution, to get it running.
Thank you both once again for your help!

@StevenLobo2
Copy link

I am getting the same issue even after updating Makefile.config to add LIBRARY_DIRS := $(PYTHON_LIB) /Applications/MATLAB_R2014a.app/bin/maci64 /usr/local/lib /usr/lib.
Is this only change or anything else need to be updated? I am getting error for make matcaffe Undefined symbols for architecture x86_64:
"_mxArrayToString", referenced from:… on 10.8.x for MATLAB 2014a.

@vimalthilak
Copy link

Did you change Matlab's mexopts.sh ? It sounds like you build is getting confused between libc++ and libstd++. Look over the mathworkx link included in one of the previous posts.

Vimal

Sent from my iPhone

On Aug 24, 2014, at 11:30 AM, StevenLobo2 notifications@github.com wrote:

I am getting the same issue even after updating Makefile.config to add LIBRARY_DIRS := $(PYTHON_LIB) /Applications/MATLAB_R2014a.app/bin/maci64 /usr/local/lib /usr/lib.
Is this only change or anything else need to be updated? I am getting error for make matcaffe Undefined symbols for architecture x86_64:
"_mxArrayToString", referenced from:… on 10.8.x for MATLAB 2014a.


Reply to this email directly or view it on GitHub.

@shelhamer
Copy link
Member

If a matcaffe user on OSX 10.9 could send a PR noting the proper mexopts.sh
configuration or otherwise make a MATLAB section on the wiki with these
details that could help a lot of users navigate the CUDA / libstdc++ issue.

On Sun, Aug 24, 2014 at 11:51 AM, Vimal Thilak notifications@github.com
wrote:

Did you change Matlab's mexopts.sh ? It sounds like you build is getting
confused between libc++ and libstd++. Look over the mathworkx link included
in one of the previous posts.

Vimal

Sent from my iPhone

On Aug 24, 2014, at 11:30 AM, StevenLobo2 notifications@github.com
wrote:

I am getting the same issue even after updating Makefile.config to add
LIBRARY_DIRS := $(PYTHON_LIB) /Applications/MATLAB_R2014a.app/bin/maci64
/usr/local/lib /usr/lib.
Is this only change or anything else need to be updated? I am getting
error for make matcaffe Undefined symbols for architecture x86_64:
"_mxArrayToString", referenced from:… on 10.8.x for MATLAB 2014a.


Reply to this email directly or view it on GitHub.


Reply to this email directly or view it on GitHub
#915 (comment).

@StevenLobo2
Copy link

Yes! I had changed the mexopts.sh to include 10.8 wherever 10.7 was there ( 4 places). But then too I am getting the same issue.

@Akrit2013
Copy link

@StevenLobo2 Same thing happen to me!
Sys ver 10.9.4 and MATLAB2014a
It bother me too days....

@Akrit2013
Copy link

@StevenLobo2 Problem solved...
You should copy /Applications/MATLAB2014a/bin/mexopts.sh to ~/.matlab/R2014a/mexopts.sh first before you change anything.
Because mex -setup won't do anything if ~/.matlab/R2014a/mexopts.sh didn't exist and the mex will ignore the setting in /Applications/MATLAB2014a/bin/mexopts.sh

BTW: on maverick, use 10.8sdk instead of 10.9sdk it will work.

@reking
Copy link

reking commented Nov 7, 2014

Here I got a problem like:
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

mex: link of ' "matlab/caffe/caffe.mexmaci64"' failed.

After modify the mexopts.h, add maci64 path in Makefile.config and veclib *.h file as told before. So how
could it be worked out?
Thanks very much for your help
@drdan14 @vimalthilak

@dgolden1
Copy link
Contributor

dgolden1 commented Nov 7, 2014

@reking Can you post the full make output as a gist?

@reking
Copy link

reking commented Nov 7, 2014

Thanks @drdan14 for reply, output is too long, here is part of it, https://gist.github.com/reking/7ff32dcce1f516dec379

@dgolden1
Copy link
Contributor

dgolden1 commented Nov 7, 2014

@reking, I see boost errors, which I vaguely recall getting myself. If I recall, Caffe was seeing Matlab's internal libraries earlier in the library path than my local homebrew libraries in /usr/local/lib. Caffe might be trying to link Matlab's version of the boost library, which, needless to say, isn't compatible with Caffe.

Try changing the LIBRARY_DIRS := ... line in your Makefile.config so that the /usr/local/lib directory is before your Matlab library directory.

Mine looks like this:

LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib $(MATLAB_DIR)/bin/maci64 /usr/lib

@reking
Copy link

reking commented Nov 7, 2014

Thank you very much for reply, the boost error is solved, however, the ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

mex: link of ' "matlab/caffe/caffe.mexmaci64"' failed.

still happens, I was viewing your post, my pkgutil -...... shows version 5.1, does it matter for compilation?
Thanks~

@reking
Copy link

reking commented Nov 7, 2014

The new error is like https://gist.github.com/reking/7ff32dcce1f516dec379
I tried your method of adding /usr/lib/libstdc++.dylib
@drdan14

@dgolden1
Copy link
Contributor

dgolden1 commented Nov 7, 2014

@reking
Two things:

  • Make sure you've replaced all instances of -lc++ with -lstdc++ in mexopts.sh
  • I have had success with Matlab 2014a but not Matlab 2014b; try 2014a if you have access to both

@reking
Copy link

reking commented Nov 7, 2014

@drdan14 Thank you for reply, maybe I haven't re make all after change the veclib to accelerate?

@dgolden1
Copy link
Contributor

dgolden1 commented Nov 7, 2014

Yep, make clean && make matcaffe

@reking
Copy link

reking commented Nov 7, 2014

new error: https://gist.github.com/reking/7ff32dcce1f516dec379
Protobuf version is 2.6.0 and build with libstdc++, oh......

@drdan14 Please take a look, thank you

@dgolden1
Copy link
Contributor

dgolden1 commented Nov 7, 2014

@reking, I'm not sure about that one. Try posting to the Google Group to see if anyone there has an idea.

@vimalthilak
Copy link

@reking can you run locate libprotobuf from command line? Are you sure that there are no other conflicting versions that link to libc++ somewhere in your path?

@reking
Copy link

reking commented Nov 7, 2014

@vimalthilak thanks for reply, I find some libprotobuf in /usr/local/lib
I could make all and run all tests successfully, but could not compile matcaffe correctly
After I move all the libprotobuf* to another dir, it still happens the same error

@reking
Copy link

reking commented Nov 7, 2014

@vimalthilak Here is the locations of all libprotobuf
/usr/local/Cellar/protobuf/2.6.0/lib/libprotobuf-lite.9.dylib
/usr/local/Cellar/protobuf/2.6.0/lib/libprotobuf-lite.a
/usr/local/Cellar/protobuf/2.6.0/lib/libprotobuf-lite.dylib
/usr/local/Cellar/protobuf/2.6.0/lib/libprotobuf.9.dylib
/usr/local/Cellar/protobuf/2.6.0/lib/libprotobuf.a
/usr/local/Cellar/protobuf/2.6.0/lib/libprotobuf.dylib
/usr/local/protobuf/libprotobuf-lite.9.dylib
/usr/local/protobuf/libprotobuf-lite.a
/usr/local/protobuf/libprotobuf-lite.dylib
/usr/local/protobuf/libprotobuf.9.dylib
/usr/local/protobuf/libprotobuf.a
/usr/local/protobuf/libprotobuf.dylib

@vimalthilak
Copy link

@reking Here is what I found on my system

>> locate libprotobuf
/Applications/MATLAB_R2014b.app/bin/maci64/libprotobuf.8.dylib
/Applications/MATLAB_R2014b.app/bin/maci64/libprotobuf.dylib
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/PrivateFrameworks/WirelessDiagnostics.framework/Versions/A/Libraries/libprotobuf.dylib
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/lib/libprotobuf.dylib
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/lib/libprotobuf.dylib
/usr/local/Cellar/protobuf/2.5.0/lib/libprotobuf-lite.8.dylib
/usr/local/Cellar/protobuf/2.5.0/lib/libprotobuf-lite.a
/usr/local/Cellar/protobuf/2.5.0/lib/libprotobuf-lite.dylib
/usr/local/Cellar/protobuf/2.5.0/lib/libprotobuf.8.dylib
/usr/local/Cellar/protobuf/2.5.0/lib/libprotobuf.a
/usr/local/Cellar/protobuf/2.5.0/lib/libprotobuf.dylib
/usr/local/lib/libprotobuf-lite.8.dylib
/usr/local/lib/libprotobuf-lite.a
/usr/local/lib/libprotobuf-lite.dylib
/usr/local/lib/libprotobuf.8.dylib
/usr/local/lib/libprotobuf.a
/usr/local/lib/libprotobuf.dylib

As you can see I have a few different versions floating around including one in Xcode that links to libc++. So please ensure that your env variables doesn't have any references to an incorrect version

@reking
Copy link

reking commented Nov 7, 2014

@vimalthilak Thank you very much, it's ok now, just follow your advice, cp libprotobuf.9.* to matlab.app/bin/maci64, thanks! Thanks @drdan14 again for your both kind help!

@AlamiMejjati
Copy link

Hi there i'm having a problem when trying to tape: make matcaffe on a shell.
i'm getting this error message:
MEX matlab/+caffe/private/caffe_.cpp
Building with 'Xcode Clang++'.
In file included from /Users/MBP/caffe/matlab/+caffe/private/caffe_.cpp:18:
In file included from ./include/caffe/caffe.hpp:7:
In file included from ./include/caffe/blob.hpp:10:
In file included from ./include/caffe/syncedmem.hpp:7:
In file included from ./include/caffe/util/math_functions.hpp:11:
In file included from ./include/caffe/util/mkl_alternate.hpp:11:
/System/Library/Frameworks/Accelerate.framework/Versions/Current/Frameworks/vecLib.framework/Headers/cblas.h:760:26: error: expected function body after function declarator
const int __ldc) __OSX_AVAILABLE_STARTING(__MAC_10_10,__IPHONE_8_0);
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/Availability.h:159:50: note: expanded from macro '__OSX_AVAILABLE_STARTING'
#define __OSX_AVAILABLE_STARTING(_osx, _ios) __AVAILABILITY_INTERNAL##_osx
^
:6:1: note: expanded from here
_AVAILABILITY_INTERNAL__MAC_10_10
^
In file included from /Users/MBP/caffe/matlab/+caffe/private/caffe
.cpp:18:
In file included from ./include/caffe/caffe.hpp:7:
In file included from ./include/caffe/blob.hpp:10:
In file included from ./include/caffe/syncedmem.hpp:7:
In file included from ./include/caffe/util/math_functions.hpp:11:
In file included from ./include/caffe/util/mkl_alternate.hpp:11:
/System/Library/Frameworks/Accelerate.framework/Versions/Current/Frameworks/vecLib.framework/Headers/cblas.h:767:26: error: expected function body after function declarator
const int __ldc) __OSX_AVAILABLE_STARTING(__MAC_10_10,__IPHONE_8_0);
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/Availability.h:159:50: note: expanded from macro '__OSX_AVAILABLE_STARTING'
#define __OSX_AVAILABLE_STARTING(_osx, _ios) __AVAILABILITY_INTERNAL##_osx
^
:6:1: note: expanded from here
__AVAILABILITY_INTERNAL__MAC_10_10
^
2 errors generated.

make: *** [matlab/+caffe/private/caffe_.mexmaci64] Error 255

i tried to change the blas.h file like @drdan14 said but i only have the lecture rights.
@vimalthilak @damro @drdan14 @shelhamer you guys have some ideas to help me ?

@NRmf
Copy link

NRmf commented Sep 2, 2015

@AlamiMejjati I am having the same error (using OS X Yosemite 10.10, Matlab_R2015a)
Did you manage to fix it?

@alihassan1
Copy link

@NRmf I'm have the exact same issue with similar configuration (OSX Yosemite 10.11, Matlab_R2015b).
were you able to fix it?

@AlamiMejjati
Copy link

Sorry guys, my solution was to move on ubuntu. It is way easier to install. Goog luck ;)

@yi-ji
Copy link

yi-ji commented Feb 23, 2016

same error, many symbol(s) not found for architecture x86_64

one is cv::String::(de)allocate, others are google::protobuf::xxxxxx......

Every possible solution mentioned above have been tried but still.....

DESPERATE, please help if you have any idea...

@yi-ji
Copy link

yi-ji commented Feb 24, 2016

Problems solved thanks to https://groups.google.com/forum/#!topic/caffe-users/BZgh3mtaR2o

Just remember to make clean & make all before make matcaffe.

Anyway homebrew helps a lot in version control.

@emojiface-ops
Copy link

emojiface-ops commented Jul 19, 2017

Being driven mad by the "Undefined symbols for architecture x86_64: _mxArrayToString" issue. Have read this thread half a dozen times and still can't seem to fix it. I'm using Matlab 2017a on OS X Sierra 10.12.5, Xcode 8.3.3.

I've tried:

  • Replacing existing LIBRARY_DIRS with "LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib $(MATLAB_DIR)/bin/maci64 /usr/lib"; also tried moving "maci64" before "/usr/local/lib"
  • Search/replace in mexopts.sh "10.8" with "10.12"
  • Search/replace in mexopts.sh "-lc++" with "-lstdc++"
  • Running "mex -setup" in Matlab
  • "Make clean" then "Make matcaffe"

Still getting the error. Help! :)

UPDATE: Realized I should mention I'm getting these warnings, maybe part of the problem?
ld: warning: object file (.build_release/lib/libcaffe.a(upgrade_proto.o)) was built for newer OSX version (10.12) than being linked (10.9)

@yizhichun
Copy link

@emojiface-ops
I have encountered the same problem, i need help

@LiangChaoPossible
Copy link

@emojiface-ops
I've tried as same as you did , but still find the

Undefined symbols for architecture x86_64:
"mxArrayToString", referenced from:
get_solver(int, mxArray_tag**, int, mxArray_tag const**) in caffe
.o
solver_restore(int, mxArray_tag**, int, mxArray_tag const**) in caffe_.o
get_net(int, mxArray_tag**, int, mxArray_tag const**) in caffe_.o
net_copy_from(int, mxArray_tag**, int, mxArray_tag const**) in caffe_.o
net_save(int, mxArray_tag**, int, mxArray_tag const**) in caffe_.o
read_mean(int, mxArray_tag**, int, mxArray_tag const**) in caffe_.o
write_mean(int, mxArray_tag**, int, mxArray_tag const**) in caffe_.o

do you fix that ?

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