Academic Company Events Community Support Solutions Products & Services Contact NI MyNI
7 ratings:
 3.14 out of 5   

Syntax Error or Link Error When Calling a DLL in LabWindows/CVI



Primary Software:
Primary Software Version: 9.0
Primary Software Fixed Version: N/A
Secondary Software: N/A

Problem:
I am calling a DLL from a LabWindows/CVI project. I have included the import library (.lib) and header file (.h) for the DLL in the LabWindows/CVI project. Why am I receiving the following error when I try to build the project? 

"headerfile.h"(1,20) syntax error; found 'identifier' expecting ';'


Solution:
Link Error
First double-check that you have included both the header file and the import library for the DLL in your project (Refer to the Project Tree inside LabWindows/CVI). If one of those files is missing, add that file to your project by selecting Edit » Add Files to Project or by right-clicking the project name inside the Project Tree and selecting Add File....

If the above files are included, the second possible issue could be dealing with the compiler's calling convention. The default calling convention for DLLs is set under the Options » Build Options menu as shown below.



For both compilers, the default calling convention is normally __cdecl but can be changed to __stdcall. Do not change the default calling convention to __stdcall if you plan to generate static library or object files for both compatible external compilers.

Syntax Error
If the DLL you want to include uses WINAPI, then you will need to use the _stdcall calling convention as described above. You can check if your DLL uses WINAPI by opening the header file and looking at the function prototypes. If the function prototypes are of the form datatype WINAPI functionname(parameters); then the DLL requires _stdcall. To build successfully, WINAPI must be replaced with _stdcall for each function prototype in the header file.

Leaving WINAPI in the function prototype will result in a syntax error for each function: "headerfile.h"(1,20) syntax error; found 'identifier' expecting ';'. Where headerfile.h is the name of your header file.

If you are unsure as to the calling convention of the DLL, contact the author of the DLL or attempt to try the other calling convention.

Related Links:
KnowledgeBase 2RCKK3TL: Calling Conventions in LabWindows/CVI

Attachments:


BuildOptions.GIF


Report Date: 04/10/2006
Last Updated: 11/17/2016
Document ID: 3W9DPTG2

Your Feedback! poor Poor  |  Excellent excellent   Yes No
 Document Quality? 
 Answered Your Question? 
  1 2 3 4 5
Please Contact NI for all product and support inquiries.submit