Call library function not finding DLL in directory where my LLBs are

I am using LabVIEW 8.6.  I have a set of VIs in several LLBs.  All the LLBs are in one directory.  Most of my VIs are wrappers for the functions in one DLL.  I was told to put my DLL in the directory where the LLBs are, and supposedly this is how the previous programmer worked (using an earlier version of LabView). 
In the Call Library configuration, I have specified <dllname>.dll without a path.  (This is how we want it as our VIs are an API which other programmers will integrate, so I don't know where they will put things and I can't use any absolute paths).
When I load the VIs in LabVIEW, LabVIEW can't find the DLL and asks me to located it.  It is right there in the directory with the LLBs and when I double click on it everything works fine.  However my absolute path to the DLL now appears in the Call library configuration, and we don't want that.
Does anyone know how to make this work?  I would assume that the location of the VIs (or LLBs, in this case) would be the current directory and thus Windows would look there for the DLL.  However, it seems that this is not the case (at least, in the current version of LabVIEW).
Thank you.
Batya
Solved!
Go to Solution.

rolfk wrote:
Well somebody using your library should not have to dig into your VIs and do all this on his own. Instead your library should wrap that and hide the troubles of this entirely.
 That is EXACTLY what I want to do.
The error cluster was added when the dynamic path option was added. It is not useful to hide that error output so it is always there. Together with the dynamic path there was improved error handling added to the CLN. One of them is that the level of error checking during the function call (exception handling) can be specified. I would assume that some of those options can generate an error code instead of popping up a dialog as they did before and for that the error code output can be useful even in the static call case.
As to what you want to do, I would long ago
I would long ago have done a lot of things differently on this project -- but no one asked me then :-)  (Good thing it wasn't me, or maybe I'd have taken offense ;-)  )
have handled that with a wrapper DLL that has basically the same functions as your other DLLs and some initiliasation function that returns a pointer to a function dispatch structure based on the actual DLL you want to call.
OK, I am getting the feeling that this will be a brilliant and elegant solution when I fully understand it.  I understand what a wrapper DLL is.  But do you mean that each version of my product would include a different wrapper DLL (with the same name so that CLN would always work), or the same one and it would somehow be told which actual DLL I want to call?  Who would decide which DLL, the VI or the wrapper DLL?
By a function dispatch structure do you mean a table of function pointers gotten by GetProcAddress, one such entry for each function?
Quite like what an object oriented function dispatch table is. Then when initilising your interface you call that initialise function and specify the interface/device type you want to use and after that all the other functions take one additional function dispatch pointer parameter as first parameter in addition to the parameters the actual function has. This function dispatch pointer would be just a pointer to a structure containing the table of function pointers for that interface and for the sake of LabVIEW would be simply a pointer sized integer.
The wrapper function then verifies the function dispatch structure pointer for validity and calls the actual function with the remaining parameters.
I think I understand what the wrapper functions need to do.  But I am missing some pieces for the initialize function.  It would have to do LoadLibrary and lots of GetProcAddresses -- that much I get.  But I still don't understand who decides which DLL.  Maybe you mean that the wrapper DLL's initialize function will get the DLL name and path from the registry, load it, try a different path if the load fails, etc.  Is that what you mean?  That could work very nicely.   But from where would it get the registry key?  From the VI?  This is the part that would clearly be different for each product.  I suppose that you had something in mind when you described your solution. 
This is some C programming
Great!  That's what I do for a living.  At least I know how to do that!  Hey, I should have thought of this idea! 
and might require some planning and desigining of the different interfaces to facilitate this kind of dispatch technique but it will for sure pay of in the long run, and make your library even usable in earlier LabVIEW versions, as well as VB etc. without tricky dynamic loading in the high level programming environment.
Ah, see how much I don't know in LabVIEW?  I didn't know this was a new feature...
Thank you for the great idea.
Batya Perlman

Similar Messages

  • Using call library function on a dll file created in an old version of labview

    So I'm trying to update an old labview program to work in labview 2012. Everything converted over just fine but labview will always crashoverwrote some while using a  library function in a DLL that was compiled using labview 8.5. Labview exits, stating that it vital memory area. It passes an array of data to the library call and an empty array for output. I thought I could get around this problem by changing my code to initialize the array being passed in so that it would be large enough to hold all the expected output. Now instead of overwritting areas of memory it shouldn't, I get a pop up message that says:
    fatal internal error
    memorymanager.cpp line 406
    8.5.1.f5 
    So it appears because I don't have the ability to recompile the DLL file it runs off of the 8.5 runtime instead of the more recent one. Is there any thing I can do about this?

    rjpierce wrote:
    So I've been trying to figure out a way around this on my own while waiting on a response. From what I'm reading, a dll created in one version of the labview runtime can't be used by a different labview runtime. Am I correct in this? I feel like I must be mistaken since that's basically the opposite of how a dll should work. If nothing else works I have access to the original code for the DLL but it requires the control and simulation toolkit. I would like to avoid having to recompile the DLL since it was put in to a DLL to avoid the need for the toolkit to begin with. 
    Your problem most likely is that you try to pass native datatypes to the DLL function? That only can work if the caller and callee use the same LabVIEW runtime engine. Otherwise the memory block created in the memory manager of the caller will be accessed by the memory manager in the callee and bad things happen. Instead you should define the DLL function to use standard C datatypes (Pointer to C array) and also make sure to allocate the according buffer in the caller for all output array parameters.
    An even more elegant way would be to completely abandon the DLL approach and call the according functions directly in LabVIEW. Then you won't have the problems about mismatched runtime engines. Passing C array pointers to a DLL is less performant than passing native datatypes, but if you use native datatypes you have to make sure the DLL is compiled in the same LabVIEW version as the one you call it from.
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • What are analogous shared libraries that can be called using a call library function to user32.dll and lvtoolbox.dll when using Linux and Mac?

    I am wondering if anyone is familiar with how to get similar information with a LV program using a Linux shared library as well as the corrolate Mac library to the Windows user32.dll and lvtoolbox.dll.  I specifically am trying to get system metrics such as screen resolution information and cursor information as well as being able to set mouse position.   I am trying to convert a LV Windows program to these other operating systems and I am unfamiliar with these platforms.
    Thanks for your time - I really appreciate it.

    There is no simple answer to that. On Linux you will likely have to call into X Server, which would be a pain to do, due to various versions and implementations of that. On the Mac there would be the difficulty that you can't call into the native ObjectiveC API but would need to find a Carbon API or something like that to do what you want.
    If you seriously want to do something like this for multiplatform, you should bite the bullet and start coding an intermediate shared library in C. This library would export a LabVIEW friendly C API and access whatever system API you need to have for the particular functions. But multiplatform programming on this level is a pain in the ass, no matter what.
    Message Edited by rolfk on 04-21-2010 08:26 AM
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • I have an 2.4 Mac Book Pro.  I want to wipe it clean and reinstall the Lion OS I bought from the App Store.  I looked for instructions but did not find them any advice where the instructions are would be appreciated.  Thanks

    I am looking for help on how to or where I can find information on how I can clean my hard drive and then reinstall Lion,  Thanks

    Boot from Recovery HD upon startup hold-down keys Command R . Until you see the Apple logo then select language:English.click the Arrow (Next)
    From the OS Utility, select Disk Utility then click Macintosh HD. click the Erase tab on the right side.
    Format:Mac OS Extended(Journaled)
    Name:Macintosh HD
    And click Erase
    Once Erase process is done, close Disk Utility and select the second option in the OS Utility which is Reinstall OS. Let it run. It should take about an hour to complete, this type os installation is internet dependent so somehow the completion of the process depends on internet speed as well.

  • Call library function node - function not found

    When creating a DLL I get a the Labview error "Call Library Function Node "LabviewReceiverDLL.dll:readDataJ1939Data' Function not found. Everything looks correct to me and this used to work, though I've changed computers since then.
    This is the beginning of my C++ code just to show my function name. I've also attached the Call Library Function Window to show my setup.
    Thank you in advance for your help.
    #include"StdAfx.h"
    #include<iostream>
    /* Call Library source file */
    extern"C"__declspec(dllexport)unsignedint readDataJ1939Data(unsignedint, unsignedint, unsignedchar, unsignedchar* canData, unsignedchar* path);
    unsigned int readDataJ1939Data(unsignedint ulTimeStamp, unsignedint ulIdentifier, unsignedchar uiDataCount, unsigned char* canData, constchar* path)
    Solved!
    Go to Solution.
    Attachments:
    Call Library Function.png ‏192 KB

    You mention that you have changed computers and that it used to work before.
    Could it be that there is another (older) copy of the DLL on this computer, and LabVIEW is loading the wrong one?
    The simplest way to check is to close your VI and delete the one you are expecting it to use.  Then open the VI again; if LabVIEW doesn't ask you where the DLL is, it is loading it from somewhere else.
    Batya

  • Call Library function

    Hi,
    I just transfered some of my programs (in LV5.0 - student edition) from one computer to another. The programs work perfectly on computer A, but when I transfered them to computer B, an error comes up saying 'call library function not supported in this version'. What I don't understand is that I am using the exact same LV5.0 student edition on both computers - was maybe an update installed on the original computer to allow the call library function to work? If so, where could I find this? Any other ideas why I can't use Call Library Function on computer B?

    Hi LV newbie,
    Th call library function calls functions within a dll. The dll can be an API or driver from the equipment manufacturer or custom-made functions to control or communicate with the DUT.
    So the first thing I would look for is the dll in question.
    When you transferred the LV code from computer A to B, did you do a mass compile? (Tools > Advanced > Mass Compile). You can try that. If already done that, open the vi giving you trouble and look at the call library function. Is it pointing to the right directory to find the dll? The problem may be in the ability for the vi to find the dll. Make sure it is calling the right function(s) and passing the appropriate parameters and values. Strange things can happen when moving LV from one PC to
    another.
    Let us know your progress.
    JLV

  • Call library function will not retain change of directory for the library.

    I have created a call to a dll made in Visual C++. Everything works fine. I then configure the vi to call the a newer version of the library that is in another directory. The Call Library Function dialog box updates with the new path. I click the OK button. Then configure the vi again to very my change took and it is back to the original path to the library.
    Why can I not change where to find the library? I am sure that I can make a new vi an input all the parameters again, but I have many parameters and calls to the same dll. Making new ones each time the location of the dll changes is not an option.
    Thanks for your help.
    Attachments:
    code.zip ‏106 KB

    If you have more than one VI accessing the same DLL, then you can't
    change the DLL location without unloading all the other VIs first. This
    is because Windows will always look first for the DLL in memory, before
    even attempting to load it from disk. And if another VI makes use of
    that DLL it will be still kept in memory.
    Rolf Kalbermatter
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • 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

  • Problem with Call Library Function. Want to pass a string and return a string, but my compiler does not recognize "CStr" and Labview does not recognize my "char *function()" callout

    Hi, I'm trying to use a .DLL I wrote in Visual C++ .NET. The Call Library Function generates a function prototype of "CStr Parser(CStr arg_raw)"
    but my compiler won't accept this. So I change it to how C normally deals with strings "char *Parser(char *arg_raw). Now the Call Librafy Function does not find "Parser" in my .DLL though it is definitely there!
    Help!
    -Fong

    Hello
    You will need to include extcode.h in your C file. You can find this under ..\LabVIEW\cintools folder.
    The include has all the defines you will need.
    Bilal Durrani
    NI
    Bilal Durrani
    NI

  • 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 not Supported

    Hai,
    I have question to ask to NI members. I get an error said " Call Library Function Node 'LVASPT_WA.*ptDecimationFilterH':Node not supported". I use the call library function node in the FPGA.VI in my design. My question is, is it the function cannot used in FPGA.VI? I try to search a similar thread and find the manual but still can't find the answer. Anyone please clarify it to me. Thanks in advance.

    You cannot use Call Library Function Node in FPGA. The FPGA is hardware - it has no way to call an external library. If it is not immediately obvious why it's impossible for the FPGA to call a DLL, you should spend some time understanding what a FPGA is.
    You can integrate FPGA code written outside the LabVIEW environment, but that's not the same as calling a DLL.

  • Call Library Function Node: library not found or failed to load

    Hello,
    I had a VI that could not find some of the dll functions it needed.  It works on one machine and not on another.  So foolishly I copied the dll in question from the working machine and pasted it over the one on the non-working machine. 
    Now all my math functions are broken on the machine I copied the dll too.  The error is "Call Library Function Node: library not found or failed to load"
    And if I try to relink in the VI I get "Error loading C:\National Instruments\LabVIEW 8.2\resource\lvanlys.dll" A dynamic link library (DLL) initialization routine failed."
    I tried a repair labview and that did not help.
    I tried uninstall and reinstall labview and that did not help!
    Please help me fix this!
    Version 8.2
    dll: C:\National Instruments\LabVIEW 8.2\resource\lvanlys.dll
    Jim

    What library did you first copy?
    Also lvanlys.dll depends on the Intel Math Kernel Library that gets installed in a different location "C:\Program Files\National Instruments\Shared\MKL".
    This Intel Math Kernel Library again depends on the Visual C runtime libraries. Most likely you replaced one of those runtime libraries somehow and now the Math Kernel Library (MKL) fails to initialize which causes thelvanlys.dll to fail its load.
    Without a good view on your system and what other NI software you have installed it is very hard to recommend a good way of proceeding. There are various versions of the MKL used by various versions of NI products and just deleting the entire MKL folder might get you into trouble with other NI tools.
    Deinstalling everything from NI, deleting the entire National Instruments folder and then reinstalling what you need would be the most safe proceeding.
    And next time don't just copy some Visual C runtime libraries between machines. Their dependencies are complicated at the least and simply not graspable by us mere mortals. Use the according C runtime installer for the version you need as that installer will take care of installing the right versions of C runtime components and registering everything proberly so you do not usually run into problems with other applications using different versions of the C runtime.
    Message Edited by rolfk on 03-01-2010 10:26 AM
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • Call Library Function - Function not found in library

    Hello,
    I am working with a .dll in LabView 5.1. I finished a little program that should give me the number of CPCI-cards in a PXI-machine. But now i always get the error messages "Call Library Function - Function not found in library". I know it is threated several times bfore on this forum, but i didn't exactly find a sollution that solved my problem.
    The .dll is documented and i can see the function names by opening the .dll with Quick View. I have checked (a hundred times) the names i typed in and they are correct (=equal to manual of .dll and to Quick View, so we can skip that).
    What else could be wrong? What can i do?
    Regards,
    Klaas Engels
    student

    I'm not sure if it's a reason, but once I had the same error. In my case the reason was in that DLL function was actually named with additional suffix letter "A", and then digging through MS documentation I've found an explanation that MS uses desired function with one or another suffix depending on usage contents and data type. Adding that suffix was solved the problem.
    This was not obvios because in DLL description there was no mentions at all and function name was given generally, i.e. without any suffix at all, assuming every user should be MS guru.
    Sergey

  • 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

  • Passing arrays with Call Library Function does not work after application builder

    Calling a DLL with Call Library Function which requires an array of data works correctly in Labview, but after building an exe with application builder, the call no longer works.  Dereferecing the pointer in the DLL retuns all 0s and not the actual values.
    Solved!
    Go to Solution.
    Attachments:
    TEST.zip ‏28 KB

    I did not run your code because it is a little unclear to me what it does.
    Two things:
    First, is the DLL you are calling the DLL-ified version of PopUpNames.vi? Then the problem is likely that the panel is not being built into the DLL.
    When LabView builds an application / dll, it strips the front panel and block diagram from all VIs that it doesn't think need to show a panel at run time. This reduces file size and increases code security. The App Builder's panel inclusion logic can be overridden by Build Specifications -> Source File Settings -> Remove front panel. A better method is to put a property node on a control in a window you want to show marking it "visible"; this is sufficient to tell the App Builder it should keep the panel.
    Currently Source File Settings shows "no dependencies" (clearly incorrect---another evil side effect of Express VIs I guess) but if you change the settings as shown below to keep ALL panels, one might hope the App Builder can figure it to keep the panel when it deconstructs the Express VI. (Alternatively convert the Express VI into a regular one.)
    A second comment: I am a bit flummoxed at the larger goal here. You are calling LabView DLL from LabView, which doesn't make a lot of sense, so I assume your larger goal is to call LabView from C or vice-versa. In that case be aware that your DLL is x86 (32-bit) but you are passing 64-bit ints as your pointers. In this case it is 32-bit LabView with 32-bit pointers in embedeed in 64-bit containers calling 32-bit LabView with 32-bit pointers in embedeed in 64-bit containers, so it all works, but if your going to call this from C or whatnot you're going to have to follow that same design.
    When calling C code the LabView Call Library Function does have a "unsigned pointer-sized integer" data type that always appears to be 64 bits in the dev env but which actually passes a 64 or 32-bit int to the DLL depending on the environment. The "pointer sized int" has to be 64 bits in the "LabView" part of the code because LabView's strong typing requires the data type to be determined at compile time. Casting all pointers to the largest data type in LabView makes it possible to write platform-independent code, but down at the Call Library level you still have to put the right number of bytes on the stack.

Maybe you are looking for