From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

error when pass 1D array by Array Data Pointer via Labview-built DLL to C++

Solved!
Go to solution

I try to generate a Labview VI to a DLL and let it be invoked by vc++, by which a 1D array is passed. However, I cannot generate the DLL when using Array Data Pointer, which gives the error as below:

[ERROR]
Code:-2147221480
Building DLL.
An error occurred compiling the DLL because a function or parameter name is illegal. Please verify that the function and/or parameter names are legal C identifiers and do not conflict with LabVIEW headers.
Additional Information: 9 Project link errors
Error generating type library. Midl.exe failed while compiling the odl file used to create the type library.
Note: The error indicates that the odl file has unknown types. This error is possible when
functions with non-standard types are exported using the export qualifier method from files in
release configuration that have not been recompiled during the build process.

 

 

The Define VI Prototype is as below

PrototypeDef.jpg

 

But, if I use Pass by Array Handle Pointer, the generation is successful, with no error. I write something to call the labview-built DLL, which basically reads 1000 double data from an instrument.

#include "TestDQMaxDLL.h"
#include <iostream>

using namespace std;

int main(int argc, char** argv) {
	cout << "Start testing DQMax DLL" << endl;

	int leng{ 1000 };
	DoubleArray rawDPData = AllocateDoubleArray(leng);
	test_dqmax_dll(&rawDPData);
	cout << "Successfully invoked the DLL!" << endl;
	cout << "DoubleArray.len: " << (*rawDPData)->dimSize << endl;
	for (int i = 0; i < leng; i++)
	{
		cout << (*(rawDPData + i))->elt[0] << "\t";
		if (0 == i % 10)
		cout << endl;
	}

	system("pause");

	DeAllocateDoubleArray(&rawDPData);
}

 But the printed results are not correct.

 

My questions are:

1. why cannot generate DLL with Array Data Pointer. In this case, the argument of the function is more straightforward as a double array.

2. For Array handle Pointer, when the resutls are incorrect, and how to get the correct ones.

Any comments would be appreciative.

 

BTW: I am using Labview 2012 with Visual c++ 2013 on Windows7 64bit.

0 Kudos
Message 1 of 8
(3,995 Views)

Have you tried renaming your parameters? Specifically I wonder if "len" is defined somewhere else.

 

Searching for this same error on these forums, I see that other people report there's more of the error message, which explains how to call MIDL.EXE manually to see the specific errors generated. Is there more of the error message than you've shown, and are you able to run midl.exe manually?

0 Kudos
Message 2 of 8
(3,983 Views)

I did ever possible trial to figure that out, including renames the parameters. I also tried the MIDL.EXE in the error report, but the thing is that it needs a file temporarily created in Temp dir, which however is deleted immediately after the build is done. here is the full log msg:

 

27/03/2015 12:07:40
[General]
Project: D:\Codings\Labview\test-dqmax-dll.lvproj
Target: My Computer
Build Specification: TestDQMaxDLL
OS: Windows NT 6.1

[Source Files]

[ERROR]
Code:-2147221480
Building DLL.
An error occurred compiling the DLL because a function or parameter name is illegal. Please verify that the function and/or parameter names are legal C identifiers and do not conflict with LabVIEW headers.
Additional Information: 9 Project link errors
Error generating type library. Midl.exe failed while compiling the odl file used to create the type library.
Note: The error indicates that the odl file has unknown types. This error is possible when
functions with non-standard types are exported using the export qualifier method from files in
release configuration that have not been recompiled during the build process. You can mark all
files for recompilation and repeat the build. To avoid this situation, it is recommended that
you export these functions using the include file method.
Use the generated odl file "c:\Users\qwang\AppData\Local\Temp\dlltemp\TestDQMaxDLL.odl" with the command line:
d:\programs\national instruments\shared\lvdb\sdk\bin\midl.exe "c:\Users\qwang\AppData\Local\Temp\dlltemp\TestDQMaxDLL.odl" /win32 /mktyplib203 /tlb "TestDQMaxDLL.tlb" /Id:\programs\national instruments\shared\lvdb\sdk\include /cpp_cmd d:\programs\national instruments\shared\lvdb\bin\preprocessor.exe
to see what errors midl.exe reported.

ERROR_REPORTED_TO_USER

[Output Files]


[Errors]
Visit the Request Support page at ni.com/ask to learn more about resolving this problem. Use the following information as a reference:

Error -2147221480 occurred at Building DLL.
An error occurred compiling the DLL because a function or parameter name is illegal. Please verify that the function and/or parameter names are legal C identifiers and do not conflict with LabVIEW headers.
Additional Information: 9 Project link errors
Error generating type library. Midl.exe failed while compiling the odl file used to create the type library.
Note: The error indicates that the odl file has unknown types. This error is possible when
functions with non-standard types are exported using the export qualifier method from files in
release configuration that have not been recompiled during the build process. You can mark all
files for recompilation and repeat the build. To avoid this situation, it is recommended that
you export these functions using the include file method.
Use the generated odl file "c:\Users\qwang\AppData\Local\Temp\dlltemp\TestDQMaxDLL.odl" with the command line:
d:\programs\national instruments\shared\lvdb\sdk\bin\midl.exe "c:\Users\qwang\AppData\Local\Temp\dlltemp\TestDQMaxDLL.odl" /win32 /mktyplib203 /tlb "TestDQMaxDLL.tlb" /Id:\programs\national instruments\shared\lvdb\sdk\include /cpp_cmd d:\programs\national instruments\shared\lvdb\bin\preprocessor.exe
to see what errors midl.exe reported.

ERROR_REPORTED_TO_USER

This error code is undefined. Undefined errors might occur for a number of reasons. For example, no one has provided a description for the code, or you might have wired a number that is not an error code to the error code input.

Additionally, undefined error codes might occur because the error relates to a third-party object, such as the operating system or ActiveX. For these third-party errors, you might be able to obtain a description of the error by searching the Web for the error code (-2147221480) or for its hexadecimal representation (0x80040018).
27/03/2015 12:07:44

 

 

The interesting thing is that I tried simply passing two arrays as input and output respectively in other computer, which hosts the exactly same version of Labview, Visual studio and Windows, but I did not encounter any error. The build was successful. But today when I try the same VI on my laptop, I encounter the same error. That is, I can use both Array Data Pointer and Array Handler Pointer on other computer, but I cannot use Array Data Pointer on my laptop.

0 Kudos
Message 3 of 8
(3,946 Views)

If the same thing works on a different computer, it sounds like something's corrupted in your installation on the computer that doesn't work. Maybe a header file doesn't exist or got modified unexpectedly? I'd try reinstalling or repairing your LabVIEW. I don't think Visual Studio is an issue, since the error occurs during the LabVIEW build (if I'm understanding correctly).

 

It's probably not worth the effort to figure out how to use an Array Handle. Passing anything other than a standard array pointer isn't useful unless you're writing this specifically to interface with LabVIEW and you need to resize the array within the non-LabVIEW code.

0 Kudos
Message 4 of 8
(3,932 Views)

Nathand, thanks for the reply.

 

I uninstalled all NI's software, and deleted all relating folders, and made a re-installation. Tried the building but with no luck again. 

 

Since we need pass 2-D array via DLL, I wonder how to play with Array Handler Pointer since it is the only opption for 2-D array. And example would be helpful.

0 Kudos
Message 5 of 8
(3,926 Views)
Solution
Accepted by topic author ChiangW

I've never needed to pass a LabVIEW array handle to external code. Search this forum for RolfK's posts, he's the one most likely to have posted such an example. I recommend that you keep things simple and reshape your 2D array to a 1D array before passing it to the external code, and manage everything as a 1D array (it's just a bit of extra math).

 

Sorry I don't have a solution on why you can't build with a 1D array as an array pointer. If you post your project I'm happy to try to build it (I'm on LabVIEW 2012, though), but since you said it will build on another machine, it seems more likely to be a problem with something installed on the specific computer where there's a problem.

Message 6 of 8
(3,919 Views)

Good tips. Anyway, the error should be something wrong with the installation, rather than setup. I have given it up...

 

Thanks for the response.

0 Kudos
Message 7 of 8
(3,915 Views)

I am facing similar issue, I just created a VI with a string in and out, The dll is getting created in other PC for the same code, 

Uninstalled and reinstalled LabVIEW and other related software several times still the issue is not getting fixed.

 

Any ideas ?

 

LabVIEW Version : 2015.

 

Possible reasons

An error occurred compiling the DLL because a function or parameter name is illegal. Please verify that the function and/or parameter names are legal C identifiers and do not conflict with LabVIEW headers.
Additional Information: 9 Project link errors
Error generating type library. Midl.exe failed while compiling the odl file used to create the type library.
Note: The error indicates that the odl file has unknown types. This error is possible when
functions with non-standard types are exported using the export qualifier method from files in
release configuration that have not been recompiled during the build process. You can mark all
files for recompilation and repeat the build. To avoid this situation, it is recommended that
you export these functions using the include file method.
Use the generated odl file "c:\Users\vmohan1\AppData\Local\Temp\dlltemp3525.328656\SharedLib.odl" with the command line:
C:\Program Files (x86)\National Instruments\Shared\MSDTRedistributables\BuildTools\8.1\midl.exe "c:\Users\vmohan1\AppData\Local\Temp\dlltemp3525.328656\SharedLib.odl" /win32 /mktyplib203 /tlb "SharedLib.tlb" /IC:\Program Files (x86)\National Instruments\Shared\MSDTRedistributables\BuildTools\8.1 /cpp_cmd c:\program files (x86)\national instruments\shared\lvdb 2015\bin\preprocessor.exe
to see what errors midl.exe reported.

ERROR_REPORTED_TO_USER

 

Details 

Click the link below to visit the Application Builder support page. Use the following information as a reference:

Error -2147221480 occurred at Compile DLL Stub.vi -> AB_Engine_DLL_Build_Stub.vi

This error code is undefined. Undefined errors might occur for a number of reasons. For example, no one has provided a description for the code, or you might have wired a number that is not an error code to the error code input.

Additionally, undefined error codes might occur because the error relates to a third-party object, such as the operating system or ActiveX. For these third-party errors, you might be able to obtain a description of the error by searching the Web for the error code (-2147221480) or for its hexadecimal representation (0x80040018).

 

Thanks & Regards

Varaprasath M
Certified LabVIEW Architect
Certified TestStand Architect
0 Kudos
Message 8 of 8
(3,123 Views)