Compilation matconvnet - vl_compilenn - matlab

I am using 64bit MATLAB trial R2015b in Linux mint. I am trying to compile the CPU version of the library. When I try to configure compiler for mex using command
mex -v GCC='/usr/bin/gcc-4.7' timestwo.c
It shows me an error
In file included from /usr/local/MATLAB/R2015b/extern/include/mex.h:51:0,
from /home/tt/Desktop/practice/timestwo.c:1:
/usr/local/MATLAB/R2015b/extern/include/matrix.h:23:20: fatal error:
stdlib.h: No such file or directory
compilation terminated.
As it is not compiled. So,
cd /home/tt/Desktop/practice/matconvnet-1.0-beta14/matlab/
vl_compilenn
Error using mex
No supported compiler or SDK was found.
Error in vl_compilenn>mex_compile (line 438)
mex(mopts{:}) ;
Error in vl_compilenn (line 400)
mex_compile(opts, srcs{i}, toobj(bld_dir,srcs{i}), flags.mexcc) ;

Related

Running Simulink produces make error

Opening a file in simulink and running it produces the following make error:
Making simulation target "ekf_trial_sfun", ...
/Applications/MATLAB_R2013a_Student.app/bin/mex -c -O -DMATLAB_MEX_FILE -I/Applications/MATLAB_R2013a_Student.app/stateflow/c/mex/include -I/Applications/MATLAB_R2013a_Student.app/stateflow/c/debugger/include ekf_trial_sfun.c
xcodebuild: error: SDK "macosx10.7" cannot be located.
xcrun: error: unable to find utility "clang", not a developer tool or in PATH
mex: compile of ' "ekf_trial_sfun.c"' failed.
gmake: *** [ekf_trial_sfun.o] Error 1
I have clang on my computer. Do I need to open up the mex .sh file and rename all the old operating system refences (10.6) to 10.10.4? I tried doing a find and replace and that didn't work.
The file was given to me by another engineer
I also get the warning: Some of the issues encountered during model compilation may be because this model was created in a previous release.

use library (gcc) in matlab and error with compile of mex

I am using Mac OSX (yosemite V 10.10.1) and running MATLAB 2014a on it.
I wanted to use SPAM library (sparse modeling software by J. Mairal) on MATLAB and for that I have to install XCode6.1 (that has gcc). First I type in command window mex -setup and result is shown below:
mex -setup
MEX configured to use 'Xcode with Clang' for C language compilation.
Warning: The MATLAB C and Fortran API has changed to support MATLAB
variables with more than 2^32-1 elements. In the near future
you will be required to update your code to utilize the
new API. You can find more information about this at:
http://www.mathworks.com/help/matlab/matlab_external/upgrading-mex-files-to-use-64-bit-api.html.
To choose a different language, select one from the following:
mex -setup C++
mex -setup FORTRAN
So after that I run the compile.m file in SPAM library and suddenly I saw an error that was:
add_flag =
-mmacosx-version-min=10.6
Warning: Directory already exists.
> In compile at 144
compilation of: -I./linalg/ -I./decomp/ -I./prox/ -I./dictLearn/ dictLearn/mex/mexArchetypalAnalysis.cpp
Building with 'Xcode Clang++'.
clang: warning: argument unused during compilation: '-fopenmp'
Error using mex
ld: warning: directory not found for option '-L/usr/lib/gcc/x86_64-linux-gnu/4.8/'
ld: library not found for -lgomp
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Error in compile (line 439)
mex(args{:});
I don't understand what to do. please help me!
It appears that the actual error is occurring at the point of linking with precompiled libraries. The 2 issues are as follows:
The compile code apparently included in the compile.m file looks like it is intended to compile with gcc (it is trying to include files installed by GCC, possibly even linux-specific ones, are you sure that it's an OSX-compatible toolbox?), and yet the error strongly suggests that you are in fact using clang to compile it - you will either need to change the compiler (easy) or rewrite compile.m (not so easy).
One of the libraries that the code needs to have installed in order to be properly linked hasn't been found. On OSX I think this file should be called libgomp.dylib (any mac afficionados want to confirm this?). If you have it on your computer, then it's not in a directory that clang is looking in. You can confirm the library is installed by running find / | grep libgomp.dylib from the terminal - if it is there, you can add it into the compiler argument in compile.m using the -I /DIRECTORY_HOLDING_LIBRARY syntax.
It is entirely possible that fixing 1. will also remediate 2. - I have never tried using SPAM

installing libsvm on Mac (OSX 10.9.2)

I have tried to install the libsvm package with
mex -setup
(since "make" resulted in an error). This was followed by one choice for a compiler, so I chose "1".
Afterwards I typed in "make" got the following error though:
xcrun: error: SDK "macosx10.7" cannot be located
clang: warning: no such sysroot directory: '-mmacosx-version-min=10.7'
libsvmread.c:1:10: fatal error: 'stdio.h' file not found
#include <stdio.h>
^
1 error generated.
mex: compile of ' "libsvmread.c"' failed.
If make.m fails, please check README about detailed instructions.
What can I do?
I think the following answer from the matlab support might be helpful (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):
The Mac OS X 10.7 SDK, available in Xcode 4.1 through 4.6, is used by
MEX and related capabilities. This SDK is no longer available in Xcode
5, resulting in errors similar to the following when compiling:
xcodebuild: error: SDK "macosx10.7" cannot be located.
xcrun: error: unable to find utility "clang", not a developer tool or
in PATH
The simplest solution is to avoid updating Xcode to version 5 if you
are using R2013a or R2013b. If you need Xcode 5, or you have already
irreversibly upgraded to it, you can update MEX to use the 10.8 SDK:
In the MATLAB Command Window, execute the following commands:
cd(matlabroot)
cd bin
edit mexopts.sh
Save a backup copy of this file somewhere in case you make a mistake and you need to revert your changes.
Scroll down to the Mac (“maci64”) section of this file, beginning around line 120.
Replace all instances of 10.7 with 10.8; there are four of these in all (a fifth may be found in comments only)
Save the file, then execute the following command in the MATLAB Command Window:
mex -setup
Please note that this workaround links MEX files with a different SDK
than with which MATLAB was tested. Although there are no known
compatibility issues, support may be limited.

Compiling .cpp file into Matlab MEX file

I'm trying to compile a C++ function to use it with Matlab (2013a)? I'm using Mac OS 10.9. When I run the below command from the Matlab command line:
mex SEA.cpp
the following error appears:
SEA.cpp:6:10: fatal error: 'windows.h' file not found
#include <windows.h>
What am I missing?

matlab R2011a unable to compile mex files

I have Xcode(4.4.1) installed on my mac, and use MATLAB r2011a (64 bit) on the computer. I have ben trying to compile mex files, but I get the following error:
/Applications/MATLAB_R2011a.app/bin/mex: line 305: gcc-4.2: command not found
/Applications/MATLAB_R2011a.app/bin/mex: line 1041: gcc-4.2: command not found
mex: compile of ' "mdwt.c"' failed.
??? Error using ==> mex at 208
Unable to complete successfully.
Error in ==> compile at 39
mex mdwt.c mdwt_r.c
When I type in "gcc" at the command prompt (terminal) , I see that it has been installed.
Can anyone tell me how to fix this?
You might have to run mex -setup first to tell matlab which compiler is available.
Please check this link:
How to use/install gcc on Mac OS X 10.8 / Xcode 4.4
For xcode 4.4, I guess you need to install gcc manually by yourself.