mex

Compiling CUDA Mex Files using Visual Studio 2013 IDE

一笑奈何 提交于 2019-12-11 03:49:09
问题 I am trying to compile following program, which is a CUDA mex file for MATLAB, using Visual Studio 2013. There are instructions available on MATLAB's official website only for C++ Mex files , not for the CUDA mex. So I made following additional changes to my project settings while following the official instructions on Mathworks: 1. I created a project using Visual studio project with my installed CUDA 6.5 runtime. 2. Included the libs (libmx.lib,libmex.lib,libmat.lib,gpu.lib) in Linker

matlab crashes without dump file when using fopen for file

China☆狼群 提交于 2019-12-11 03:41:37
问题 I am using gnumex with mingw for compiling mex files in matlab in Windows OS. I am not able to use fopen command to open files. Following is the code which I am using. #include <stdio.h> #include "mex.h" void mexFunction(int nlhs,mxArray *plhs[],int nrhs,const mxArray *prhs[]) { FILE *fp=NULL; fp = fopen("test.txt", "w+"); } The program compiles succesfully but when I try to run the compile mexw64 file, matlab simply closes down without generating any dump file. Note that I am able to run

Creating mex files from CUDA code

旧街凉风 提交于 2019-12-11 03:31:46
问题 I have Windows XP 64 bit, MATLAB R2012a( R2010a is also available here, but not installed), VS 2010 (VS 2008/VS 2012 is also available, but not installed) and CUDA 5.0 installed.. Is it possible to compile CUDA codes with these in MATLAB to create a mex file? Can anyone help with the necessary steps or any thing further need to be installed?? Thanks in advance 回答1: Using MATLAB 2013 If you can upgrade to 2013 read on, otherwise go to the bottom of the page for some suggestions for 2012

Missing symbol 'for_realloc_lhs' in Matlab's libifcorem​d.dll'

旧巷老猫 提交于 2019-12-11 02:51:50
问题 I built a toto.dll and a toto.lib with ifort (Intel's 2017 update 4 fortran compiler). Then I used mex matlab's compiler to produce several mexw64 files. When I used mex I linked to toto.lib . Then, I ran a .m file (matlab file) inside matlab 2017a 64bits (under win10 64bits), an this file is using functions from the various mexw64 's I compiled. In the matlab file, at the first call of such function I got the following error : Invalid MEX-file 'C:\path\to\mexfile.mexw64': Missing symbol 'for

Using a dll file in matlab code

☆樱花仙子☆ 提交于 2019-12-10 21:10:06
问题 I need to use a function in Matlab that is defined by a dll file. I got an example that guy converted a dll to mexw32 file but i have known how I do this. I tried use loadlibrary but it didn't create any file. How I can do this? 回答1: loadlibrary is MATLAB's implementation of FFI services, a mechanism of calling functions in external shared libraries. It involves converting between C-types and their equivalent MATLAB data types to pass data around. MEX-files are also a kind of dynamically

Can MEX files be run with -fsanitize=address?

纵饮孤独 提交于 2019-12-10 19:24:05
问题 I have a MEX file compiled normally with g++. I recently changed its compilation to use clang++, and included -fsanitize=address into both the LDFLAGS and CFLAGS (note: no CXX flags exist for this project). However, despite this, once I get to MATLAB and attempt to call the MEX file, I get: Invalid MEX-file '(path to mex file)': undefined symbol: __asan_option_detect_stack_use_after_return. That specific error is really common when people mess up linking in the address sanitizer correctly.

mex file compiled without errors but not working in matlab

旧时模样 提交于 2019-12-10 18:33:46
问题 First I wanted to compile MatConvNet library for using in windows form this tutorial (Compiling MatConvNet on Windows) but I couldn't. Then I think it is better to compile a very simple file and after that going to compile the library. I have Matlab R2013a 64 bit and Visual Studio 2010 64 bit . my program Test.cpp #include "mex.h" void mexFunction(int nlhs, mxArray *plhs[],int nrhs, const mxArray *prhs[]) { printf("Hello! :)\n"); } I can compile Test.cpp in matlab with mex Test.cpp And when I

Is there a way to make try-catch statements in mex files?

纵然是瞬间 提交于 2019-12-10 17:09:46
问题 I know that there is no built-in way to do try-catch statements in C, but has MATLAB facilitated any type of try-catch functionality for MEX files? I tried to use Longjmp and Setjmp in the way described in http://www.di.unipi.it/~nids/docs/longjump_try_trow_catch.html, but I was not successful. Has anyone else figured out a way? 回答1: You can write your MEX-files in C++ and use the C++ exception handling. 来源: https://stackoverflow.com/questions/17190465/is-there-a-way-to-make-try-catch

Trying to Compile a C mex file in MatLab

末鹿安然 提交于 2019-12-10 16:18:54
问题 Hey trying to compile one C-file in MatLab, but I got this error and I'm trying to make sense of it. Any and all guidance is greatly appreciated. >> mex BDS_unpack_mex5.c xcrun: error: SDK "macosx10.7" cannot be located clang: warning: no such sysroot directory: '-mmacosx-version-min=10.7' BDS_unpack_mex5.c:17:10: fatal error: 'math.h' file not found #include <math.h> ^ 1 error generated. mex: compile of ' "BDS_unpack_mex5.c"' failed. Error using mex (line 206) Unable to complete successfully

MATLAB MEX interface to a class object with multiple functions

﹥>﹥吖頭↗ 提交于 2019-12-10 12:55:48
问题 I am using the MEX interface to run C++ code in MATLAB. I would like to add several functions to MATLAB for handling a System object: sysInit() sysRefresh() sysSetAttribute(name, value) String = sysGetAttribute(value) sysExit() Since each MEX dll can contain one function, I need to find a way to store the pointer to the global System object which will exist until deleted by a call to sysExit . How can I do this in MATLAB properly? Are there any ways to store global pointers across calls to