单独测试我的代码之后,我决定最终将它合并到项目中。问题是,当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文件只是函数的原型。
答案 0 :(得分:1)
因为LabVIEW将自己的tbb.dll版本安装到windows路径中并加载,所以修复它的唯一方法是将新的tbb.dll复制到system32文件夹中。这不是一个好的解决方案,所以唯一可能的答案似乎是: