问题描述
单独测试我的代码后,我决定将它并入项目。问题是,当LabVIEW 2010(SP1,64位)加载自定义DLL时,它会遍历依赖关系,并发现它需要。嗯,据我所知,LabVIEW使用自己的tbb.dll版本。它的版本缺少入口点?throw_exception_v4 @ internal @ tbb @@ YAXW4exception_id @ 12 @@ Z
。我单独运行函数,它工作正常。 的许可。任何想法?
Since this is a dependency of a third party library, I can either not use the MATLAB libraries and make everything from scratch, or I can force LabVIEW to load the working version of tbb.dll, which appears to mean copying the DLL into the Windows folder. Neither of these are usable solutions. Additionally, we do not have the license for Mathscript. Any ideas?
为了防止我在修改示例时发生错误,我的代码的简化版本如下:
Just in case I did something wrong when I modified their example, a simplified version of my code is as follows:
#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文件只是函数的原型。
The .h file is just the prototype of the function.
推荐答案
因为LabVIEW将自己的tbb.dll版本安装到Windows路径中,并加载它,修复它的唯一方法是复制新的tbb.dll在system32文件夹中。这不是一个好的解决方案,所以唯一的答案可能似乎是:
Because LabVIEW installs its own version of tbb.dll into the windows path, and loads that, the only way to fix it is to copy the new tbb.dll in the system32 folder. This is not a good solution, so the only answer possible appears to be either:
- 使用此system32 hack可能会导致其他问题
- 创建一些黑客来在一个单独的过程中动态加载适当的DLL,从LabVIEW加载,并从该过程调用MATLAB DLL,然后将计算的值返回到LabVIEW过程。由于我的程序只将数据写入文件,因此不需要将任何返回到LabVIEW,简化了这一选择。
- 或者只是停止使用MATLAB和LabVIEW。 >
- Use this system32 hack which will probably cause other issues down the road.
- Create some hack to dynamically load the proper DLL in a separate process with nothing loaded from LabVIEW and call the MATLAB DLL from that process then return the value computed to the LabVIEW process. Since my program only writes data to a file, it doesn't have to return anything back to LabVIEW, simplifying this choice.
- Or just stop using MATLAB and LabVIEW in conjunction.
这篇关于从LabVIEW调用的DLL编写MATLAB文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!