Calling a C function from MATLAB

Hello,
I have one question: While I successfully create a dll file for my C file via MinGW, whenever I call my file with certain parameters I keep getting an error that is related to that this code in C returns NULL , any ideas please?
#ifdef WINDOWS
hLibrary = LoadLibrary ("fcnsuite.dll");
#else
hLibrary = dlopen ("./fcnsuite.so", RTLD_NOW);
#endif
And this gives "failed to load procedure"!!!

댓글 수: 6

Walter Roberson
Walter Roberson 2013년 4월 22일
Does your C code have a "return" statement? http://msdn.microsoft.com/en-us/library/sta56yeb%28v=vs.80%29.aspx
seldeeno
seldeeno 2013년 4월 22일
No return since my function is void, and my interface (mexfunction) also calls another void function in another file that is included as a dll
Friedrich
Friedrich 2013년 4월 23일
"failed to load procedure" is not a standard C error. Seems more like a selfmade error somewhere in your code (I would guess when you call GetProcAdress which fails). Are you sure the LoadLibrary call works? So the DLL can be found? Is hLibrary a valid pointer?
seldeeno
seldeeno 2013년 4월 23일
What you are saying is exactly what I have and the loadLibrary is the thing that is not getting the dll right and hence says that the procedure in the library is not found:
"procedure g06 not found in library file!Error using mlbsuite failed to load procedure"
Jan
Jan 2013년 4월 23일
In which folders does LoadLibrary look for this dll-file?
seldeeno
seldeeno 2013년 4월 23일
It is in the same folder as the C and .m files

댓글을 달려면 로그인하십시오.

답변 (1개)

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!

댓글 수: 1

please give more details about how you fixed this problem. at the end, the problem was in matlab or when compiling this:
gcc -c fcnsuite.c -DWINDOWS
dllwrap -o fcnsuite.dll fcnsuite.o
I really want to have access to this files. Thanks in advance

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

질문:

2013년 4월 22일

댓글:

2018년 9월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by