Best practice for C files in matlab 64bit
조회 수: 2 (최근 30일)
이전 댓글 표시
I'm using Microsoft Visual Studio Express 2012 (64 bit) and Matlab 2013b (64bit) on win7. I'm having some problems with importing and writing dll libraries that work in Matlab. I have looked around and found that this is a quite common problem.
Could Matlab pose a best practice solution for this problem?
Right now I use
test.h:
#ifdef __cplusplus
extern "C"
{
#endif
double return_my_double(double x);
#ifdef __cplusplus
}
#endif
test.cpp:
#include "lhr_test.h"
#ifdef __cplusplus
extern "C" {
#endif
double return_my_double(double x)
{
return x;
}
#ifdef __cplusplus
}
#endif
I compile this without warnings in ms visual studio. In matlab I type
>> unloadlibrary('Project1');
>> loadlibrary('Project1', 'test.h');
Warning: The function 'return_my_double' was not found in the library
> In loadlibrary at 403
>> libisloaded('Project1')
ans =
1
>> m = libfunctions('Project1')
m =
[]
>>
So clearly, matlab loads the library but fails to find the function...
Lars
댓글 수: 0
채택된 답변
Friedrich
2013년 8월 7일
Clearly the DLL does not export the "return_my_double" function. Recompile your code correctly and make sure the function is really exported. You can double check which functions are exported with tools like dependecy walker.
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Whos에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!