How to call external functions without a .DLL (just using a .H and .LIB file)?

Hello everyone,
actually I'm facing little difficulties on how to get an external function getting called from within CVI (Version 2009).
I was supplied with a .H file and a .LIB file to call an external function from within my CVI project. The .H file looks like this:
void exportedFunction(double *parameter);
As far as I know, the external function was written with MS Visual C++ 6.
So I tried to statically link to the extern al function like this:
- Add the .H file and the .LIB file to the CVI project
- #include the .H file where I needed to call the external function
- do the external function call
When building I get an unresolved external function call error from CVI so this seems not to be working.
I made some searches around and got up with two possible issues. Maybe one of you can help me get a bit further and get things working.
1) The "real" function code is located in the DLL file which was not delivered to me. Or is there a way to get things done (call external functions) just with a .H and a .LIB file (without any .DLL file included)?
2) The external function does not export according to "C-Style" rules. The function signature in the .H file shows no things like
extern "C" __declspec(dllexport) void __stdcall ...
 Or maybe it's a combination of both issues (missing .DLL + wrong export style of function)?
I guess I could get around the wrong export style of the function when I manage to write a wrapper around the original function that actually uses C-Style exporting. But I guess I need the .DLL file for this try as well.
Thank you for your answers.
Best regards,
Bernd
Solved!
Go to Solution.

There is no need  for the dllexport stuff. There is also the option for a static library without any DLL.  But the 'extern "C"' is essential, because it forces the C++  compiler, which was probably used to compile the library , to use C calling convention.
If you can't ask the provider of the library to provide a version which was compiled using C calling convention the way to go is to write a wrapper with VC++6 around that library which reexports the functions using C calling convertion. Something like
extern "C" type0 myfunc1(type1 arg1, ...) {
       return func1( arg1,...);
for every function , you need to use.
BTW. "unresolved symbol" is the linker error message, you can expect if you try to link C code against a library build with C++ calling convention.

Similar Messages

  • How to call a function of a dll

    Hello,
    I have to call a function from a dll. I have a description how to do that in Visual Basic but I don't find those command in Diadem 9.1.
    Here is the command in Visual Basic:
    Declare Sub oLIC Lib "LICENSE.DLL" (ByVal PrgNam As String, ByVal VerString As String)
    PrgNam = "DiademScript"
    VerString = "1.0.0"
    Call oLIC(PrgNam,VerString)
    Is such a call possible in Diadem?
    Regards
    Patrick

    Hello Patrick!
    This is not possible! This is one of the differences between VB/VBA and VBS. You have to wrap the DLL with a COM server or a DIAdem GPI DLL.
    Matthias
    Matthias Alleweldt
    Project Engineer / Projektingenieur
    Twigeater?  

  • How to call a function of registered DLL in Diadem8.10?

    Please make the entire procedure after registering DLL in Diadem8.1. Notably, i can't use LAbview. I need it in VBS file. Can you put a sample code example, as i already exhausted in searching the help.

    Hi mv_rajk,
    I have to agree with IS that I'm not completely sure what you want either. But I'd like to round out IS's excellent points with two more:
    4) VBScript can create object variables from an ActiveX object file (*.ocx) and call methods and read and write properties of the new object variable natively. So you can call a DLL from VBScript, but only if you first wrap that DLL in an ActiveX layer and create an object variable with the CreateObject() command.
    5) VBScript can similarly create an object variable for any application's OLE Automation Server, again with the CreateObject() command. So you can absolutely call a LabVIEW VI from a DIAdem VBScript, and you can pass DIAdem channels to the VI and create new DIAdem channels based on the
    outputs of that VI. Note that this works with all LabVIEW inputs and outputs EXCEPT clusters. So you might have to wrap the VI you're interested in in another VI that builds the clusters to send to the VI you want or unpacks the clusters you get back from the VI you want.
    If either of these points sound interesting to you, we'd be happy to provide VBScript code and examples.
    Regards,
    Brad Turpin
    DIAdem Product Support Engineer,
    National Instruments

  • How to check which is th best method to use in LSMw and the file

    Hi all,
    I am new to LSMW,
    Can know me when i get the file , how to check the which is the Best method ( Batch input, Direct input,BAPI, IDOC)  have to use in LSMW .
    How to check the input file is completely filled and how to check whether it is correct and also how to Prevalidation check has to be done fior the file before uploading.
    Can you provide any documents LSMW also Apprecited.
    Regards,
    Madhavi

    Hi Madhavi,
    To check Correctness & completeness of the file:
    1. The input file structure should be same as source structure what you defined whicle creating LSMW.
    2. Check the following steps to assure the field mapping is done correctly.
    a) Maintain field mapping & conversion rule
    b) Check 'Display Read data'
    c) Check ' Display Converted data''
    Please note LSMW is a tool, which will simply upload the data whatever you are providing. So you need to be careful while making your file and validate it outside SAP ( before upload start)
    Pradeep D

  • How to call a function in DLL file, while writing test scripts in ATML standards

    Hello all,
                I am trying to develop test scripts in ATML standards. I need to call a function in DMM.dll file. How can i do that in ATML standards, please explain with some example ATML standard XML file. Someone please help me in doing so. Thanks a lot in advance.
    With Regards,
    kalyan

    Hi srivinayaka,
                         I am attaching the XML file i have written in ATML standards and the Labwindows/CVI code that was generated when the XML file is opened in TESTSAND. actually the defenition of the function "IALdcpwr_reset()" is in IALdcpwr.lib and IALdcpwr.h files.
    "How can we add this library and header files?" so that i can show the path of definition. whether it should be done manually or can we do some changes in the XML file and make the work done?. Thanks in advance. If you have any example for this type of sequences. please forward me which would be helpful for me.
    With best regards,
    kalyan
    Attachments:
    XMLfile.doc ‏135 KB
    XMLfile.doc ‏135 KB

  • How do i call these functions without an error? Python

    Hi, I'm confused on how to call these functions I'm continuously getting error can you please help me.
    I am also unsure on how parameters work and don't know what I need to write in them, i'm a bit of noob so will need you to explain thoroughly thank you
    I am trying to get a dice roll and then the player chooses which counter to move, the program will then automatically minus the movement from the counters position
    counter = ()
    postiony_red1 = 605
    postiony_red2 = 605
    def dice_roll():
        import random
        dice = random.randint(1, 4)
        print("You rolled a", dice)
        if dice == 1 :
            print("You can step forward", dice, "move")
        elif dice == 2 or dice == 3:
            print("You can move", dice, "steps forward")
        else:
            print("You can move 1 space back")
        input("Press return")
        return dice
    def move(dice):
        if dice == 1:
            move = -60
        elif dice == 2:
            move = -120
        elif dice == 3:
            move = -180
        elif dice == 4:
            move = 60
        print("move")
        return move
    def ask_player():
        while counter != ("counter 1") or ("counter 2"):
            counter = input("Do you wish to move counter 1 or counter 2?")
            return counter
    def counter_postion():
        if counter == ("counter 1"):
            move += postiony_red1
            print("total move is", move)
        elif counter == ("counter 2"):
            move += postiony_red2
            print("total move is", move)
    dice_roll()

    This forum section here is about Small Basic programing language!
    I dunno Python, but the few droplets I've heard about is that Python is very strict about global variables!
    And that every time we need to assign values to them, we gotta declare it w/
    global keyword inside each function that needs it:
    def ask_player():
    global counter
    while counter != "counter 1" or "counter 2":
    counter = input("Do you wish to move counter 1 or counter 2?")
    return counter
    Click on "Propose As Answer" if some post solves your problem or "Vote As Helpful" if some post has been useful to you! (^_^)

  • How to call LabView function with nested structs and arrays from C#

    Hi,
    I've got the following functions defined in a LabView-dll:
    uint32_t __stdcall VOSC04_General(uint32_t Command, TD18Hdl *Messages);
    uint32_t __stdcall CheckDiameter(uint32_t Command, TD6 *Parameter);
    typedef struct {
     double SP_Diameter;
     double SP_Tolerantie;
     double PV_Diameter;
     } TD6;
    typedef struct {
     int32_t dimSize;
     int32_t Numeric[1];
     } TD18;
    typedef TD18 **TD18Hdl;
    I've got some C#-code (generated by PInvoke-wizard) to call these functions:
    [DllImport("vosc04.dll")]
    public static extern uint32_t VOSC04_General (uint32_t Command, ref TD18Hdl Messages);
    [DllImport("vosc04.dll")]
    public static extern uint32_t CheckDiameter(uint32_t Command, ref TD6 Parameter);
    [StructLayout(LayoutKind.Sequential,Pack=4)]
    public struct TD18
       public int32_t dimSize;
       [ MarshalAs( UnmanagedType.ByValArray, SizeConst=1)]
       public int32_t [] Numeric;
    [StructLayout(LayoutKind.Sequential,Pack=4)]
    public struct TD6
       public Double SP_Diameter;
       public Double SP_Tolerantie;
       public Double PV_Diameter;
    The problem now is that when I try to read the Messages-output-parameter, I get wrong values (pointers?). I think that the problem lies in the fact that LabView generated a TD18 AND an TD18Hdl struct.
    How can I correct this problem?
    Can anyone give me some advise to correct this problem? I'm not an expert in C, only in C#.

    I think the problematic line is this:
    public struct TD18
       public int32_t dimSize;
       [ MarshalAs( UnmanagedType.ByValArray, SizeConst=1)]
       public int32_t [] Numeric;
    It looks like C# is forcing the array to be of size 1. The thing is, LabVIEW stores arrays as handles which are double pointers to a structure which contains a size element followed by the elements of the array. For your example, int32 arrays are stored in memory as:
    handle -> location -> |size|element 1|element 2| .... |element size-1|
    Because C does not do runtime array bounds checking, you can get away by declaring the structure as:
    typedef struct {
     int32_t dimSize;
     int32_t Numeric[1];
     } TD18;
    The correct declaration would've been:
    typedef struct {
     int32_t dimSize;
     int32_t Numeric[size];
     } TD18;
    But size is not a constant, so C/C++ won't let you do that. So, even though the array is declared to be of size 1, it can (and usually does) have more than 1 element. This does not cause a problem because LabVIEW allocates memory based on the actual size of the array.
    If I were you, I'd try to change the prototype of the LabVIEW DLL function to accept a pointer to array data, rather than an array handle, pre-allocate memory for the array in C# and pass a pointer to the allocated memory into LabVIEW so that LabVIEW can "fill it up".
    Let me know if you need more information.
    Pramod

  • Calling C Functions in existing DLL's from Java

    Hi Guys ,
    The tutorial in this site talks about creating ur own DLL's and then calling them from Java . I need to call C functions in existing DLL's from Java . How do I go about doing this ? . Any help on this would be much appreciated.
    regards
    murali

    What you are interested in can be done with what's called "shared stubs", from the JNI book (http://java.sun.com/products/jdk/faq/jnifaq.html), although you don't need the book to do it (I didn't).
    The example code will call functions with any number and kind of parameters, but doing that requires some assembly language. They supply working examples for Win32 (Intel architecture) and Solaris (Sparc).
    If you can limit yourself to functions to a single function signature (number and types of parameters), or at least a small set that you know you'll call at compile time, you can modify the example so that the assembly language part isn't needed, just straight C code.
    Then you'll have one C library that you compile and a set of Java classes and you can load arbitrary functions out of arbitrary dynamic libraries. In my case you don't even have to know what the libraries and functions are ahead of time, the user can set that up in a config file.
    You mentioned doing this with Delphi. One thing to watch out for is C versus Pascal (Win32) function calling convention. A good rule of thumb; if it crashes hard, you probably picked the wrong one, try the other. :-)

  • Calling a function from a dll written by using visual studio c++

    Hi, how can i call a function from a dll which is written by visual studio c++ in test stand?  Although the functions in dll are exported and i've chosen c/c++ adapter, i saw no function in test stand. Is there a different step while i'm calling a function from a dll written by c++ than calling a function from a dll written by cvi?

    Hey Sadik,
    Selecting the C/C++ DLL Adapter Module should be sufficient for this. When you drag an action step for this onto the Main Step and navigate to the location of the DLL, the function list should populate and you should be able to select the function you want to use. If this is not the case, would you be able to post this DLL so that we can test this on our end?
    Regards,
    Jackie
    DAQ Product Marketing Engineer
    National Instruments

  • How to call a function from asp

    Hi!, I'd like to know how to call a function from an asp page. I've written:
    set rs = server.createobject("Adodb.recordset")
    rs.open "call dbo.sf_Obt_Des_Producto ('0000161')",Conn
    if err.description <> "" then
    response.write ("No se pudo! :(")
    else
    response.write ("rs: " & rs(0))
    end if
    rs.close
    set rs = nothing
    but there is an error:
    ORA-06576: not a valid function or procedure name
    Please is very urgent!!!
    Thanks.
    Angie.

    You need to use the syntax "{call <procedure_name>}".
    The {call } syntax tells the OLE DB provider that it needs to translate the call into whatever the database's procedure calling syntax is. This means that even though different databases have different syntax for calling stored procedures, your OLE DB code can be run against any of them without changing.
    Justin

  • How to call api functions

    Hi
    I have a problem in form6i.i wrote a c++ program calling forms bjects and changing properties .The code gets complied(let file name be some.cpp file).now how can i use this file .where should i use this file .please replay
    from
    Pradeep

    gang lee (guest) wrote:
    : sir:
    : For some reasons,I want to call the windows api functions
    : from developer/2000 2.1,I want to know how to do that?
    : thanks for your help!
    There are two ways to invoke windows api functions: First, and I
    believe the simplest of the two is the Forms package ORA_FFI,
    which stands for Foreign Function Interface. This allows you to
    load the dll and call any function in that dll as long as its
    arguments uses standard data type (e.g. int, floats, chars), but
    it does not support complex datatype such as structures and
    pointers to structures.
    Thoe other alternative is writing your own C function in a dll
    and calling the windows api from the user exit. This is more
    flexible as it can call functions that pass complex data types.
    Either approach will require time and tinkering to get it to
    work. A good knowledge of C would be helpful.
    null

  • Calling a function from a DLL, exectution in background mode.

    Dear Experts,
    We have created an ABAP report the calls a function from a DLL file. If the report is executed in on-line mode the program calls and executes the function from the DLL, but if the ABAP programa is executed in background mode it doesnt calls the DLL function.
    Do you know a way to solve the problem when executing in background mode?
    Best regards.
    Antonio

    Hi Gabriel,
    Let me explain in details about my DLL function.
    We are importing the business partners from legacy system into the SAP CRM system, so at the moment we created the BP master data via BAPI, I get the name of the BP and this moment I call the function in the DLL file. I export the parameter name and I receive back a simplified string with the name reduced to a code. This code I get back from the dll it is insert in a Z table, so there is no interaction in the screen, all must be executed in background mode, because there are a lot of business partners to be converted in SAP system.
    I am sending my code for your considerations.
    Instancia a DLL
      CREATE OBJECT dll 'MTCODE.CPFONET'.
      IF sy-subrc NE 0.
        RAISE without_dll.
      ENDIF.
    Move para a tabela interna IT_NAME os valores recebidos na TI_NAME
      it_name[] = ti_name[].
    Para cada registro importado
      LOOP AT it_name.
        CLEAR v_string_ret.
        wa_matchcode-zregid     = it_name-zregid.
        wa_matchcode-name1_text = it_name-name1_text.
        v_string = it_name-name1_text.
        CONDENSE  v_string.
        TRANSLATE v_string TO UPPER CASE.
        CALL METHOD  OF dll 'SetNome' EXPORTING #1 = v_string.
        CALL METHOD  OF dll 'ExecMatch'.
        CALL METHOD  OF DLL 'GetMCData' = v_string_ret.
        FREE OBJECT dll.
      Preenche os campos do match-code de acordo com o retorno da DLL
        SPLIT v_string_ret
        AT '|'
        INTO wa_matchcode-zparmcln
             wa_matchcode-zparmcfn
             v_empty
             wa_matchcode-name_first
             wa_matchcode-name_last
             wa_matchcode-namemiddle.
      Adiciona o registro com o match-code correspondente na TE_MATCHCODE
        APPEND wa_matchcode TO te_matchcode.
      ENDLOOP.

  • How to call external files from java?

    How to call external files in java. For example how to call a *.pdf file to open in its default editor(say Acrobat), or a *.html file to open in the default browser or a *.txt file in a notepad etc..,
    In my program i have *.chm (Compiled Windows HTML Help) help file. how to open it in its default editor it?

    Jayarathina_Madharasan wrote:
    no one answered my questionHi what wrong did i do...basically insulted all the volunteers here who took the time to consider your question and try to offer you help. Other than that, you did nothing wrong.
    From JavaRanch :
    And even if an answer doesn't solve your problem, even if it should totally miss the point - the best thing to do to motivate others to continue trying to help you is showing respect and gratitude for the investment of time that was put into dealing with your issue.
    Edited by: Encephalopathic on Apr 14, 2008 10:01 AM

  • How to call javascript function from PL/SQL procedure

    Can anybody advice me how to call javascript function from PL/SQL procedure in APEX?

    Hi,
    I have a requirement to call Javascript function inside a After Submit Process.
    clear requirement below:
    1. User selects set of check boxes [ say user want to save 10 files and ticks 10 checkboxes]
    2. user clicks on "save files" button
    3. Inside a After submit process, in a loop, i want to call a javascript function for each of the file user want to save with the filename as a parameter.
    Hope this clarify U.
    Krishna.

  • How to call java function from PL/sql in oracle applications

    I am trying to call a java function from plsql procedure. Can any one explain how to call java function, and in which directory I have to store my java function in oracle applications. Do I need to register that java function from Application developer.
    Thanks
    Kranthi

    http://www.oracle.com/technology/tech/java/jsp/index.html
    Good Luck,
    Avi.

Maybe you are looking for

  • Letter case in SAP import manager

    Hi, We are facing a strange issue with SAP import manager. we have the value 'n' for a field in XML file. when we tried to open the XML file through import manager, in map/value fields tab, the value is showing up as 'N' for that field where as it is

  • Mac Mini & iSight

    I have two Mac Minis, each connected to different iSight cameras. I use the iSight and Mac Mini to connect and talk to friends using Skype. While talking, I frequently loose the mirophone function of the iSight. The solution is to unplug the iSight f

  • Save data to database?

    Hi All, In one requirement i have save button. in two requirements it has to trigger. 1. adding new record, 2. modyfing existing. how to do this? any help? Thanks, venkat.

  • HP 7110 on 10.6.2

    Was called in to help someone with new iMac and 10.6.2 who has an HP 7110. I downloaded the latest drivers from the HP site. They were labeled as only being for OS X up to 10.4. I installed and reinstalled the driver five or six times. HP installer h

  • Open mail message closes automatically after few seconds

    Whenever I open a mail message to read - it automatically closes after a few seconds. Can this be prevented. Thanks