Calling a C function from MATLAB

2 views (last 30 days)
seldeeno
seldeeno on 22 Apr 2013
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 Comments
Jan
Jan on 23 Apr 2013
In which folders does LoadLibrary look for this dll-file?
seldeeno
seldeeno on 23 Apr 2013
It is in the same folder as the C and .m files

Sign in to comment.

Answers (1)

seldeeno
seldeeno on 23 Apr 2013
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 Comment
Victor Hugo Cantú
Victor Hugo Cantú on 20 Sep 2018
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

Sign in to comment.

Categories

Find more on Write C Functions Callable from MATLAB (MEX Files) in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!