- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我想用 Matlab Compiler SDK 构建一个可以从 LabView 调用的 DLL。如您所知,LabView 不能直接调用由 Matlab Compiler SDK 生成的库(我们称之为“my_dll.dll”/“my_dll.lib”),因为它使用非标准数据类型 (mxArrays)。
因此,我的计划是在 C 中生成一个包装代码。这个包装代码,无论何时被调用,都会执行 Matlab 运行时引擎所需的例程,并调用在“my_dll.dll”中生成的函数。此包装代码基本上与使用先前生成的 DLL 的任何其他可执行文件或应用程序非常相似,遵循 this 的准则。 .
代码示例:
int main(double *input){
/* Call the mclInitializeApplication routine. Make sure that the application
* was initialized properly by checking the return status. This initialization
* has to be done before calling any MATLAB API's or MATLAB Compiler SDK generated
* shared library functions. */
mclmcrInitialize();
if( !mclInitializeApplication(NULL,0) )
{
fprintf(stderr, "Could not initialize the application.\n");
return -1;
}
return mclRunMain((mclMainFcnType)wrapper_main,0,NULL);
}
double wrapper_main(int argc, char **argv) {
//declare variables
double *out; // Here my output will be stored
double number = 16; // This is the input number
// Initialise library
dll_layer1Initialize();
//Create two pointers of mxArray type to store inputs and outputs
mxArray *in1_ptr;
mxArray *out1_ptr = NULL;
//Allocate input pointer to a 1 by 1 double, real matrix
in1_ptr = mxCreateDoubleMatrix(1, 1, mxREAL);
//Move the data from the input to the pointer
memcpy(mxGetPr(in1_ptr), &number, 1 * sizeof(double));
//Pass values to mlfFoo and receive in mxArray type variable
//mlfFoo is my matlab function. In this case it only performs
//the square root of the input number.
mlfFoo(1, &out1_ptr, in1_ptr);
out = mxGetPr(out1_ptr);
printf("\n Result is: %f", *out);
//Terminate foo implementation
dll_layer1Terminate();
mclTerminateApplication();
return 0;
}
但是,为了从 LabView 调用这个 C 包装代码,我必须生成一个新的 DLL,问题来了,因为我找不到这样做的方法。下图总结了我想做的事情。
我尝试过的事情:
1 - 使用 Matlab Compiler SDK 'mbuild' 命令编译 C 包装程序代码和 my_dll.lib 以生成 wrapper.dll。这只会创建一个可执行文件,而不是一个 dll。也许我遗漏了什么。
2 - 使用 Visual Studio 创建 DLL。我在这里面临的问题是,当我要构建项目时,它会给我很多错误,例如:
Error LNK2019 unresolved external symbol _mclRunMain_proxy referenced in function "public: static double __cdecl Wrapper::Functions::wrapper_sqrt(double)" (?wrapper_sqrt@Functions@Wrapper@@SANN@Z) Win32Project1 ...\visual studio 2015\Projects\Win32Project1\Win32Project1\wrapper.obj 1
也许我的错误是我没有正确链接 Matlab 库,在这种情况下我不知道如何修复它。
在 LabView 中运行 Matlab 代码的其他可能性是使用 MathScript 节点、Matlab Script 节点或 Matlab Coder(也用于创建 DLL),但是,出于其他几个原因,我放弃了这些选项。
预先感谢您的帮助。
最佳答案
对于尝试 #2,您是否在项目中添加了对 matlab dll 的引用?
关于c++ - 在 C 代码中为 Matlab/LabView 接口(interface)创建 DLL 包装器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46928129/
我有一个 Windows Service(一个发布版本),我替换了一个在 Debug模式下构建的 DLL 并尝试启动服务。它引发了错误无法加载文件或程序集“名称”或其依赖项之一。尝试加载格式不正确的程
我使用 Microsoft Visual Basic 6.0 Enterprise Edition SP6 开发了一个 VB6 应用程序。 我已将可执行文件复制到未安装 VB6 的计算机 C。 我已在
我有很多小的 DLL,我想将它们组合成一个大的(更)DLL(如 suggested here)。我可以通过合并我的项目来做到这一点,但我想要一种不那么干扰的方式。 可以将多个 DLL 合并为一个单元吗
我想将非托管 DLL 和图像文件与托管 DLL 合并。我该怎么做?可能吗? 最佳答案 很有可能。这可以通过 bxilmerge 来完成此解决方案可以将非托管 DLL 和图像或其他文件与托管 DLL 合
如何在Windows Server 2003上安装msvcr71.dll,这是我的软件所需的。我真的不想将此dll复制到system32文件夹,因为它可能会破坏此目标系统。 最佳答案 只需将其复制到程
我最近遇到了一个安装在我的系统上的 DLL,Dependancy Walker(以及我尝试过的所有其他实用程序)说按名称或顺序导出为零,但文件大小约为 4mb。我认为 DLL 的唯一目的是导出供其他代
我终于让我的本地主机在本地显示该站点。一切似乎都在朝着这个方向努力。我的下一步是当网站使用 ActiveX.dll 中的函数时,实际上能够从 VB6 IDE 进入代码 更新: 我更新了代码并删除了我在
首先,我指的是Windows环境和VC++编译器。 我想要做的是重建一个Vc++ dll并与已经链接到该lib的exe保持兼容性,而不必重建该exe或使用LoadLibrary动态加载该dll。换句话
我以前这样做过,我不记得我是从网上下载的 DLL 还是其他东西,但我不想感染病毒。我需要访问这个命名空间,以便我可以拥有 Webbrowswer 控件不提供的额外功能。 如何准确添加 Com 引用。还
我正在尝试为依赖于 ghostscript 的库创建 Nuget 包,因此引用 gsdll32.dll - 一个非托管库。我不能只包含一个标准的 dll 引用。我应该把它放在 nuget 目录结构中的
如果我有 Windows 可执行文件,我如何找出它将加载哪些 dll? 我只是谈论哪些将静态加载,而不是那些可能使用 LoadLibrary 等动态加载的内容。 最佳答案 dumpbin是VC++自带
这可能是一个非常菜鸟的问题,但在当今的网络应用程序开发世界中,许多程序员不需要过多处理 dll,因此也懒得去了解它们的用途。 那么什么是dll? 它有什么用? 它是如何工作的? 如何创建一个? 在什么
所以我刚刚开始使用 OpenTK,并将此代码放在一个继承 GameWindow 类的类中: protected override void OnRenderFrame(FrameEventArgs e
如何调试未由 java 应用程序加载的 dll。 场景是这样的:我的 java 应用正在加载正在使用另一个 dll 的 jni.dll,而那个 dll 正在使用另一个 dll。 javajni.dll
我将“更好”放在引号中,因为这是一个定性问题。几年来我一直在编写 COM DLL,直到最近才发现并成功使用了带有 Typelib 概念的标准 DLL。 使用 COM DLL 代替 DLL+Typeli
这种用户机器可能没有msvcp100.dll、msvcp100.dll之类dll的情况怎么处理?我不希望我的软件因为这种错误而无法安装在用户的机器上。我一直在考虑要么找到一个工具并将每个需要的 dll
在 VS2012 中使用 C# .NET 和 COM 互操作,我正在开发一个用于其他几个程序的公共(public)库。为了简化集成,我想将整个库缩减为一个 DLL。该库的特点之一是本地化。它有包含多种
我在 .Net 中使用 FieldTalk Modbus。当我运行应用程序时,我在为 MbusTcpMasterProtocol 创建对象时遇到错误。 MbusTcpMasterProtocol mb
我想指出,我知道如何向/从 GAC 添加/删除程序集。我要问的是,是否有人可以从技术角度向我解释它是如何工作的。将 dll 放在那里有什么意义 - 从节省资源的角度来看。 亲切的问候 最佳答案 将东西
我继承了一个传统的经典 ASP 应用程序,它使用 VB6 ActiveX DLL 来执行业务逻辑。 我想跟踪加载和卸载 DLL 的点。有没有办法在 VB6 DLL 中拦截这些事件? 在相关说明中,Cl
我是一名优秀的程序员,十分优秀!