LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Link Error - Undefined symbol...

Hello,
 
i try to bind my VC++ 6.0 dll in my CVI Project. What is the reson for the error message "Undefined symbol '_sum' referenced in "usecvidll.c""? In VC++ i can bind this dll, too.
I have insert the SumDll.dll and SumDll.h in my CVI Project and then i debug the project. What is the problem?
 
Thank you.
 
  
Download All
0 Kudos
Message 1 of 3
(4,089 Views)
RonnyG,

You need to include SumDll.lib in your project, not SumDll.dll. It should be located next to SumDll.dll in your compiler's output location.

Regards,

-alex
0 Kudos
Message 2 of 3
(4,064 Views)

Hi RonnyG,

The problem is that you are not exporting those functions (sum and summe) from your DLL. You need to do this so external programs like CVI can access those functions. This is why you are getting the undefined symbol errors since CVI can't find the exported functions.  You need to be using the
dllexport keyword to declare a function to be exported. For example, you would say:

__declspec(dllexport) int __cdecl sum(int a, int b);

Refer to the Microsoft Exporting from a DLL Using __declspec(dllexport) document and the FAQ: Using Dynamic Link Libraries with LabWindows/CVI tutorial for help.

You also need to make address the issue of mangled functions names in C++. Essentially, if you are creating a DLL using Visual C++ for use with LabWindows/CVI, you must mark the exported functions with extern "C" to specify that these functions will be used with a C compiler. If you do not mark an exported function with extern "C", LabWindows/CVI will not be able to call that function because C++ compilers mangle function names when they are exported from a DLL.  So, for example you would say something like:

extern "C" char __declspec(dllexport) GetChar( void )

This topic is also discussed in that CVI tutorial.

Hope this helps!

Best Regards,

Jonathan N.
National Instruments
Message 3 of 3
(4,063 Views)