LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

import dll

I am trying to import a dll. All of it. I will need almost all of the functions. I have tried using the Import Library Function Node, but I realized that it is very time consuming. Also, there are functions spanning too many different header files. so I am trying to use Tools -> Import -> Shared Library (.dll). I get stuck with preprocessor directives. I am posting step by step:

 

1.png

 

2.png

 

3.png

 

The message for the first function is:

The function cannot be imported into LabVIEW. This might be caused by one of the following problems:

The function is not declared in the header file but is exported in the library.

Check the header file to make sure it contains declarations of the function.

Undefined symbols can prevent the wizard from recognizing functions and parameters. To correct this problem, check the header file to determine if you must add preprocessor definitions. Click the Back button to return to the previous page of the wizard to add a preprocessor definitionsl (for example, "NIAPI_stdcall = __stdcall" or "NIAPIDefined = 1").
GENAPIC_EXPORTS;GENAPIC_LINUX_BUILD;GENAPIC_WIN_BUILD;MIDL_PASS;MRTDLL;PYLONC_BOOL_DEFINED;PYLONC_EXPORTS;RC_INVOKED;UNALIGNED;_CRTDBG_MAP_ALLOC;_CRT_ALIGN;_CRT_ALTERNATIVE_INLINES;_CRT_DISABLE_PERFCRIT_LOCKS;_CRT_FORCE_MANIFEST;_CRT_GETPUTWCHAR_NOINLINE;_CRT_MANAGED_HEAP_NO_DEPRECATE;_CRT_MANAGED_HEAP_NO_WARNINGS;_CRT_MANIFEST_DEBUG;_CRT_MANIFEST_INCONSISTENT;_CRT_MANIFEST_RETAIL;_CRT_NOFORCE_MANIFEST;_CRT_NONSTDC_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;_CRT_NON_CONFORMING_SWPRINTFS;_CRT_OBSOLETE_NO_DEPRECATE;_CRT_OBSOLETE_NO_WARNINGS;_CRT_SECURE_CPP_OVERLOAD_SECURE_NAMES;_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES;_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES_COUNT;_CRT_SECURE_DEPRECATE_MEMORY;_CRT_SECURE_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE_GLOBALS;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS_GLOBALS;_CRT_SECURE_WARNINGS_MEMORY;_DEBUG;_DLL;_MSC_EXTENSIONS;_MSC_VER;_MSC_VER_GREATER_THEN_13102050;_MT;_M_AMD64;_M_CEE;_M_CEE_MIXED;_M_CEE_PURE;_M_IA64;_M_IX86;_PFT_SHOULD_CHECK_RETURN;_PFT_SHOULD_CHECK_RETURN_WAT;_PFT_VER;_POSIX_;_PREFAST_;_STATIC_CPPLIB;_TRUNCATE;_USE_32BIT_TIME_T;_USE_ATTRIBUTES_FOR_SAL;_VC_NODEFAULTLIB;_W64;_WIN32;_WIN64;_X86_;__BORLANDC__;__CRTDECL;__GNUC__;__cdecl;__cplusplus;__cplusplus_cli;__linux__;__midl;

 

Most of these should be undefined. For example, there is:

 

#ifdef GENAPIC_EXPORTS

//do A

#else

//do B

 

And I want it to do B. But this is complaining that GENAPIC_EXPORTS is undefined... How to get around that?

 

I am attaching PylonC.h file which I think is enough to help me. The rest of the whole api is available on basler's website: http://www.baslerweb.com/MV_Customer_Service_Downloads_pylon-Linux-Text-16855.html. I am using Pylon 3.0 64-bit , C version.

 

 

0 Kudos
Message 1 of 6
(3,875 Views)

you forgot to add the genapi include directory path in the second step. Your include file references this here:

 

#include <genapic/GenApiC.h>

 

And don't try to generate wrappers for DLLRegisterServer and DLLUnregisterServer.

 

And last but not least, don't expect the Import Library Wizard to create magic. It can create the DLL caller VIs for you but it can not guess at how this API should be used. A C header file only gives information about how to link to the function, but none at all about how to use it. A LabVIEW VI usually also implements quite a bit about how the API is used (preparing parameters such as preallocating output buffers, etc) that is really impossible to deduce from the header file alone. It's what a C programmer continously has to worry about when calling functions and since you are incorperating this API into LabVIEW you have to worry about it too. Otherwise it will just cause exceptions.

 

So you will have to go through every and each VI and check it for such problems, which is really the hard work. Creating the VIs that call the functions with Call Library Nodes may seem like a lot of work, but once you have done one or two it's absolutely trivial in comparison to the real hard work that the Import Library Wizard can't do for you at all.

 

Rolf Kalbermatter
My Blog
0 Kudos
Message 2 of 6
(3,857 Views)

Not really, no.

 

GenApiC.h is located at:

C:\Program Files\Basler\pylon 3.0\pylonc\include\genapic\GenApiC.h

 

Thanks for the reply though!

0 Kudos
Message 3 of 6
(3,845 Views)

I believe what rolfk meant was that you included "C:\Program Files\Basler\pylon 3.0\pylonc\include\" but not "C:\Program Files\Basler\pylon 3.0\pylonc\include\genapic\" and LabView probably does not check sub directories.

 

Regards,

 

Pedro

0 Kudos
Message 4 of 6
(3,840 Views)

@elsayed3 wrote:

Not really, no.

 

GenApiC.h is located at:

C:\Program Files\Basler\pylon 3.0\pylonc\include\genapic\GenApiC.h

 

Thanks for the reply though!




Well ok! But do any Pylon.. functions occur in the list in the second screenshot? For instance PylonEnumerateDevices()? Screenshots are nice but as you can see they often don't show much to do more in depth analysis. If these functions don't occur in the list you got the wrong DLL. If they do occur you have to analyze the rather convoluted preprocessor defines to find out which of them may be needed to let the parser see those function definitions.

 

And the error message is not complaining that GENAPIC_EXPORTS is missing, only that it couldn't find any function declarations in the header file that match any of the exported functions in the DLL and that this might be caused by the lack of a preprocessor define, listing all the conditional preprocessor defines it had encountered during the parse.

Rolf Kalbermatter
My Blog
0 Kudos
Message 5 of 6
(3,833 Views)

I gave up on using the dlls. I decided to use a completely different method. I am not using the api anymore, but rather, I am directly accessing the camera's registers. I had initially thought that using the dlls would be easier, but the direct register access wasnt too cumbersome. Working fine now.

 

Thanks

0 Kudos
Message 6 of 6
(3,802 Views)