Compiling .cpp file into Matlab MEX file - matlab

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?

Related

Compilation matconvnet - vl_compilenn

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) ;

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.

make error: invalid command line option

I'm trying to make http://iridia.ulb.ac.be/~manuel/hypervolume (version 2.0) on windows using the instructions they've given in their README which is to install MINGW and run "make mex", however I keep getting this error:
$ make mex
mex -D VARIANT=4 Hypervolume_MEX.c hv.c
mex.exe: Invalid command-line option
mex.exe: Data: unknown option
make: *** [mex] Error 1
instructions given:
Guillaume Jacquenot contributed a MEX interface for MATLAB
(Hypervolume_MEX.c). Use make mex to compile it.
Any help would be appreciated thank you
Within matlab change directories to the location of the hypervolume code, then run
mex -DVARIANT=4 Hypervolume_MEX.c hv.c avl.c
at the matlab command prompt. If your c compiler is set up correctly within matlab this should generate an executable named Hypervolume_MEX.xxx (dll in my case).
edit
I used the matlab compiler (Lcc C 2.4) on Matlab 7. No luck with Visual Studio 6 or Watcom 10.6 compilers (although I did not attempt to debug).

fatal error: 'gtk/gtk.h' file not found

So I'm trying to install Gtk-Perl-0.7000 from http://search.cpan.org/dist/Gtk-Perl/ on a mac
I already successfully followed the steps to instal gtk+ at http://www.gtk.org/
when I run the Makefile.pl from Gtk-Perl-0.7000 it gives me:
gtkvertmp.c:3:10: fatal error: 'gtk/gtk.h' file not found
#include <gtk/gtk.h>
^
1 error generated.
Unable to find Gtk version...
Invoking gendefs.pl with [].
Please wait, this may take a moment...
gtktypexp.c:1:10: fatal error: 'gtk/gtktypeutils.h' file not found
#include <gtk/gtktypeutils.h>
^
1 error generated.
I have:
echo $PKG_CONFIG_PATH
:/Users/one/gtk/source/gtk+-2.24.16/gtk:/Users/one/gtk/inst/include/gtk-2.0/gtk:/Users/one/gtk/inst/lib/pkgconfig
I do have the gtk.h file in my system. I've searched online but haven't gotten Gtk-Perl to compile.
Your Mac OS need libgtk to be installed to run the script properly.

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.