Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法在MATLAB中加载库 我在Visual C++ 2008 SP1中编写了一个非常简单的程序。 它只是把两个数字加起来。 DLLTest.cpp是: #include "DllTest.h" __declspec(dllexport) double Add(double a, double b) { return( a + b ); }_Matlab_Visual C++_Dll - Fatal编程技术网

无法在MATLAB中加载库 我在Visual C++ 2008 SP1中编写了一个非常简单的程序。 它只是把两个数字加起来。 DLLTest.cpp是: #include "DllTest.h" __declspec(dllexport) double Add(double a, double b) { return( a + b ); }

无法在MATLAB中加载库 我在Visual C++ 2008 SP1中编写了一个非常简单的程序。 它只是把两个数字加起来。 DLLTest.cpp是: #include "DllTest.h" __declspec(dllexport) double Add(double a, double b) { return( a + b ); },matlab,visual-c++,dll,Matlab,Visual C++,Dll,而DllTest.h是: #ifndef _DLL_TEST_H_ #define _DLL_TEST_H_ #endif __declspec(dllexport) double Add( double, double); < >我使用Visual C++ 2008构建DLL。当我尝试使用loadlibrary加载库时,出现以下错误: ???在422大楼DllTest\U thunk\U pcwin64上使用==>loadlibrary时出错。编译器输出为: DllTest\u thunk

而DllTest.h是:

#ifndef _DLL_TEST_H_
#define _DLL_TEST_H_
#endif

__declspec(dllexport) double Add( double, double);
< >我使用Visual C++ 2008构建DLL。当我尝试使用
loadlibrary
加载库时,出现以下错误:

???在422大楼DllTest\U thunk\U pcwin64上使用==>loadlibrary时出错。编译器输出为: DllTest\u thunk\u pcwin64.c:\Users\Admin\Desktop\DllTest.h(5):错误 C2054:应为“(”跟随“导出的函数” C:\Users\Admin\Desktop\DllTest.h(5):错误C2085:“添加”:不在 正式参数列表DllTest_thunk_pcwin64.c(40):错误C2085: “int8”:不在正式参数列表DllTest\u thunk\u pcwin64.c(41)中: 错误C2085:“uint8”:不在形式参数列表中 DllTest_thunk_pcwin64.c(42):错误C2085:“int16”:不是正式的 参数列表DllTest_thunk_pcwin64.c(43):错误C2085:'uint16': 不在正式参数列表DllTest_thunk_pcwin64.c(44)中:错误 C2085:“int32”:不在形式参数列表中 DllTest_thunk_pcwin64.c(45):错误C2085:“uint32”:不是正式的 参数列表DllTest_thunk_pcwin64.c(46):错误C2085:'int64': 不在正式参数列表DllTest_thunk_pcwin64.c(47)中:错误 C2085:“uint64”:不在形式参数列表中 DllTest_thunk_pcwin64.c(48):错误C2085:“voidPtr”:不是正式的 参数列表DllTest_thunk_pcwin64.c(49):错误C2085:“字符串”: 不在正式参数列表DllTest_thunk_pcwin64.c(51)中:错误 C2082:重新定义形式参数“导出的函数” DllTest_thunk_pcwin64.c(51):错误C2143:语法错误:缺少“;” 在'type'DllTest_thunk_pcwin64.c(52)之前:错误C2085: “EXPORTED_FunctionDoubleThunk”:不在形式参数中 列表DllTest_thunk_pcwin64.c(52):错误C2143:语法错误:缺少 “;”在“{”之前


我想在MATLAB中加载一个简单的程序,用Visual C++编写。我如何解决这个问题?

< p>谢谢考虑我的问题。 我发现了问题。实际上,有两个问题: 1) MATLAB是64位的,但我创建了32位DLL,我必须在Visual Studio中更改设置以创建64位DLL。 2) MATLAB用于加载DLL的编译器似乎存在“extern”C“命令问题。因此,我更改了如下标题:

#ifndef DllTest_h
#define DllTest_h

#include <stdio.h>

#ifdef __cplusplus

extern "C" {

#endif
__declspec(dllexport) double Add( double, double);

#ifdef __cplusplus
}
#endif


#endif
\ifndef DllTest\h
#定义DllTest_h
#包括
#ifdef_uucplusplus
外部“C”{
#恩迪夫
__declspec(dllexport)双加(double,double);
#ifdef_uucplusplus
}
#恩迪夫
#恩迪夫
最后它成功了。

您使用的是什么操作系统(32/64位)和Matlab版本?