Reputation: 2105
After testing my code alone, I decided to incorporate it into the project finally. The issue is, when LabVIEW 2010 (SP1, 64-bit) loads the custom DLL, it walks the dependencies and finds that it needs tbb.dll eventually. Well, as far as I can tell, LabVIEW uses its own version of tbb.dll. And its version is missing the entry point ?throw_exception_v4@internal@tbb@@YAXW4exception_id@12@@Z
. I ran the function before separately, and it worked fine. It would appear this is not an unheard of LabVIEW error which hasn't been addressed.
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;
}
The .h file is just the prototype of the function.
Upvotes: 3
Views: 851
Reputation: 2105
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:
Upvotes: 1