Calling Dlls from LabVIEW

LabVIEW Gurus:
I am working with some software engineers who have no experience in LabVIEW. Unfortunately I have little experience in C/C++ to make sense of their inquiry.  
Basically we are dealing with “Data Marshalling”. I will call a DLL and issue a command (string) and get back a 2-D array and an integer. So far so good.
The C/C++ programmer requested that I provide them with a pointer/memory address in which they will store data, so I can read it once the dll returns the array and integer. I browsed through the example online http://decibel.ni.com/content/docs/DOC-1690 and thought that if I wanted to read from the dll, the process is a simple as calling the appropriate function and configure the parameter (no pointers needed).
So, is there a specific way that they need to write the C/C++ code to be used in LabVIEW? Or what else to I have to take into consideration?
Thank you,
Santiago 

That example is pretty simplistic as it only deals with integers. In this case no pointers are required since everything is returned by value. When you're dealing with arrays, however, you need to deal with pointers. If you open the Example Finder (Help -> Find Examples) and search for "dll" you will see the "Call DLL" example. That contains many examples of how to call DLL functions with a wide variety of datatypes. I strongly suggest looking at that example. There is also a chapter in the LabVIEW Help on calling DLLs (Fundamentals -> Calling Code Written in Text-Based Progamming Language).
You have 2 things to consider:
You're dealing with arrays - this means you typically need to pre-allocate the memory in LabVIEW, and it sounds like that's what the DLL expects you to do. This amounts to using the Initialize Array function to create your 2D array of the appropriate size and datatype.
You may be dealing with a C++ DLL. LabVIEW can only interface to C DLLs. This doesn't mean that you can't create a DLL in C++, but it does mean that the C++ programmers need to add an extern "C" modifier to the function calls, otherwise you get name mangling, and LabVIEW won't be able to call the DLL. The DLL programmers should know what that means.

Similar Messages

  • Calling 64-bit dll from labview 8.2 on Windows7

    Hello,
    I have tried the LABview driver from the OMNIDRIVER (OceanOptics) package. But when calling functions from the “OmniDriver32.dll” , LABView is crashing and  says that the memory is corrupted.
    I am using LABVIEW 8.2 (32-bit) running on Windows 7 (64-bit).  I have tried some LABView code examples given for LABview 7.1 and 8.0. These example are using the OmniDriver32.dll (not the OmniDriver64.dll).
    But maybe these example are assuming that you are on a 32-bit operating system, which is not my case.
    So I have tried calling the OmniDriver64.dll. but LABView seems not to recognised the dll and can’t read the included functions.
    Is there a way to call some 64-bit dll from LABview 8.2 ?
    Or do I need to buy a new license for LABVIEW 64-bit ?
    Thanks,
    Pierre

    There is no virtualization support for DLL bitness issues outside of the Windows standard directories. The Windows and System directories that an application "sees" depends on its bitness. All other directories are not mapped depending on the calling process' bitness.
    So if you have installed 32 Bit LabVIEW and are not calling one of the system DLLs, you have to point the path of the DLL to the real 32 bit DLL. Pointing it to a 64 bit DLL should not even be able to get the VI compilable, since Windows will refuse to load the DLL into the 32 bit process as being an unknown file format, and that should make the VI broken.
    If you need to call a system DLL you simply enter the DLL name without path and Windows will find the according DLL for LabVIEW.
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • The problem about call dll from VB....

    Dear All.
    I have a device and  VB dll file.I want to use labview to call  dll.But Labview show "An Exception occurred within the external code ..."
    Below is  to call this dll details.
    1、FindHardware:
    Call it at beginning when load program first, it can let program auto detect printer port address and model of dso scope.
    parament
    winversion:
    winversion = 2  "Windows NT,XP"
    UIP: open UIP(2048) array
    UCP:open  UCP(1023, 1023 + 11, 6)  array
    return:
    board_model:
    dso2902_128 = 27
    Then is my program
    Could somebody tell me what's wrong?
    Attachment file is this dll.
    http://us.f1.yahoofs.com/bc/500cf3ac/bc/dll/dll.ra​r?bfd1QSDBkHPgKI9c
    Thanks.
    由 Samyang 在 10-09-2005 07:14 AM 上編輯的訊息

    I can't say I understand the documentation snippet you provides, and I also can't access the DLL, but here are a couple things...
    1. I doubt very highly that a VB DLL is built with the C calling convension. I believe you should try the stdcall instead.
    2. You have the winversion being passed by pointer, but the docs make it look like a regular integer. Is that correct?
    3. Your board model is being passed by value, but it is listed as a return value in the docs. That would indicate an actual return value or a parameter passed by reference.
    My guess is that one or more of the above is causing the stack to get corrupted or an invalid pointer to be accessed and that is generating the error. Is there anyway to see the document (pdf or webpage)?
    Brian Tyler
    http://detritus.blogs.com/lycangeek

  • Create dll from labview

    Hi all:
    I am using labview 8.5 , i want to create dll for spacific vi , to use its output in another program like C++,
    can any one help me to learn the steps to create dll from labview
    thanks

    You need the application builder (which is part of the professional distro).
    In general you should every VI that you want as a function set to 'top-level'
    If you right click on the builds in your project you have an option to build a DLL (if you have the application builder), from there on the help is available.
    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!

  • Call dll from my dll

    I Have a dll file for my attendance machine
    and every thing are ok when I call dll from my exe application
    I want to create my own dll which my dll connect to attendance dll and get data from it and then insert data to tables
    a second question
    is there a method for calling my dll through windows batch file or I must create an exe application calling from it

    Let me explain a bit what a VFP DLL is for:
    You can only build one type of DLL, an OLE COM Server DLL. It'll mainly contain OLEPUBLIC class definitions, which are then usable in other programming languages. In any programming language capable to make use of OLE COM Server classes.
    If your project is named mydll.pjx and a prg or vcx contains a class myclass, the final DLL will have the OLE class "mydll.myclass" in it.
    This is overhead, if you use this in VFP. If you want to modularize your application, then create several EXE or build as APP. You can DO some.prg IN some.APP or you can create an object o = NEWOBJECT("myclass","myclasslib.vcx","myapp.app")
    to refer to a class inside a vcx compiled and build together with other project files into an app file.
    But any separation you do complicates the code use. A DLL is only needed, if some other programming language needs to use your VFP code. And that other programming language has to be able to instanciate classes.
    You don't need this, even if other programming languages would be involved. You can compile an EXE and that can be run. If needed with parameters. That's typically much simpler and could even be used by DOS batch files either using the DOS start command
    or directly your.EXE as man DOS commands also are merely EXE files.
    Bye, Olaf.
    Olaf Doschke - TMN Systemberatung GmbH http://www.tmn-systemberatung.de

  • Create DLL from labview and calling it from other application

    I have an application built using Labview. I wanted to create DLL out of it. The application has
    two String inputs start and stop buttons and two status indicators.
    1. How to itegrate start and stop buttons from function prototype?
    2. Does Labview created DLLs requires labview runtime engine when it is to be called from other application?
    Can some one help on this.
    Solved!
    Go to Solution.

    Hi Yuvish,
    1) They should be boolean inputs to your VI. But does it makes sense to provide a stop button input at the start of your VI? (THINK DATAFLOW!)
    2) Yes, the LV-RTE is needed...
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

  • Call dll in labview

    "Hi All,
    I have to get data from USB camera, I have following functions in DLL.
    DLLINOUT HANDLE WINAPI CC_Open( LPCSTR CameraName , ULONG CameraNumber , CC_CAPTURE_MODE CaptureMode ) ;
    and
    DLLINOUT BOOL WINAPI CC_CaptureSingle( HANDLE Cam , PVOID Buffer , ULONG TransferSize , CC_TRIGGER_MODE TriggerMode , USHORT TimeOut , OVERLAPPED * pUserOverlapped );
    When I open hardware with function cc_open I am getting handle to an object. How can I store this object and pass it to CC_CaptureSingle function?
    Another question is when I call CC_CaptureSingle I am getting pointer on the 2 dimension array �PVOID buffer� how can I get this array in Labview?"

    hi,
    you can do this two thing.
    1. Create your new DLL with (your DLL will call camera's DLL) one big function my_capture_image() and insert you do CC_Open(), CC_CapruteSingle() and CC_Close(). And to LabView you pass only Array whit image data. And you don't have problems with HANDLE. But you must allocate memory for image array in LabVIEW before you call this DLL!!! [Or use LabVIEW C function for reallocating memory]
    2. You must identify type of HANDEL variable. And you can change type of this variabile. But when HANDLE variable is structure it is hard pass this structure to LabVIEW.
    If you use LabVIEW 7.1 look example 'Call DLL.vi' it is great!
    Have a nice day.
    JCC

  • Error calling DLL in LabVIEW, but works in VC

    I compiled a DLL from Matlab, and then compiled a wrapper DLL in VC++. I tested the wrapper DLL in VC++, and it works fine, generating the correct output as in Matlab. 
    But when I call the wrapper DLL in LabVIEW, the first thing I noticed was that it only ran once. The second time I ran the VI, it returns an error. And the output is always a single number instead of an array when it runs. 
    I followed the examples how to create a wrapper DLL for Matlab compiled code. One of the examples said three functions Initialize, run and terminate should be implemented so that the DLL function can run continuously. I did all those, but it still does not work. 
    Here is the test code in C++. I explicitely loaded the DLL and ran the functions. It worked fine. Why the VI in LabVIEW does not do the same thing?
    // contourWrapper3.cpp : Defines the entry point for the console application.
    #include "stdafx.h"
    #include <Windows.h>
    #include <iostream>
    typedef int (*InitFunc)();
    typedef void (*TerminateFunc)();
    typedef void (*contourFunc)(double*,double*,int,int,double);
    int _tmain(int argc, _TCHAR* argv[])
    InitFunc _InitFunc;
    TerminateFunc _TerminateFunc;
    contourFunc _contour;
    HINSTANCE hInstLibrary = LoadLibrary("contourcWrapper.dll");
    if(hInstLibrary)
    _InitFunc=(InitFunc)GetProcAddress(hInstLibrary,"c​ontourcInit");
    _TerminateFunc=(TerminateFunc)GetProcAddress(hInst​Library,"contourcTerminate");
    _contour=(contourFunc)GetProcAddress(hInstLibrary,​"contourcGenerate");
    if(_InitFunc)
    _InitFunc();
    if(_contour)
    double image2DArray[] = {1,2,6,4,6,8,0,5,1,3,5,4,7,8,8,9,10,0};
    int width = 3;
    int height = 6;
    double c[sizeof image2DArray] = {0};
    _contour(c, image2DArray, width, height, 0.6);
    for (int i=0; i<width*height; ++i)
    std::cout << c[i] << std::endl;
    _TerminateFunc();
    else
    std::cerr << "Could not initialize libcontour properly."
    << std::endl;
    return 0;
     This is the output window of the above C tester code. It displays the correct output of array. 
    And this is the VI that does not work. 
    In the attached files, 'libcontour.zip' contains the matlab-generated dll and wrapper dll. 
    Attachments:
    contourcWrapper_test.vi ‏12 KB
    libcontour.zip ‏50 KB

    But LabVIEW does.  The declarations (in C) for different types of arrays are not the same.  I think you are passing extranious data to the DLL which is causing the issue.
    I will defer to your expertise however.  Over the years my knowledge in this area has waned.  Perhaps you are correct (in which case I am not sure what is wrong).
    Examples:
    typedef struct
        int dimSize;
        double data[1];
      } t_LvArrayDbl1D, *p_LvArrayDbl1D, **h_LvArrayDbl1D;
    typedef struct
        int dimSize[2];
        double data[1];
      } t_LvArrayDbl2D, *p_LvArrayDbl2D, **h_LvArrayDbl2D;

  • Can I create a dll from labview with more that one function name

    I know that when I create a dll from C and then call it in labview using the call library function node I can see the different functions on the configuration screen. Is there a way to create a dll in labview to have more than one function name? No matter how many functions happen in my VI it seems to build into a dll under the same function name requiring inputs for every function, can this be avoided somehow?
    Thanks,
    Dave

    Each function corresponds to a separate VI. When creating the dll, on the Source Files tab of the app builder, click the Add Exported VI for each VI that you want. SubVIs of a main are not automatically exported and will not be available as separate function calls.

  • Call DLL from PL-SQL block

    Hello all,
    I want to call a function located in an external DLL from a PL-SQL block. I execute the followin steps :
    1. Create a database library pointing to the external DLL :
    create or replace library libstk as 'C:\SUMMIT\libstkdte_s_trade1.dll'
    2. Create the definition and the body package :
    CREATE OR REPLACE PACKAGE dllcall IS
         FUNCTION s_trade (
              s_in VARCHAR2 )
    RETURN VARCHAR2;
    PRAGMA RESTRICT_REFERENCES(s_trade, WNDS);
    end dllcall;
    show errors
    CREATE OR REPLACE PACKAGE BODY dllcall IS
    FUNCTION s_trade (s_in IN VARCHAR2) RETURN VARCHAR2
    IS EXTERNAL
    NAME "s_trade"
    LIBRARY libstk
    PARAMETERS (s_in           STRING,
    RETURN STRING);
    END dllcall;
    show errors
    set serveroutput on
    3. Start the PL-SQL block calling the external function. And I got the foolowing error :
    1 begin
    2 dbms_output.put_line ( dllcall.s_trade ( '<Request> ' ||
    3 '<CurveId>MYCURVE</CurveId> ' ||
    4 '<Mode>02</Mode> ' ||
    5 '<ExpCcy>GBP</ExpCcy> ' ||
    6 '<AsOfDate>20001023</AsOfDate> ' ||
    7 '<Entity>***SUMMIT-XML***</Entity> ' ||
    8 '</Request>') );
    9* end;
    10
    11 /
    begin
    ERROR à la ligne 1 :
    ORA-06520: PL/SQL: Error loading external library
    ORA-06522: Unable to load DLL
    ORA-06512: at "V31.DLLCALL", line 0
    ORA-06512: at line 2
    The "Read - Execute permissions" of the DLL file was given to "Authentified users" .
    What's wrong ?
    TIA
    PS : NT2K environment, DB 8.1.7
    R. Charles Emile

    Yes, a RPC was set up.
    Listner.ora
    LISTENER =
    (DESCRIPTION_LIST =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = Server1)(PORT = 1521))
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = NMP)(SERVER = Server1)(PIPE = ORAPIPE))
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
    SID_LIST_LISTENER =
    (SID_LIST =
    (SID_DESC =
    (SID_NAME = PLSExtProc)
    (ORACLE_HOME = E:\Oracle\Ora81)
    (PROGRAM = extproc)
    tnsnames.ora
    extproc_connection_data =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
    (CONNECT_DATA = (SID = PLSExtProc))
    Thanks
    RCE

  • Call dll from javascript

    hai,
    i have a dll(VB) in client m/c. i need to call a method in a dll from javascript.
    if possible please give some sample code.

    http://www.google.com/search?hl=en&ie=UTF-8&oe=UTF-8&q=calling+a+dll+from+javascript

  • Call DLL from pl/sql

    Hi Every one
    I have to call one microssoft dll from the pl/sql using form .
    How can I do it.
    Prashant

    That likely means that the DLL call failed.
    Some basics.
    A DLL exposes an interface where it lists the names of the proc/func exposed (together with a number/ordinal for each).
    The Win32 LoadLibrary() call is used to load a DLL. This returns a handle that is then used by subsequent calls to the DLL.
    In order to make the actual call, the caller needs to know the address of the procedure/function in the DLL. The GetProcAddress() is the Win32 call I remember using to get the address to call (but I think it has been deprecated since).
    Anyway, for the caller to call that proc/func in the DLL, it needs these steps:
    - load that library
    - get the "address" of that proc/func in the DLL
    - make the call
    The DLL is then executed - in the address space of the caller. Yes, the DLL's code segment is loaded once and shared amongst how ever many executables are using that DLL. But the DLL has no data segment - the data segment of the DLL lives in the address space of the caller.
    Should the DLL do something dirty/wrong, it can crash the caller by corrupting its address space. Or the DLL call could simply fail, throw an exception and terminate unexpectedly.
    This is the basics of the a DLL call - and also why Oracle wants to run that DLL call externally using the EXTPROC interface, so as not to risk that DLL compromising the memory space of the Oracle server process.
    This makes it a tad more complex now as the Oracle server process makes a call to EXTPROC (an IPC/RPC call) - and the EXTPROC process makes the DLL call (as described above).
    If that EXTPROC process crashes, the call that the Oracle server process made also terminates unexpectedly.
    Why can the EXTPROC process crash? Well, there are more meaningful errors returned when the DLL fails to load in my experience. So I expect that your DLL was found and that the EXTPROC process did a successful LoadLibrary() call - and even made a successful GetProcAdress() (or whatever call).
    But when the actual call to the DLL func/proc was made, an error resulted (incorrect parameter passing, invalid data types being passed, invalid memory being referenced, etc).
    This error caused a fatal error and terminated the EXTPROC process. No meaningful error was therefore returned to the Oracle server process - so it throws the exception "lost RPC connection to external process".
    Hope this was not too technical and you got the gist of it.

  • Calling DLL from forms6i

    Hi,
    I would like to use the fuctionality of a DLL, developed in VB. How I can call the existing methods of a DLL from forms6i.
    Thanks.....
    Bye
    vhareesh
    null

    Hi,
    I would like to use the fuctionality of a DLL, developed in VB. How I can call the existing methods of a DLL from forms6i.
    Thanks.....
    Bye
    vhareesh
    null

  • Call dll from plsql

    Hi
    I am trying to connect an external program(DLL) from pl/sql.
    for the practice i trying to call "GetComputerName" from kernel32.dll.
    i made the following step
    1. Creating a library .
    2. Creating a package .
    3. Set the listener.ora
    4. Set the tnsnames.ora.
    After solving the problame with the settings of the listener.ora
    I testing the function , it run with no error but return 'null' .
    I thing the problems is with the "parameter"
    I do not know of haw to send them .
    ----my pak-------------------------------
    CREATE OR REPLACE Package Body K32 As
    Function GetComputerNameK(lpBuffer out varchar2,nSize in out long )Return long Is
    External
    Library Sys.Kernel32 Name "GetComputerNameW"
    Language c
              WITH CONTEXT
    PARAMETERS (
    CONTEXT,
    --lpBuffer STRING,
              lpBuffer BY REFERENCE,
              nSize BY REFERENCE,
              --nSize INDICATOR short,*/
              RETURN INDICATOR--,
         /*     RETURN short */);
    End K32;

    Let me explain a bit what a VFP DLL is for:
    You can only build one type of DLL, an OLE COM Server DLL. It'll mainly contain OLEPUBLIC class definitions, which are then usable in other programming languages. In any programming language capable to make use of OLE COM Server classes.
    If your project is named mydll.pjx and a prg or vcx contains a class myclass, the final DLL will have the OLE class "mydll.myclass" in it.
    This is overhead, if you use this in VFP. If you want to modularize your application, then create several EXE or build as APP. You can DO some.prg IN some.APP or you can create an object o = NEWOBJECT("myclass","myclasslib.vcx","myapp.app")
    to refer to a class inside a vcx compiled and build together with other project files into an app file.
    But any separation you do complicates the code use. A DLL is only needed, if some other programming language needs to use your VFP code. And that other programming language has to be able to instanciate classes.
    You don't need this, even if other programming languages would be involved. You can compile an EXE and that can be run. If needed with parameters. That's typically much simpler and could even be used by DOS batch files either using the DOS start command
    or directly your.EXE as man DOS commands also are merely EXE files.
    Bye, Olaf.
    Olaf Doschke - TMN Systemberatung GmbH http://www.tmn-systemberatung.de

  • Calling DLL using LabVIEW 7.1

    so, i have this DLL which might be compiled using Visual Studio 2003 or Visual Studio 2005.NET.
    question is: Can i call DLL functions using LabVIEW 7.1? has anyone tried it and has any issues loading the DLL?
    i think i have everything right, as far as the configuration of 'Call Library Function Node' is concerned, but i get the
    'error loading DLL - application has failed to start because application config is incorrect'.
    can you please verify if .NET is not causing me issues? i think DLL assembly should be the same wheather it's VStudio6
    or .NET, but can anyone confirm that's not the issue? Thanks...

    Yes.
    If you dll is generated by C/C++, using Call Library Function node.
    If it is generated by .net, using constructor node.
    http://forums.ni.com/ni/board/message?board.id=170&message.id=206959#M206959

Maybe you are looking for