Search code examples
matlabmakefileliblinear

Installing LibLinear on MATLAB R2014a


I'm trying to install LibLinear for MATLABR2014a on linux. When compiling in MATLAB the read.mexa64 and write.mexa64 are created just fine, it's on the train.mexa64 that it fails. The error I used to get was:

/home/admin/Documents/Project/Software/liblinear-1.94/linear.cpp:2739:19: 
warning: ignoring return value of ‘int fscanf(FILE*, const char*, ...)’, 
declared with attribute warn_unused_result [-Wunused-result] fscanf(fp,"\n");               ^

If make.m fails, please check README about detailed instructions.

So I sorted out the handling of the return value in linear.cpp and it still fails, providing only the last line directing me to the README. I've also tried installing gcc-4.7, g++-4.7 and cpp-4.7 but the make process still terminates without any information. As it suggests I have the matlab directory set to:

MATLABDIR = /usr/local/matlab

and I have included

-U_FORTIFY_SOURCE 

in the CFLAGS just in case it was the ignored values causing a fuss. I managed to compile it from the command line in the main directory and it works fine, but it would be awesome to have a nice MATLAB interface :) If anyone's managed to get it up and running I'd be super grateful for any help!


Solution

  • If anyone stumbles across this then I found a method that seems to work. I tried using the Makefile in the matlab folder directly but kept strange getting compiler errors asking to change the source directory. However, if you go into the Makefile and change the line

    MEX_OPTION = CC\#$(CXX) CXX\#$(CXX) CFLAGS\#"$(CFLAGS)" CXXFLAGS\#"$(CFLAGS)"
    

    to

    MEX_OPTION = CC=$(CXX) CXX=$(CXX) CFLAGS="$(CFLAGS)" CXXFLAGS="$(CFLAGS)"
    

    it should work.