취소
다음에 대한 결과 표시 
다음에 대한 검색 
다음을 의미합니까? 

Linking C++ DLL into LabVIEW

해결 완료!
솔루션으로 이동

Hi,

 

I am suffering about linking a DLL into LabVIEW. I am using LabVIEW 2014 32-bit and generating my DLL in Visual Studio Express 2013. I am using Import Library Wizard (Tools->Import->Shared Library), I select DLL file and header file, I click next, and getting error "The Import Shared Library tool cannot get exported function names ....." as pictured below.

 

I read lots of topics in Forum about DLL importing, but I could not solve my problem.

What am I doing wrong?

 

Thanks.

 

import_error.PNG

 

 

commdll.hpp

CPP_Header.PNG

 

comdll.cpp

CPP_Source.PNG

 

 

If I select I get only 3 functions, the function Addition is not listed as pictured below:

 

import_error2.PNG

 

import_error3.PNG

 

And of course it does not work.

import_error4.PNG

0 포인트
1/14 메시지
10,871 조회수

I've you tried to disable the name mangling when compiling your *.dll?

 

Michel

0 포인트
2/14 메시지
10,820 조회수

In my experience, I have instantiated my class in global space and wrapped the object's class methods inside global space functions as shown below.  And when you build this, make sure you tell your compiler to set the BUILDING_EXAMPLE_DLL flag (i.e. CXXFLAGS   = -DBUILDING_EXAMPLE_DLL) 

 

example_dll.h file:

#ifndef EXAMPLE_DLL_H
#define EXAMPLE_DLL_H

	#ifdef __cplusplus
	extern "C" {
	#endif

		#ifdef BUILDING_EXAMPLE_DLL
		#define EXAMPLE_DLL __declspec(dllexport)
		#else
		#define EXAMPLE_DLL __declspec(dllimport)
		#endif

		double EXAMPLE_DLL Addition(double a, double b);

	#ifdef __cplusplus
	}
	#endif

#endif // EXAMPLE_DLL_H

example_dll.cpp

#include "example_dll.h"
#include "MyMathFuncs.h"

/*
 * An example of shared (global) data
 *
 */
MyMathFuncs myMathFuncs;

double Addition(double a, double b)
{
	return myMathFuncs.Addition(a,b);
}

 

0 포인트
3/14 메시지
10,815 조회수
솔루션
주제 작성자 kahlenberg이(가) 승인함

Have a look at this whitepaper: http://www.ni.com/white-paper/3056/en/ for building a C++ dll. The example code is helpful too.


CLA CTAChampionI'm attending the GLA Summit!
Subscribe to the Test Automation user group: UK Test Automation Group
0 포인트
4/14 메시지
10,796 조회수

LabVIEW cannot do anything with a C++ class in a DLL, including import functions contained in a class. Any function you want to call from LabVIEW must be a standard C function. You need to rewrite your DLL without classes, or wrap the classes in standard C functions.

0 포인트
5/14 메시지
10,780 조회수

Thanks, I followed that white paper, I deleted class and implemented everything as C functions, it works now.

0 포인트
6/14 메시지
10,706 조회수

I've got a similar problem, witha dll.h like this:

 


/*------------------------------------------------------------------------------------------*/
/* Exported DLL Functions */
/*------------------------------------------------------------------------------------------*/
#ifdef _cplusplus
extern "C" {
#else
#ifdef __cplusplus
extern "C" {
#endif
#endif

 

LONG __stdcall MY_Create(char * Device);

 

(all functions are declared like this)

 

Wizard don't find anything. Why?

Thanks

0 포인트
7/14 메시지
10,488 조회수

If you attach the .h file to a message here, then someone else can try running the import wizard with it and see what changes you would need to make to the file in order for the wizard to be able to import it. Or, you can simply configure the Call Library Function Node calls yourself for the functions you want to use, and skip the wizard. Possibly you need to set the include path so that the wizard can find some other header that's referenced.

0 포인트
8/14 메시지
10,479 조회수

I haven't been truly:

 

Wizard find functions in DLL but not in header file of which I attached the very first part.

0 포인트
9/14 메시지
10,449 조회수

Again, can you attach the full .h file so other forum users can try running the import wizard on it, to see what the problem might be?

Have you tried configuring the call library function node manually, rather than relying on the wizard?

 

0 포인트
10/14 메시지
10,420 조회수