LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Can't call function from dll or lib file

Solved!
Go to solution

Hello,

I am trying to call c++ function SendCANMessage from .lib file into my CVI project by following steps from this link:

Link (Part: 2nd way to use a DLL).

I have included 2 .h and 2 .c++ files into DLL project in Visual Studio, added __declspec(dllexport) in front of functions that I want to use in CVI

and built project successfully. Then I have added .lib and .dll files that I got from this build into my CVI project. and tried to call one of functions from .c file (from CVI). When i build project, it says:

Capture.JPG

 

Function declaration in .h file is: CAN_ERROR SendCANMessage(CAN_msg *pMsg, DWORD dwTimeout); and I have 

defined CAN_ERROR, CAN_msg and DWORD earlier in my .c file.

I found that -10 means this: "Identifier not defined globally in the module.", but i don't know what to do about it.

I think that CVI don't see any of functions in .lib and .dll files and i need help how to include it properly, because I just added

these files by Edit->Add Files To Project and added files. I provided archive with all files that are included in CVI project.

Best regards,

Igor

 

0 Kudos
Message 1 of 4
(3,738 Views)

Are you sure you create the DLL and lib file in Visual C as the same bitness than what you run in LabWindows/CVI?

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 2 of 4
(3,712 Views)

Make sure that the functions exported from the VC dll are C-style functions.

See http://www.ni.com/white-paper/3341/en/#toc9 for details.

Also, why don't you use the 1st part in the document you linked? It is easier.

0 Kudos
Message 3 of 4
(3,682 Views)
Solution
Accepted by topic author bigor94

Thank you for your answers, 

the problem was that I have generated bad dll and lib files.

I couldn't include extern "C" in front of functions because that functions are members of class and I got linkage error, so I needed new .h file

where I have put all definitions from two header files (RT_COM.h and RT_CAN.h) and wrap it with extern "C" {}. Also I have added declarations of functions with extern "C" __declspec(dllexport) in front of them. When I built this in VS i got new dll and lib files, copied dll, lib and h files to CVI project folder, added lib to project and included h file in my c file. Example of usage this c++ functions in c program is shown bellow:Capture.JPG

You can see .h file in attachment.

 

 

 

0 Kudos
Message 4 of 4
(3,675 Views)