LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

lib file

Hi,

 

I would like to know if it's possible to load a lib file dynamically!

 

Example : testA.lib has 2 functions.

                 testB.exe uses a function in testA.lib.

                 I add a message poppup in testA.lib then recompile testA.lib.

                 testB.exe doesn't show up the message poppup unless I recompile testB.exe.

 

I would like to not have to recompile testB.exe to see the message poppup from testA.lib

 

Thanks

0 Kudos
Message 1 of 2
(2,953 Views)

hi,

    Static Lib files is linked to executable at compilation time, cannot be changed at run-time.

    I think you need use Dynamic link library - DLL.

 

    Create new or change your library project to Build->Target type->Dynamic link library.

    You also need to select header file with exported functions in Build->Target settings->Export (button change).

    After compilation you get *.lib and *.dll file.

    This Lib file is used in the same way as clasic static library but instead of contain program code, this one cause load functions from .DLL at executable startup.

    The dll file need to be distributed with apllication in the same directory like .exe file.

   

    There are some information CVI help for DLL.

 

Note 1:When using DLL you do not need to recompile your executable as long, as you do not change function parameters.

 

Note 2:When using .lib for connect .exe and dll, newly added function is not accesible until compilation with new lib. Instead of lib file you can use function LoadLibrary and
  GetProcAddress. Then you can call any function in dll without recompilation as long as you know its parameters. CVI has built-in feature for creating this .c file from header and  DLL files.Just open header file and then go to menu Options->Generate DLL import source.Still with this, the executable need correct function prototype(parameters, call type)  and name for use new functions.

 

Note 3: there are obsolete function LoadExternalModule which can load .lib files at runtime but i do not recommend it, it is some sort of incompatible and nonstadard way to do.

 

Message 2 of 2
(2,940 Views)