LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Using .exp file with 3rd party dll.

I'm new to programming in Labwindows, and could use some help.  I'm having problems using a 3rd party dll.  The dll comes with both a .lib and an .exp file.  When I write a Visual C++ program using the dll, I get  "undefined symbol" errors if I only use the .lib file.  If I add both to my project, the program compiles fine.
 
For Labwindows V5, I also get the "undefined symbol" errors when I include the .lib file only.  Is there any way to add the .exp file or to not use it at all for Labwindows?  I did try to create a .lib file for the dll using Labwindows, but the dll uses another dll, which Labwindows gives an error message for in the .h file.  Thanks.
0 Kudos
Message 1 of 4
(3,969 Views)


@J Ahn wrote:
I'm new to programming in Labwindows, and could use some help.  I'm having problems using a 3rd party dll.  The dll comes with both a .lib and an .exp file.  When I write a Visual C++ program using the dll, I get  "undefined symbol" errors if I only use the .lib file.  If I add both to my project, the program compiles fine.
 
For Labwindows V5, I also get the "undefined symbol" errors when I include the .lib file only.  Is there any way to add the .exp file or to not use it at all for Labwindows?  I did try to create a .lib file for the dll using Labwindows, but the dll uses another dll, which Labwindows gives an error message for in the .h file.  Thanks.


Mmh, haven't dealt recently with CVI myself, but the .exp file is just the binary form for Microsoft C of what usually has been put in a .def file. The prefered way nowadays in Visual C (of course not compatible with other compilers other than maybe LabWindows CVI) is however to simply declare the function name with __declspec(dllexport) and that should take care of this. GNU compilers typically use something like attribute(export) instead.

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

Actually I think I figured out my problem.  It looks like the functions in the dll were mangled.  I was able to get around it by building a new dll with this dll in Visual C++ and by using the below:

#ifdef __cplusplus
extern "C" {
#endif
__declspec(dllexport) int __stdcall Array_Add(int *array, int num);
#ifdef __cplusplus
}
#endif

It worked for a couple of functions so we'll see how it goes.

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

It sure sounds like you found the solution.  Here is a link that describes the same fix. http://digital.ni.com/public.nsf/websearch/862567530005F09C862566D600768A51?OpenDocument

The disadvantage from the point of visual c++ is that you cannot overload a function when using the extern c declaration. 

For anyone who comes across this thread later, this link provides a way to check if you have a dll that uses name mangling.

http://forums.ni.com/ni/board/message?board.id=180&message.id=11323&requireLogin=False

 

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