0

I'm trying to write a program in C++ to write static arrays and matrices to .mat files so that I can load them into Matlab, and I'd also like to be able to read them. I've done a lot of reading and I'm aware that there's some framework I need to properly set up in XCode in order for things to work. I'm using Matlab R2015b and Xcode 7.3.

I'm modeling my code initially to be simple like what the author mentions in Reading data from matlab files into C but I can't locate my libraries. The folder /glnxa64/ does not exist on my machine. I know that my headers I want to include are in applications/MatlabR2015/extern/include for mat.h, matrix.h.

I have two problems: Under my project settings in XCode, what do I modify to make sure my project finds mat.h and matrix.h, is it under the "Precompiled Headers Cache Path" or elsewhere? Also, where do I find those library files and how do I link them in XCode, is it just under the Project Build Phase link binary with libraries?

Thanks for the help!

Community
  • 1
  • 1
  • 1
    In Xcode select your target and in tab _Build Settings_ fill in the _Header Search Paths_ with a proper path to matlab's headers. To link a library you can either use _Link Binary With Libraries_ from _Build Phases_ or you can set _Library Search Paths_ and _Other Linker Flags_ in the _Build Settings_ – Teivaz Apr 20 '16 at 06:48
  • Thank you! I was changing project build settings when I needed to be changing target build settings. – Graham Harper Apr 20 '16 at 17:32
  • Ok, if this resolves your issue then I'll post it as an answer an we'll make it resolved – Teivaz Apr 20 '16 at 17:35

1 Answers1

0

I found the solution to the second part of my question. The first part was just me messing with the project build settings instead of the target build settings.

The folder for the libraries that Matlab has depends on what operating system and version of Matlab you're on. Opening matlabR2015b.app by making the finder show package contents, then navigating to applications/MatlabR2015b.app/bin/maci64/ is where the library binaries are located on my machine. The name maci64 changes depending on the OS (since I'm on a mac 64-bit OS, I believe that's where my path name came from) and manually paging through the list of libraries found it, since using the file search doesn't really work inside a package.

My code still won't compile because it looks like I need to include all of the right codependent libraries, and I don't know which other ones I need (I only included libmex.dylib and libmat.dylib), but I found where the libraries are stored.