Skip to content

Compilation on OSX does not work #5

@susnak

Description

@susnak

The following has been reported:

  1. I noticed that ltfatmex.m make an extensive use of system calls. The command 'mex' is not available in OSX terminal. Indeed when installing MATLAB, all MATLAB binaries are not automatically added to the terminal search path (probably there is some good reason).

This was the source of my first issue. Indeed at line 124 of ltfatmex.m the script check of the system command 'mex -help', which in my case was failing.

WORKAROUND. instead of permanently adding the MATLAB binary to the search path, I did it only for the instance of MATLAB I've used to compile the library:

Open a TERMINAL enter the command 'export PATH=$PATH:/Applications/MATLAB_R2017b.app/bin/' (it can be different depending on matlab version) then launch MATLAB from the terminal typing 'matlab' (and do not close the terminal until done with MATLAB).

Path to the mex parent directory is added to PATH by default on both Windows and Linux.
Consider using $(CC) instead.

  1. The file 'uchar.h' included at line 6 of mex_helper.h is missing. This file does not exist on OSX (seems a common issue, just Google it), it should exist on Linux.

WORKAROUND: replace #include <uchar.h> with the following
#include <stddef.h>
#include <stdint.h>
typedef uint16_t char16_t;
typedef uint32_t char32_t;

I don't even remember why it is there.

  1. The file 'fftw3.h' is missing. On the machine I'm using, I never installed the library FFTW3, but even if I did, I believe that the installation path wont be found by the ltfatmex.m. Indeed on OSX there are at least 3 or 4 common path to install libraries (it depends on what you use to install these), while on Linux the search paths for include file and libraries are more standard.
    Indeed in the ltfat library, the file 'fftw3.h' is provided in ltfat/libltfat/modules/libltfat/include/ltfat/thirdparty

WORKAROUND: I've copied 'fftw3.h' from ltfat into one of the header file search path for lphaseret ( libphaseret/include/ )

That will be easy to fix.

  1. the linker cant find libfftw3. The script ltfatmex.m is very smart with respect to this. Indeed during compilation I've got the following message:

    ========= Compiling MEX interfaces ========
    ...using libmwfftw3.3.dylib from Matlab installation.
    ...using libmwfftw3f.3.dylib from Matlab installation.

The script recognizes that the library can not be found on the default search path, and so it works with the equivalent library inclided in the matlab installation (dynamically changing the linker options).

WORKAROUND: here there are two options. Install libffw3 on OSX, or use MATLAB one (I went for the second).

Mind that building fftw3 on OSX can be a nightmare (much easier on Linux). Compiled binaries can be found here http://www.finkproject.org/pdb/package.php/fftw3?rel_id=10.13-x86_64-current-bindist

MATLAB fftw3 (the one working on double) is in in the following path and it has a slightly different name '/Applications/MATLAB_R2017b.app/bin/maci64/libmwfftw3.3.dylib'
I had to change line 26 of paseret/mex/Makefile to the following

$(MEX) CFLAGS='$(MYCFLAGS)' $&lt; $(TARGETUP) -L/Applications/MATLAB_R2017b.app/bin/maci64 -lmwfftw3 -lm > /dev/null

This is working but is not very elegant (it's an absolute path, better to use a relative path to MATLAB main folder).

It should do the same thing as LTFAT is doing i.e. preferably link the Matlab libfftw.

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions