【发布时间】:2014-11-13 04:58:30
【问题描述】:
在单独测试了我的代码后,我决定最终将其合并到项目中。问题是,当 LabVIEW 2010(SP1,64 位)加载自定义 DLL 时,它会遍历依赖项并最终发现它需要 tbb.dll。好吧,据我所知,LabVIEW 使用自己的 tbb.dll 版本。它的版本缺少入口点?throw_exception_v4@internal@tbb@@YAXW4exception_id@12@@Z。我之前单独运行了这个函数,它工作得很好。 It would appear this is not an unheard of LabVIEW error which hasn't been addressed.
由于这是第三方库的依赖项,我不能使用 MATLAB 库并从头开始制作所有内容,或者我可以强制 LabVIEW 加载 tbb.dll 的工作版本,这似乎意味着复制 DLL进入 Windows 文件夹。这些都不是可用的解决方案。此外,我们没有Mathscript 的许可证。有什么想法吗?
以防我在修改他们的示例时做错了,我的代码的简化版本如下:
#include "stdafx.h"
#include <stdio.h>
#include <stdlib.h>
#include <cstring>
#include "mat.h"
#include "createMatFile.h"
export "C" int createMatFile(const char *filename, int* dataArray, int count)
{
MATFile *pmat;
mxArray *data;
mwSize dims[2] = {1,1};
//Open the file to write to
pmat = matOpen(filename, "w");
if (pmat == NULL) {
printf("Error creating file %s\n", filename);
printf("(Do you have write permission in this directory?)\n");
return(EXIT_FAILURE);
}
//Convert data to double
double* dataDouble = new double[count];
for(int i=0; i<count; i++)
{
dataDouble[i] = (double)data[i];
}
//Populate the mxArrays
dataArray = mxCreateDoubleMatrix(1,count,mxREAL);
memcpy((void *)(mxGetPr(dataArray)), (void *)dataDouble, sizeof(*dataDouble)*count);
//Put the shape struct in the .mat file
int status = matPutVariable(pmat, "data", dataArray);
if (status != 0) {
printf("%s : Error using matPutVariable on line %d\n", __FILE__, __LINE__);
return(EXIT_FAILURE);
}
//Clean up
delete [] dataDouble;
mxDestroyArray(dataArray);
//Close the file to write to
if (matClose(pmat) != 0) {
printf("Error closing file %s\n",filename);
return(EXIT_FAILURE);
}
return EXIT_SUCCESS;
}
.h 文件只是函数的原型。
【问题讨论】:
-
可能是 x32/x64 问题?
-
我也想过。我们使用的是 64 位版本的 LabVIEW,以及 64 位版本的 MATLAB 库。我的 dll 是为 64 位架构构建的。现在,自从it's not possible to load a 32 bit dll into a 64 bit process 我取消了那个选项。
-
尝试使用 Labview 加载 dll 库手动加载您需要的 tbb.dll,看看是否有效?
-
我可以这样做吗? It would appear 我只能通过调用它们来加载 dll,但我从不调用 tbb.dll,MATLAB DLL 会自己调用。我想我可以尝试调用其中一个函数并吞下由此产生的错误,但我认为这不是一个好主意,我不知道这是否真的有效。即使内存中有第二个 tbb.dll,当 libmat.dll 调用 *.dll 调用 ... 调用 tbb.dll 时,它会使用隐式加载,并获取 LabVIEW 的。