mex compiler could not find include path in .h files - matlab

Hi I'm using MEX in Matlab.
The c code uses boost and a lot of headers are included.
And at first my problem is like this
>>mex readTrackletsMex.cpp
readTrackletsMex.cpp
e:\kitti\tools\devkit\matlab\tracklets.h(7) : fatal error C1083: can not open include file:“boost/serialization/nvp.hpp”: No such file or directory
This is because the include path is not specified. So I copied the headers into "/include/boost/XX" and added "-I" flag.
This time it seems that the compiler cannot find the include path in one of the header file.
>> mex -Iinclude readTrackletsMex.cpp
readTrackletsMex.cpp
include\boost/serialization/nvp.hpp(21) : fatal error C1083: can not open include file:“boost/config.hpp”: No such file or directory
Any idea on this? How do I specify a "global" include path for the compiler?
Thanks for your time.

You could try adding the include paths to the environment variables C_INCLUDE_PATH and CPLUS_INCLUDE_PATH. The other issue may be that you put in -Iinclude, and not -I/include

Related

Can not build a mex file in octave using mkoctfile --mex

I am trying to build a mex file in octave. The Octave instructions says that we need to use mkoctfile --mex to build one. The file I am trying to build is in the following path:
> C:\devwork\Octave\boosted\toolbox\channels\private\rgbConvert.cpp
When I write
> mkoctfile --mex rgbConvert.cpp
I get the following error:
> g++: error: rgbConvert.cpp: No such file or directory g++: fatal
> error: no input files compilation terminated.
Note: My current directory is set correct. It is at \devwork\Octave\boosted\toolbox\channels\private
Can some one explain me why am I getting this error.
The problem is resolved using: mkoctfile --mex -DMATLAB_MEX_FILE rgbConvertMex.cpp
Hence, if you want to convert any Matlab compiled .mex file to Octave executable file, do the following two steps:
Modify wrappers.hpp file by adding #include <stdlib.h>
Save the file.
Simply run: mkoctfile --mex -DMATLAB_MEX_FILE file_name
.o file will be created.
I did it using the same and it worked fine.
Eskapp was grateful enough to release the Octave compiled MEX files. You'll need to manually add the files to the main toolbox.Please find the link here:
https://github.com/Eskapp/Piotr_vision_extrafiles_Octave
Hope it helps others :)

Cannot compile mex file on Windows

When I attempt to compile a .mex file on Windows, I get the following error. How can I fix this?
Error using mex
MEX cannot find library 'mwblas' specified with the -l option.
MEX looks for a file with one of the names:
libmwblas.lib
mwblas.lib
Please specify the path to this library with the -L option
As the error message states, you need to specify the directory in which the .lib file is located using the -L option or specify the full path to the .lib file as an input to mex. This library is located in matlabroot/extern/lib. So you could do something like
blas = fullfile(matlabroot,'extern','lib',computer('arch'),'microsoft', 'libmwblas.lib');
mex('-largeArrayDims', 'mymexfile.cpp', blas)
Or you can specify the folder with -L
libdir = fullfile(matlabroot,'extern','lib',computer('arch'),'microsoft');
mex('-largeArrayDims', ['-L', libdir], '-lmwblas', 'mymexfile.cpp', )
More info about compiling mex files to use LAPACK and BLAS is here

fatal error: QScriptEngine: No such file or directory

I am working on blackberry project when i include
#include <QScriptEngine>
in my .cpp file it gives be error
fatal error: QScriptEngine: No such file or directory
can any one tell what should i include in .pro file so that i can get rid of this error .
Try replacing it with
#include <QtScript/QScriptEngine>
The qt4 include dir should be on your include path by default as long as you have CONFIG += qt somewhere in your pro file. So my guess is you just need to qualify where QScriptEngine is beneath the qt4 dir (which is inside QtScript dir).

SUN benchmark code Invalid .mex file error

I've downloadad the SUN benchmark code from MIT:
version 2:
http://people.csail.mit.edu/jxiao/SUN/source_code/
Once I download the 15 image dataset and run the function:
compute_features.m
I get an Invalid MEX file error:
Invalid MEX-file
'/home/arturo/Documents/Virality/reddit_data/SUN_source_code_v2/code/OpenCVmexWrapper/cvlib_mex.mexa64':
libcv.so.1: cannot open shared object file: No such file or directory
The file /home/arturo/Documents/Virality/reddit_data/SUN_source_code_v2/code/OpenCVmexWrapper/cvlib_mex.mexa64 actually does exist, so I'm thinking the problem hast to do with libcv.so.1, or the .mexa64 file is broken (which is very unlikely)
I read something about adding a path via LD_LIBRARY_PATH when I googled the error, but I'm not sure what path I should exactly add, at least temporarily. I have opencv installed along with its library, so I'm not sure what the problem is. My current system is Ubuntu 12.04 64bit.
There's a similar question here, but the answer says that for their specific case they have the source code of the MEX files posted, which is not the same fortune I have: running old mex file on new matlab releases
Found the answer. The key is to link explicitly to the folder the file 'libcv.so.1' is in just before running matlab.
so in the matlab folder:
LD_LIBRARY_PATH=/home/arturDocuments/Virality/reddit_data/SUN_source_code_v2/code/scene_sun ./matlab
And in matlab:
matlab>> compute_feature
Compling the source code in the other folders is also necessary.(vlfeat,VOC,libsvm). As well as editing the path in the function im2superpixels # GeometricContext_dhoiem from :
segcmd = '../segment_pedro/segment 0.8 100 100';
to:
segcmd = '/YOUR_PATH/SUN_source_code_v2/code/segment_pedro/segment/ 0.8 100 100';
*(The folder is one level above.)

matlab to c++: Cannot open include file: 'mclmcrrt.h': No such file or directory

We tried to complie the m file to c++ file by matlab complier. We had the file bulit but we got the error msg as follow.
fatal error C1083: Cannot open include file: 'mclmcrrt.h': No such file or directory
Do you have any ideas about the error msg? Any suggestion will be appreciated. Thanks a lot.
Ying
This error message is caused because you need MCR dlls.
You should locate the h file in "C:\Program Files (x86)\MATLAB\MATLAB Compiler Runtime\v715\extern\include\"
and add it to your include path in C.
Check out the manual of Matlab compiler.