mex

matlab mex files and C++ dll (windows)

假如想象 提交于 2019-12-12 14:42:14
问题 I have a DLL with class Test. Header: class MY_EXPORT Test { public: int doit(const string &str); }; and source: int Test::doit(const string &str) { return int(str.length()); } Now I use it from mex file: void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { string str("hello!"); Test *t = new Test(); t ->doit(str); } The problem, that variable str is not passed correctly to the method doit . Inside the method it contains rabish. I found that this happens with any

How to ignore `mexopts.sh` when compiling MEX files for Matlab?

旧城冷巷雨未停 提交于 2019-12-12 12:56:22
问题 The -f command-line argument to mex allows to specify the location of the mexopts.sh that we wish to use. But is there a way to tell Matlab to ignore mexopts.sh ? In order to compile a specific MEX file I need to specify CC , CFLAGS , etc., directly on the command line when invoking mex . Values already given in mexopts.sh cause a conflict and cause mex to fail. Thanks! 来源: https://stackoverflow.com/questions/16178891/how-to-ignore-mexopts-sh-when-compiling-mex-files-for-matlab

MATLAB Mex : Already had -std=c++11, but still got error of “compiler and library support”

半腔热情 提交于 2019-12-12 04:06:31
问题 I'm currently running MS COCO MatlabAPI on WIN 10. I want to produce a file called gasonMex.mexw64. I have installed MinGW64 and simple Matlab .c file has been tested working. I used mex -v COMPFLAGS='$COMPFLAGS -std=c++11 -Wall' -largeArrayDims gasonMex.cpp Verbose mode is on. ... Looking for compiler 'MinGW64 Compiler (C++)' ... ... Looking for environment variable 'MW_MINGW64_LOC' ...Yes ('C:\MATLAB\SupportPackages\R2016a\MW_MinGW_4_9'). ... Looking for file 'C:\MATLAB\SupportPackages

Compiling C file in Matlab with Visual Studio

安稳与你 提交于 2019-12-12 03:17:59
问题 I have a C-File that I wanna compile in Matlab with MS Visual Studio 10. For that I use the following command: mex -v test.c The output that I get after compilation is the following: test.c Contents of C:\Temp\mex_kpuu4t\mex_tmp.rsp: C:\Temp\mex_kpuu4t\test.obj --> link /out:"test.mexw64" /dll /export:mexFunction /MAP /LIBPATH:"C:\Program Files\MATLAB\R2011a\extern\lib\win64\microsoft" libmx.lib libmex.lib libmat.lib /implib:"C:\Temp\mex_kpuu4t\templib.x" /MACHINE:X64 kernel32.lib user32.lib

Working around segmentation faults that occur in parallel due to a non-thread-safe API function

[亡魂溺海] 提交于 2019-12-12 02:58:06
问题 I am currently coding a MEX file in MATLAB to run experiments in parallel using the parfor function in MATLAB 2012a. The MEX file does some very straightforward numerical tasks but relies on the CPLEX 12.4 API from IBM. Although my MEX file works sequentially, I will inevitably receive "random" segmentation fault when I run in in parallel. After sending a stack trace of the segmentation fault to MATLAB, they have suggested that the error originates from the "putenv()" function from the C

How can I use CLAPACK,BLAS or LAPACK in a mex file?

隐身守侯 提交于 2019-12-12 02:28:05
问题 I am having trouble writing a MEX file in MATLAB that can perform a simple linear operation such as taking the inverse of a matrix. I have successfully managed to take the inverse of a matrix using Visual Studio 2010 and have successfully created a MEX file hence the only thing I am having trouble is getting these two concepts together. I have tried to compile a MEX example code that I got from the MathWorks site but with no luck. Here is what I have tried, Saved the file (renamed it) I got

Unable to compile MEX

Deadly 提交于 2019-12-12 00:17:59
问题 I am trying to compile some MATLAB MEX files from C++ source. The files I am trying to compile can be found here; I am using Windows XP on a 32-bit system, MATLAB 2012a and have installed the Microsoft Windows SDK v7.1 to use as my compiler. MATLAB outputs the following error if I try to compile: >> mex -O -largeArrayDims osc_free_address.c osc_free_address.c osc_free_address.c(1) : error C2059: syntax error : '<' osc_free_address.c(37) : error C2015: too many characters in constant osc_free

using magma_dysevd in mex file matlab

感情迁移 提交于 2019-12-11 23:15:19
问题 I try to write use magma library in matlab, so basically I write a mexfunction which incorporate c code using magma function and then compile this mexfunction into mexa64 file, thus I could use in matlab. The mexfunction or source c code is below:(called eig_magma) #include <stdlib.h> #include <stdio.h> #include <string.h> #include <math.h> #include <cuda_runtime_api.h> #include <cublas.h> // includes, project #include "flops.h" #include "magma.h" #include "magma_lapack.h" #include "testings

QT exec() command crash

房东的猫 提交于 2019-12-11 22:01:30
问题 I´m developing an application in QT 4.7.3. This application is called from Matlab(simulink) using a mexFunction (*.mexw32) When I try to open a dialog using dialog.exec() command, the form is displayed but I get a "non responding application" instantaneously. After that, matlab crashes. If i try to open the dialog using dialog.show() command, it works fine. I really have no idea of whats going on, since both commands are somehow similar, as described here Does anyone know what is happening?

Object file associated with UHD (USRP Hardware Driver) not found

前提是你 提交于 2019-12-11 18:28:31
问题 I am trying to compile a C++ file that uses the utilities of UHD (USRP Hardware Driver) in MATLAB. This is in connection with trying to use a USRP called NI-2954R with MATLAB 2013b on a 64-bit system with windows 10 OS. The following is the mex command: mex -largeArrayDims -v -g rx_samples_to_file.cpp -I. "C:\Users\VINAYAK KARANDIKAR\Documents\MATLAB\MATLAB\Thesis\MATLAB_USRP_INTERFACE\UHD_sample_programs_from_GitHub\uhd"... -I."C:\Users\VINAYAK KARANDIKAR\Documents\MATLAB\MATLAB\Thesis