Call Library Function (DLL) Node Configuration

This issue was discussed few times on this forum (see for example http://forums.ni.com/ni/board/message?board.id=170&message.id=182911 ),  but I still have a problem.
My question is -  how to define the call to DLL without to specify its full path in order to be able to change the directory path without to change all calls to DLL functions within VI.
So, I did:
1. I put my DLL and my VI in the same directory.
2. I defined this directory in VI search path. This directory also defined as enviroment variable.
3. I use only one call to DLL in this specific VI (just as example in order to simplify the problem).
4. I define only DLL name without the path in CLF Node.
But, every time when I close CLF Node configution window, the program search for the DLL, find it and put full DLL path inside.
I will be very thankful if anyone can help me to overcome this problem.
Best regards,
Boris

Hello Boris,
To sum up the previous posts, when you specify the DLL when configuring the Call Library Function
node, internally LabVIEW stores in the VI either 1) the name of the
DLL, or 2) a relative path from the VI to the DLL (including the name
of the DLL). What's displayed in the dialog (in 'Library Name or Path'
field) is either 1) the name of the DLL, or 2) an absolute path that is
formed by appending the DLL's relative path to the VI's absolute path.
In
case 1, LabVIEW uses the Windows system search paths to load the DLL.
That is, it looks for the DLL in \windows\system32 folder, then if not
found there, it uses the folders specified in the PATH environment
variable, etc.
In case 2, LabVIEW tries to load the DLL from the
computed absolute path (VIs current path combined with the relative
path to the DLL that LabVIEW stored internally). And if not found
there, LabVIEW uses the VI Search Path (that can be set from Tools »
Options in the category of Paths).
So even though LabVIEW automatically puts an absolute path to the DLL
in the Call Library Function Node, as long as you will specify the
correct folder for the DLL in the VI Search Path, you should be Ok. However, if you want to
have a fixed location for the DLL, then it is best to keep it in the
\windows\system32 folder, and specify just the name of the DLL when
configuring the Load Library Function node (this way LabVIEW will not
automatically turn it into an absolute path).
Also, these knowledge base articles might be helpful:
Why Does My VI Prompt for My DLL Every Time I Open It?
LabVIEW Searching for a DLL Used in the Call Library Function Node
My Stand-Alone Executable Cannot Find My DLL, Even Though I Have Specified the Path for the DLL
Hope this helps and good luck with your application!
Shakhina P.
NIC

Similar Messages

  • LabVIEW PDA reports COREDLL.DLL error when using Call Library Function Node

    I'm trying to build a LV PDA app that calls an external DLL file built using embedded visual C. When configuring the Call Library Function node I select the stub DLL, configure the I/O parameters and select OK. When the configuration dialog closes I get the following error:
    LabVIEW: LabVIEW.exe - Unable to Locate Component
    This application has failed to start because COREDLL.DLL was not found. Re-installing the application may fix this problem.
    I do not get this error when using the configuration dialog in the example VIs.
    Any suggestions as to the cause and/or the solution?
    Thanks,
    Ryan

    Hello -
    When you create a PDA VI that calls a DLL, you must include the .c or .lib file that corresponds to the DLL. Take a look at these documents:
    LabVIEW PDA Module Build Errors with VIs that Call DLLs
    Why Do I Receive Errors When Calling a C++ DLL from a Call Library Node Using the LabVIEW PDA Module...
    How To Call External Code in LabVIEW PDA for Palm OS
    H
    ow To Call External Code in LabVIEW PDA for Pocket PC
    Hope this helps!
    S Vences
    Applications Engineer
    National Instruments

  • Help to make opencv's dll and LabVIEW's Call Library function node understanding each others

    Hi, i have a little problem trying to use a C++ opencv's dll in labview. I wrote a really simple and stupid dll just to try to understand how it works the call library function node. Here the header code:
    #ifdef GENERICDLL_EXPORTS
    #define GENERICDLL_API __declspec(dllexport)
    #else
    #define GENERICDLL_API __declspec(dllimport)
    #endif
    #include "stdafx.h"
    #include <opencv2/core/core.hpp>
    #include <opencv2/highgui/highgui.hpp>
    #include <iostream>
    #include <string.h>
    #include <stdio.h>
    #include <opencv/cv.h>
    #include <opencv/highgui.h>
    // Questa classe è esportata da Generic DLL.dll
    class GENERICDLL_API CGenericDLL {
    public:
    int Summ(int a, int b);
    int Sott(int a, int b);
    int opencv(int a);
    // TODO: aggiungere qui i metodi.
     and here the .cpp:
    // Generic DLL.cpp: definisce le funzioni esportate per l'applicazione DLL.
    #include "stdafx.h"
    #include "Generic DLL.h"
    #include <opencv2/core/core.hpp>
    #include <opencv2/highgui/highgui.hpp>
    #include <iostream>
    #include <string.h>
    #include <stdio.h>
    #include <opencv/cv.h>
    #include <opencv/highgui.h>
    using namespace cv;
    using namespace std;
    // Esempio di variabile esportata
    GENERICDLL_API int nGenericDLL=0;
    // Funzioni esportate.
    GENERICDLL_API int Summ(int a, int b)
    return a+b;
    GENERICDLL_API int Sott(int a, int b)
    return a - b;
    GENERICDLL_API int opencv(int a)
    const string ind = "C:\\Users\\sviluppo\\Desktop\\Tuli.bmp";
    const string ind_2 = "C:\\Users\\sviluppo\\Desktop\\Tuli_Gray.bmp";
    //Mat image;
    return 5;
    i can call all the three simple functions in labview with this easy code. No problem at all. If i uncomment the line "Mat image;" the call library function node doesn't work and i receive the error:
    "The library specified for this node cannot be found or cannot be loaded. Right-click the Call Library Function node and select Configure, then choose the correct library name or path."
    I think that is a problem of dependencies between opencv libraries but i dont know how to manage this. Any ideas?
    Thank you for yours time,
    Francesco.

    Hello Francesco,
    I'm having exactly the same problem as you. I created a DLL that I can easily access from LabView. If I add one line and include "imgproc.hpp" (the only one I need), then LV gives me the same error you had. I read the thread Loura linked to, but I don't see how people actually take care of the dependecies (Klemen's examples did not work for me for the same reason, even though I recompiled the .cpp). Could you explain in detail what you did to make it work?
    Thanks

  • Passing Variant to dll using call library function node

    Hi,
    Using LV2012
    I have a dll that the following prototype:
    SetTestResult(LPCTSTR Serial, int Test, int Result, VARIANT measuredValue);
    How can I pass the Variant to this node when my variant can be either int or float.
    I have tried "ToVariant" function but it is not sending data and gets error 1517 on LabView. For configuration parameters for variant I have used ActiveX type and datatype as activeX Variant Pointer.
    So for call library function node my prototype looks like this:
    int32_t SetTestResult(CStr Serial, int32_t Test, int32_t Result, VARIANT  *measuredValue);
    Can someone help me understanding What am I doing wrong here please?
    Thank you,
    Hiren
    Hiren Patel

    Hello Hiren,
    Posting your code (even without the DLL) would definitely make it easier for people to point out potential issues.  Here is an example that demonstrates passing an ActiveX variant to a DLL built in CVI, I would suggest cross-checking the way the Call Library Function Node has been configured.
    Example:Transferring an ActiveX Reference Pointer to a CVI DLL
    http://zone.ni.com/devzone/cda/epd/p/id/3343
    Regards,
    Tom L.

  • Call a special function in the dll using Call Library Function Node????

    Dear all,
          I am calling a special function in the dll using call library function node. There is a input parameter that it is a enum type in this function. I don't know how to deal this parameter for calling this function.Has anybody solved this problem?Please advise!
          I am appreciated of you anytime. 

    Most of the times an enum is just a U8/U16/U32, internally so probably you can call it with just a U8/U16/U32 or something. For the correct value you have to look at the definition.
    Ton
    Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
    Nederlandse LabVIEW user groep www.lvug.nl
    My LabVIEW Ideas
    LabVIEW, programming like it should be!

  • DLL C/C++ syntax for Call Library Function Node

    Hello,
    I am interested in calling DLL from Labview and found several intersting tutorials on the Call Library Function Node. One interesting tutorial is Building a DLL with Visual C++ http://zone.ni.com/devzone/cda/tut/p/id/3056
    One can notice in the example presented in this tutorial that the parameters that are outputs of the exported function are of type pointers. And I am curious about the theory behind this. 
    I looked also at the example in LabVIEW Call DLL.vi and it seems that all outputs are pointers to the desired data type.
    I tried to write a short code where I assign a new value for one parameter in the export function. But this value is not updated in Labview. To make it clear: assume 50 is passed to an input parameter (on the left side of the Call Lib func Node). In the function, i assign 100 to this variable and expect this value on the output in Labview (right side indicator of Call Node) but the output remains 50.
    I am trying to change my code but i get errors in linking (compiling is ok) that I cannot understand. LINK : fatal error LNK1168: cannot open Debug/DoseDLL.dll for writing
    Error executing link.exe.
    I don't get any error with the code provided in the above tutorial   so i am trying to reproduce a similar code...
    Thank you

    Hello,
    Please find attached the source code in C, the DLL and the vi. 
    you notice in the C code that I set variable dose=100 and this is the value I would like to export as an output for labview (right side of Node) for whatever value in the input (i put 50 for input dose). In the current code, the same value of input dose (50) is passed to the output (i assume it has to do with the reference ?). The idea is that variables dose and rate should be set/calculated in the DLL function. 
    Thank you!
    Attachments:
    DoseDLL3.cpp ‏1 KB
    DoseDLL.vi ‏8 KB

  • When I use Call Library Function Node in real time, is the DLL loaded once for all or load every time it is called?

    When I use Call Library Function Node in real time, is the DLL loaded once for all or load every time when it is called?
    I have a time critical real time application, in which I use a piece of DLL function developed by C++.  It is OK?  Could any senior developer assure me?
    Thank you in advance.
    Solved!
    Go to Solution.

    qing_shan61 wrote:
    When I use Call Library Function Node in real time, is the DLL loaded once for all or load every time when it is called?
    Once
    qing_shan61 wrote:
    I have a time critical real time application, in which I use a piece of DLL function developed by C++.  It is OK?
    OK
    Be sure that all DLL calls are thread safe (do not perform calls in UI thread).
    Also for real-time application you need real-time OS.
    Andrey.

  • Window doesn't close wheh Call Library Function Node set to Run in Any Thread

    This is a problem regarding Call Library Function Nodes running in the UI thread or any thread.
    I have a camera which has its own API supplied as a dll. I have created a set of VI wrappers which each call a function in the dll through a Call Library Function Node.
    Initially each CLFN was set to 'Run in the UI thread' (the default).
    To start the camera streaming images I call (through a CLFN)
    ICubeSDK_Start(int CamIndex, Hwnd, ImgHandle, bool Preview, bool callback);
    If Preview = True then the image is displayed in a preview window.
    If ImgHandle = NULL a default preview window
    is used.
    In the CLFN definition I define:
    ImgHandle as a U32
    Preview as a I32
    To stop the camera streaming images I call
        ICubeSDK_Stop(int CamIndex)
    In the actual implementation I set ImgHandle = 0 (NULL) and Preview = 1 (true).
    This all works fine, and a preview window is opened and images displayed. When I call ICubeSDK_Stop the preview window is closed.
    However, I would prefer to set the CLFN to 'Run in any thread' because
    a) when run in the UI thread the preview window randomly gets sent to the back when I switch focus between open VI windows (presumably because it is in the same thread as the VIs)
    b) I don't want to put unnecessary stuff in the UI thread
    c) my (naive?) understanding is that it is safer to run in any thread
    So I have set all CLFNs to 'Run in any thread'
    When I do this the preview window opens OK, and behaves like any other non LabVIEW controlled window in terms of focus. But when I call ICubeSDK_Stop() the preview window does not get closed properly, it just shows a blank image. I can't close it manually, there is no X in the corner and no option to close it from the taskbar. To get rid of it I have to close the LabVIEW project it is spawned from, which often results in a crash. It does appear as a separate item in task manager but if I 'end process' it, LabVIEW closes (and often crashes) as well.
    If I change only the CLFNs that call the Start and Stop functions back to 'Run in the UI thread' then it all works fine again, except that the preview window gets sent to the back randomly as before.
    So, what do I have to do to get the preview window to close properly if I set the CLFN to 'Run in any thread'.
    Alternatively, is there a way to close the window programmatically (ie force it to close) after I have called ICube_Stop.
    Thanks
    DAve

    Hi Dave,
    The "Run In UI Thread"  switches from the thread the VIs currently executing in to the user interface thread. If you select "Run in Any Thread", the Call Library Function Node continues in the currently executing thread. By default, all Call Library Function Nodes run in the User Interface thread.
    Before you configure the Call Library Function Node to run in any thread, you have to make sure that the code is thread safe. Code is thread safe when it does not store any global data (e.g. global variables, files on disks, etc.), does not access any hardware, does not make calls to any functions, libraries or drivers that are not thread safe.
    Unfortunately, since you said that your DLL accesses hardware, it is not recommended to use "Run in Any Thread." This is probably why you are seeing the crash.
    If your preview window gets sent to the back you can programmatically bring it forward. Here is an example of how this can be done: http://decibel.ni.com/content/docs/DOC-4551
    If you want to completely close the window down you can do so as described in this link: http://digital.ni.com/public.nsf/allkb/81E9C144190​0FFCE8625748F0055DBB0?OpenDocument
    I also thought you might find this useful: http://zone.ni.com/devzone/cda/tut/p/id/3009
    I hope this helps.
    Regards,
    Mahdieh G
    Applications Engineer
    National Instruments UK&Ireland

  • PDA: Calling library functions - seems to link the stubbed .cpp file instead of the DLL

    I'm having trouble developing a Lab View PDA module that calls a DLL built using Visual C++. The DLL functions correctly when called in a non-PDA VI. My issues seem to be with porting to the PDA.
    My configuration:
    - Lab View 8.5 with the PDA 8.5 module
    - Visual Studio 8.0 with the Windows Mobile 6.0 SDK
    - ASUS 626 PDA with an Intel PXA70 procesor running Windows Mobile 6 Classic
    Following the PPCBatt example code provided with the PDA module, I have:
    - used extern "C" to prevent name mangling
    - placed the DLL built with the Windows Mobile SDK in the \Windows directory on the PDA
    - created a stub Win32 DLL and lib
    - created a stubbed cpp file whose functions only return zero
    - included the stubbed cpp and lib files in the build spec / source files / additional files
    - placed Call Library Function nodes on my PDA VI, selected the function names, set the parameter types
    - built and deployed the executable, both with and without debug
    When I set the library path property of the Call Library Node, the functions appeared in the function name pulldown, but the parameters did not populate. I had to manually add them and set their types. The help page says they would autopopulate when the function was selected.
    I've debugged the VI, and the Library Function Call nodes are being called. It seems the build is linking the code from the stub C file provided in the additional files portion of the source files property page, instead of adding hooks to call the DLL on the PDA. As a test, I changed an output parameter in one of the functions in the stubbed cpp file - the changed value showed in the front panel indicator.
    What am I doing wrong?
    Dan

    Hi Dan,
    I'm not sure if I understood you problem fully. When calling external code with LabVIEW PDA, the DLL acts as a stub DLL with the correct function prototypes for the C code that you want to call. Here's a Knowledge Base article that might help explain about calling External Code in LabVIEW PDA.
    Regards,
    Stanley Hu
    National Instruments
    Applications Engineering
    http://www.ni.com/support

  • Call library function node: function not found in library

    I'm using Labview 6.1 and Windows XP.  I am trying to open some code, but it opens up with a broken arrow.  The error is Call Library Function Node:function not found in library.  Tried to configure the node, but no change.  Moved the DLLs to various directories (keeping them together) but again no change. 
    This code has been compiled and is working fine.  I'm just trying to run the source code to make some modifications.  Any suggestions? 
    Thanks
    CarlosV

    Thanks for the suggestions.  Tried it but had the same results.  The library I'm using is hpe1413_32.dll. 
    One thing I forgot to mention....doing a configure on the node, it comes up with the library: hpvscp32.dll and the function: hpe1413_error_message
    The function doesn't exist in the library.  So I set the path to hpe1413_32.dll which does contain the function. 
    After closing the configuration window and opening it up again, the library shown is hpvscp32.dll
    From what I can tell, there are three libraries involved:hpe1413_32.dll, hpe141332v.dll, and hpvscp32.dll
    Thanks again.
    Carlos

  • Is a call library function node in LabView 8.6 synchronous or asynchronous?

    I tried setting a sub-VI with a call library function node in it to "subroutine" execution status.  The error list indicated that the Call Library Function node in the block diagram was an asynchronous node.  The LabView on-line help content indicates
    "...CINs and shared libraries execute synchronously, so LabVIEW cannot use the execution thread used by these objects for any other tasks. "
    Does anyone know for sure what the status of a Call Library Function is?  Does it depend upon the specific code in the DLL being called?
    Thanks,
    Mike H.

    Based on the help page it looks like it should execute asynchronously.
    The thing in the description that leads me to believe they execute asynchronously is that you can configure the library to run as a multi-threaded operation.
    Please take a look here to see the difference between synchronous and asynchronous execution.
    Since the code even has the ability to be multi-threaded, you can consider it as running in parallel to your other code.
    Any data returned is passed to the thread that called that function.
    Cory K

  • Use call library function node

    I try to use call library function node to call a function in DLL and retrieve info stored in the C structure data type, can I do it? If yes, how ? Thanks.

    Have a look at the article Configuring the Call Library Function Node

  • [HELP] Call Library Function Node...

    I have a DLL which has a function as follows:
    int GetMessageNameNumber (char* messageName [], const int MessageNumber);
       The function is used thus:
    char *MessageName = NULL;
    int MessageNumber = 0;
    error = HL1553API_GetMessageNumberName (&MessageName, MessageNumber);
    MessageName will then contain the message name as a string.
    I having the devils own job trying to wrap this into a Labview module.  I have a Call Library function node for the above function, but I am not sure what to set the "MessageName" parameter too!  I have tried Array of signed 8-bit integers, Adapt to Type, Array Data Pointer and then passed in a String array.  Whatever I do results in LabView crashing.  I know HL1553API_GetMessageNumberName works, because if I call it directly in TestStand it works fine.  I need it LabView though!
    Any ideas?
    Christopher Povey
    Senior Test Systems Engineer for BAE Systems.
    Solved!
    Go to Solution.

    In C a pointer to a string or an array of strings are completely ambigues.
    char ** something    =====   char  * something [].
    You can not tell the two apart from the syntax but only from the documentation or from an example showing how the function is called. A C compiler treats the two equal in terms of access (but a C++ compiler will make a syntactic distinguishment when syntax checking code, resulting in possible compile warnings when prompted to use a sufficiently high warning level.)
    The sample shows that this is not an array of strings that gets allocated by the caller and passed to the function, but a string pointer that gets passed by reference. As such the function will allocate a pointer and return it (a highly non-standard C practice at least for strings). This automatically begs the question when and how will this pointer be deallocated? The documentation for that function should document the memory manager call used to allocate that pointer and also point out the function to call to deallocate it. Ideally the library (DLL) provides a specific exported function for that purpose.
    Assuming everything I have talked about so far is clear and available you have to trick LabVIEW a bit. You have to configer a pointer sized integer that gets passed by reference. Now this integer in the diagram IS in fact your string. If you only need to pass this pointer to other Call Library functions you are already done. Otherwise if you need to access the contents of that string from the LabVIEW diagram, you have to copy the information of that string pointer into a real LabVIEW string.
    One way to do that is to use the MoveBlock() C function export that LabVIEW exports itself. I have explained this several times here on this forum and a search for MoveBlock will without doubt uncover those posts.
    Another slightly better way is to use the LStrPrintf() function that LabVIEW also exports. For that you configure a Call Library function as follows:
    Library name: LabVIEW
    Function name: LStrPrintf
    Calling convention: C
    Threading: both are possible but the function is thread safe so just use reentrant
    return parameter: int32 (this is a possible LabVIEW manager error code)
    1st parameter: LabVIEW string handle, passed by value
    2nd parameter: C string pointer
    3rd parameter: pointer sized integer, passed by valu
    Wire an empty string constant to the first parameter.
    Wire a constant containing the text "%s" without quotes to the 2nd.
    Wire your string pointer to the 3rd
    On return the function will either return 0 as return value and the contents of the string on the output side of the 1st parameter or a non-zero return value indicating an error.
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • How to call a C pointer from call library function node

    I have a client/server application which the client I am trying to develop using Labview.  When I use to communicate the server and the client using the program provided by the manufacter, the system works perfectly.
    Now, I am trying to develop a system using labview, because I need to get another things.
    I have the DLL provided by the manufacter and the .h too, so I can check the functions parameters. One of these functions needs to be called using a struct element. Probably, the function's DLL instantiates the elements of this struct.  I use the call library function node to do it.
    When I receive the data, the function returns to me the struct that I passed as a parameter before, and then I can read all the elements of the struct, except the string element that returns nothing. The struct elements that are numerical, I can read them perfectly.
    Another thing that is important to say, is that the string data was not returned in fact by the DLL function that the system calls. I have to pass a pointer (I use it as unsigned 16 in Labview, but I tried before as string and unsigned 8) as a parameter, and this pointer will point to the memory location that the string is. When I try to read what is returned by the function, I can read nothing. The same function returns that the size of data that is returning is 17 bytes.
    How can I solve it?
    Thank you in advance

    Did you take a look at the example that ships with LabVIEW that shows how to do all sorts of data passing to DLLs. I believe your situation is one of the examples listed. You can find the example VI in the "<LabVIEW install directory>\examples\dll\data passing" directory.

  • Call library function node in a loop

    Hello All,
    I am currently using a call library function node in a while loop which calls a third party dll to process and recieve some data.
    My question is, if I am using this function in a while loop, what exactly happens?
    Does the dll get called in each loop iteration, or does it keep the called dll loaded in memory and just pass the values to it to process data?
    Also, if the answer to the above question is that it will make calls to the DLL in each iteration, how can we keep it loaded in memory always? I mean, if the DLL is a .NET application DLL, I believe the main .NET application which uses this DLL won't do multiple calls to the dll, rather it will keep it loaded in memory.
    Thanks
    FraggerFox!
    -FraggerFox!
    Certified LabVIEW Architect, Certified TestStand Developer
    "What you think today is what you live tomorrow"

    Hi,
    the DLL will stay in memory as long as there is a program running which has not closed (unloaded) the DLL.
    Doing repetitive calls to the DLL is irrelevant in this context. LV opens the DLL as soon as needed and will only unload it when there is no VI in memory which has a CLN to that DLL...
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

Maybe you are looking for

  • My safari wont open it keeps saying it quit unexpectedly

    My safari wont open. when i press the icon a message pops up and says it quit unexpectedly. we keep pressing the icon and the message keeps popping up. weve tried everything. also we just got it back from apple, they've replaced our hardware but all

  • Unique constraint on an indexed field

    I have a table with ALOC and ZLOC fields. They are starting points and destinations, respectively. If you can imagine a circuit, however, they represent the same wire whether the ALOC comes first or the ZLOC. New circuits come in and are inserted wit

  • Help Please w/Internet Connection

    MACBOOK   Mac OS X (10.4.8)   Hi all! Purchased new MB 3 weeks ago. After 3 weeks of major issues connecting to internet via Linksys Router not to mention it messed up my mother's ability to connect to internet, I am beyond frustrated. So frustrated

  • Error in calling method of loaded swf

    I have two classes. One is loading class and another is Main2 class. Loading class is our document class of Load.fla. The code of loading class is: package           import flash.display.MovieClip;           import flash.display.SimpleButton;        

  • Performance on a MacBook Air?

    Hi all, I'm looking to buy a new Mac notebook computer, and I am trying to figure out what to buy. I'm currently a PC user but will make the switch to a Mac. Right now, I'm running an HP DV6 with 4GB of RAM and I think it's about 2.0 GHz. It's excruc