NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

In Teststand, with "flexible dll prototype",


I want call a function Funct_1 include in the dll_Main.dll.
The source of the function Funct_1 is
containing in project1.dll,
and the project dll_main include the files
'project1.lib' and 'project1.h' (declaration of prototype).
But in the function ring control of the tab
'flexible dll prototype'
don't access at the function 'Funct_1'. the aim is to call only one dll from teststand
0 Kudos
Message 1 of 4
(3,152 Views)
Did you "export" the function?

int __declspec(dllexport) Funct_1(......)

You do not need a lib file to call the exported function from TestStand.

Plus if "Funct_1" sorce is included in "project1.dll" then that is the dll that you point to from TestStand and NOT "dll_Main.dll".

From the CVI manual

Import and Export Qualifiers
You can use the following qualifiers in variable and function declarations.

__declspec(dllimport)
__declspec(dllexport)
__import
__export
_import
_export

At this time, not all of these qualifiers work in all external compilers. The LabWindows/CVI
cvidef.h include file defines the following macros, which are designed to work in each
external compiler.

DLLIMPORT
DLLEXPORT

An import qualifier informs the compiler that the symbol is defined in a DLL.
Declarations
of variables imported from a DLL require import qualifiers, but function declarations do not..Chapter 1 LabWindows/CVI Compiler

An export qualifier is relevant only in a project for which the target type is Dynamic Link
Library. The qualifier can be on the declaration or definition of the symbol, or both. The
qualifier instructs the linker to include the symbol in the DLL import library.
0 Kudos
Message 2 of 4
(3,152 Views)
Hi,

If the function wasn't exported, then all that would happen is the step would produce a runtime error, as it would not be able to find the function in the DLL.

Suggest guillaume attach and example of the problem.

Ray
Regards
Ray Farmer
0 Kudos
Message 3 of 4
(3,152 Views)
Project1 contain :
******************

+ essai2.c :
------------
#include "tsutil.h"
#include "essai2.h"

extern void __declspec(dllexport) __stdcall essai2(CAObjHandle seqContextCVI, short *errorOccurred, long *errorCode, char errorMsg[1024])
{
int error = 0;

Error:
if (error < 0)
{
*errorOccurred = TRUE;
}

return;
}

+ essai2.h :
------------

#include "tsutil.h"

extern void __declspec(dllexport) __stdcall essai2(CAObjHandle seqContextCVI,short *errorOccurred, long *errorCode,char *errorMsg);



With the project create essai2.lib
essai2.dll

Project_main contain :
**********************

+ essai.c :
-----------

#include "tsutil.h"
#include "essai2.h"

int __stdcall DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
switch (fdwReason)
{
case DLL_PROCESS_ATTACH:

/* Respond to DLL loading by initializing the RTE */
if (InitCVIRTE (hinstDLL, 0, 0) == 0)
return 0;
break;
case DLL_PROCESS_DETACH:

/* Respond to DLL unloading by closing the RTE for its use */
if (!CVIRTEHasBeenDetached ())
CloseCVIRTE ();
break;
}

/* Return 1 to indicate successful initialization */
return 1;
}


void __declspec(dllexport) __stdcall essai(CAObjHandle seqContextCVI, short *errorOccurred, long *errorCode, char errorMsg[1024])
{
int error = 0;

Error:
if (error < 0)
{
*errorOccurred = TRUE;
}

return;
}

+ essai2.h :
------------
+ essai2.lib:
-------------

With this project create essai.lib
essai.dll

In testStand, when I call essai.dll, I see only the function 'essai' and not 'essai2'.
0 Kudos
Message 4 of 4
(3,152 Views)