Mex file-using c functions

Hello all,
I have one question: I have a matlab wrapper that calls another C file that has some functions that I want to pass data to from Matlab and get results back to Matlab. But not successful!
The complication is: Whenever I compile the first c file (wrapper), it gives an mexw64 file (although I was told it is a dll) and when this happens and I just call this file Matlab cannot load this 2nd file that has the functions claiming that it is empty! Any ideas what am I doing wrong here?
For this second file (that has the functions) I was told to compile it like this:
gcc -c fcnsuite.c -DWINDOWS
dllwrap -o fcnsuite.dll fcnsuite.o
Using MingW, but it does not generate any dll and hence I get: dllwrap: no export definition file provided. Creating one, but that may not be what you want dllwrap: CreateProcess: No error
Any hints?
Thanks

回答 (2 件)

Jan
Jan 2013 年 4 月 21 日

0 投票

MEXW64 files are DLLs, although they have a different file extension.
What about compiling the wrapper and the core functions together:
mex -O wrapper.c fcnsuite.c
? Then the code of the fcnsuit is included in the wrapper DLL.

3 件のコメント

seldeeno
seldeeno 2013 年 4 月 22 日
Actually I tried to compile fcnsuite.c using mex and then it complains that it is not like the wrapper! Why is not able to locate that dll for fcnsuite.c although I have a copy of its dll that was created on another windows system?
Kaustubha Govind
Kaustubha Govind 2013 年 4 月 22 日
To be able to use the MEX command, you need to provide at least one C-file that contains an entry-point with the signature:
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]);
Do you have this in fcnsuite.c?
Also, it's not clear what you mean by "Why is not able to locate that dll for fcnsuite.c...". How do you use it in MATLAB, and what is the error that you see?
seldeeno
seldeeno 2013 年 4 月 22 日
I have this in the interface that has my mexfunction (named "mlbsuite.c"). The fcnsuite.c contains all the functions but when I call my mlbsuite later after execution it says that the function that I call is not in the library:
"procedure g06 not found in library file!Error using mlbsuite failed to load procedure"

サインインしてコメントする。

seldeeno
seldeeno 2013 年 4 月 23 日

0 投票

Ok people I got it to work. Actually I had to create the dll of the function using a command like: mbuild file1.c file1.exports with function names in this file1.exports and that did the trick
Thank you all for your comments!

2 件のコメント

Victor Hugo Cantú
Victor Hugo Cantú 2018 年 9 月 20 日
I have the same problem as you (the same files !), I don't understand how you fixed the problem.
yuen andy
yuen andy 2021 年 5 月 31 日
編集済み: yuen andy 2021 年 5 月 31 日
I have the same problem too. so what should I run for the fcnsuite.c ?
The complete set of functions may be found in the following C source code: fcnsuite.c and should be compiled as follows:
for linux:
gcc -c fcnsuite.c
ld -o fcnsuite.so -shared fcnsuite.o
for windows:
gcc -c fcnsuite.c -DWINDOWS
dllwrap -o fcnsuite.dll fcnsuite.o
We recommend the GCC compiler native in Linux and available for Windows from here www.mingw.org.
Binary versions are also directly available from here: fcnsuite.dll (Windows) or as fcnsuite.so (Linux Intel binary).
gcc -c fcnsuite.c -DWINDOWS
dllwrap -o fcnsuite.dll fcnsuite.o

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeWrite C Functions Callable from MATLAB (MEX Files) についてさらに検索

質問済み:

2013 年 4 月 21 日

編集済み:

2021 年 5 月 31 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by