mex

Matlab: avoiding memory allocation in mex

帅比萌擦擦* 提交于 2019-12-07 12:08:37
问题 I'm trying to make my mex library avoid all memory allocation what so even. Until now, the mex got an input, created some matrices using mxCreate...() and returned this output. But now I'd like to modify this interface so that the mex itself would not do any allocations. What I had in mind is that the mexFunction will get as input the matrix to fill values into and return this very same matrix as an output. Is this supposed to be possible? The slight alarm that got me thinking if this is at

MATLAB crashes when unloading mex file which has used CUDA memory

北城余情 提交于 2019-12-07 09:53:33
问题 I have been trying to figure this out for quite some time. I use a MEX file in matlab (Linux 64bit) which uses CUDA. The code compiles and executes fine but when I want to unload the mex (e.g. to recompile it or when matlab exits), matlab crashes immediately without any message and with an empty dump. I was able reduce it to a minimal working example: MEX cpp File: #include <stdint.h> #include "mex.h" extern "C" void cudaTest(); void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const

Matlab 2012a Mex to work with Xcode 4.5 on Mountain Lion

六月ゝ 毕业季﹏ 提交于 2019-12-07 08:55:09
问题 I have Mountain Lion installed with Xcode 4.5 and Matlab 2012a. I installed and ran the patch supplied on the MathWorks website however I still received the following error: /Applications/MATLAB_R2012a.app/bin/mex: line 305: llvm-gcc-4.2: command not found /Applications/MATLAB_R2012a.app/bin/mex: line 1326: llvm-gcc-4.2: command not found mex: compile of ' "hello.c"' failed. Error using mex (line 206) Is there a known solution for that ? Solution: Open Xcode --> Preferences --> Downloads -->

Mex dynamic memory management issue with std::vector in linked external DLL; Segmentation error

∥☆過路亽.° 提交于 2019-12-06 18:16:25
I am trying to create a mex file that interfaces MATLAB with an external C++ library that communicates with some hardware. An imported library and precompiled DLL (.lib and .dll) are provided by the hardware vendor for my version of VC++ and I was able to implement them in C++ without any issue. However, I ran into segmentation error at run time when the code is written as a mex(compiled with the same version of VC++). After some investigation with the VC++ debugger, the likely culprit seems to be the fact that one of the external dll functions returns the data type std::vector, and probably

How to print C-preprocessor variables like __LINE__ with mexErrMsgTxt() In Matlab MEX

你离开我真会死。 提交于 2019-12-06 16:39:22
For debugging Matlab-MEX, which can be quite a hassle, it would be nice to have better assertion capabilities. Following this question about mex-assertions , it is possible to define a preprocessor makro, that throws an error to Matlab and prints a string (can mostly replace mxAssert , which unfortunately crashes Matlab2011b). #define myassert( isOK,astr ) ( (isOK) ? (void)0 : (void) mexErrMsgTxt(astr) ) It would be much nicer to print the file, line number and caller function, from where following example assertion myassert(A=B,"A not B") is raised! This answer to the initial question states

How to use CMake and Visual Studio 2010 (64 bit) to build a MATLAB R2011a (64 bit) mex file?

只谈情不闲聊 提交于 2019-12-06 15:57:15
I would like to write a CMakeLists.txt such that CMake writes a Visual Studio 2010 (64 bit) solution file to build a mex function for MATLAB R2011a (64 bit) from C++ code example.cxx . I do not want to use MATLAB's compiler wrapper mex but set up the Visual Studio solution file such that Visual C++ links the relevant MATLAB libraries. example.cxx has no dependencies except for the MATLAB libraries that are necessary for mex files. CMake 2.8.7 is set up correctly such that it uses the 64 bit generator for Visual Studio 2010. The essence of what I am doing right now is find_package(Matlab) add

Build a mex file under Visual Studio ultimate 2012

做~自己de王妃 提交于 2019-12-06 13:43:42
I had some code (c++) and I would like to generate the mex files. is there any tutorial which tech how to setup visual studio ultimate 2012 how to build mex files? thanks a lot j0rre I can confirm that the same steps as described in this question work for Visual Studio 2012 (and for Visual Studio 2013 too). Starting with an empty project the following settings in the project's Property Pages are necessary and sufficient to build a working .mexw64 file: Configuration properties -> General: Set Target Extension to .mexw64 Set Configuration Type to Dynamic Library (.dll) Configureation poperties

Openmp with mex in Matlab on mac

杀马特。学长 韩版系。学妹 提交于 2019-12-06 07:52:29
问题 I have OS X El Capitan and Matlab R2016a and I would like to use OpenMP, which has previously worked. I have managed to install gcc-5 via homebrew and have openmp working there. I can see from this thread GCC C/C++ MEX Matlab R2015 Mac OS X (with OpenMP) doesn't work that at least in R2014a, it was possible to insert mexopts.sh manually and edit it. However, I do not have such a file to use in order to redirect the compiler flag (CC) to point at the gcc-5 compiler that works with the -fopenmp

GLIBCXX not found when compiling vtk example under mex

£可爱£侵袭症+ 提交于 2019-12-06 05:19:13
问题 I have been trying to follow this example for compiling vtk in MATLAB using mex, on an Ubuntu 11.10. The mex command I used is as follows: mex -I/usr/include/vtk-5.6 vtk_file.cpp -L/usr/lib/ -lvtkFiltering -lvtkRendering -lvtkCommon After compilation I have a .mexa64 file. However, when I try to run the file I end up with the following error: Invalid MEX-file '/home/bill/Documents/MATLAB/vtk/vtk_file.mexa64': /usr/local/MATLAB/R2011b/bin/glnxa64/../../sys/os/glnxa64/libstdc++.so.6: version

building MATLAB jpeg toolbox with libjpeg8d

半世苍凉 提交于 2019-12-06 05:07:00
This question is related to another question I asked here: Error reading image using jpeg_read from Matlab's jpeg toolbox I've been trying to compile the jpeg toolbox under Windows 7 (using the commands Shai provided in the answer to the question I posted), but I get the following error: jpeg_read.c(52) : fatal error C1083: Cannot open include file: 'jerror.h': No such file or directory which I believe happened because I haven't built libjpeg. I tried to build libjpeg6b like jpegtoolbox's README says, but I couldn't find a clear guide on how to do it on Windows with visual studio 2010 (and