LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Undefined symbol which is defined in my Dynamic project

Solved!
Go to solution

I am new to LanWindows and working on a Legacy application, which has many projects defined as Dynamic Link Library using 2010 LabWindows .

 

I created a new Dynamic Link Project, say my_DLL_prj.  Added into the workspace. In Target Type, set a header file mytest.h in DLL Export Options dialogue. then I build this my_DLL_prj.  LabWindows reported my_DLL_prj.dll and my_DLL_prj.lib are created correctly.

 

In main application, added the mytest.h file to main project, added the my_DLL_prj.lib into the main project. then in main.c file, I call a function, my_test() defined in mytest.h file from  my_DLL_prj.  

 

It complains link errors - Undefined symbol '_my_test' reference in 'main.c'.

 

Since it is an legacy project from many years ago, I am trying to look through existing projects hopefully can find some clue.  All existing DLL project will create a file named exports in the cvibuild.projectX folderand inside this file, there is a symbol of function names that are exported

[ShowSWFP_X]
callConv = 115
name = ShowSWFP_X
paramSize = 20

 

But my_DLL_prj does not generate a exports file.

 

I had read the NI LabWindows/CVI help for roughly one week already... did not find a clue.

 

Many thanks.

 

0 Kudos
Message 1 of 3
(2,180 Views)

Other than the help you can get infos using the provided sample projects.

The "Find Examples..." item is on the lower left of the Welcome Page and in the Help menu.

Search for "DLLs" there to get a list of suitable projects.

 

Just make absolutely sure that your exported function and the prototype(s) match and (best practice) have an explicit calling convention decorator like CVICALLBACK, WINAPI, __cdecl or __stdcall.

-----------------------
/* Nothing past this point should fail if the code is working as intended */
Message 2 of 3
(2,104 Views)
Solution
Accepted by topic author qing22

Hello CVI-User,

Thank you. Yes, I missed the __cdecl .  So, I used something like the following for the h file in my DLL project:
 
#ifdef PART_OF_xxx_IF
#define xxx_IF __export __cdecl
#else
#define xxx_IF __import __cdecl
#endif
 
This way, in my DLL c file, I defined the PART_OF_xxx_IF which will use the export.  In my main project, I do not define the PART_OF_xxx_IF, which will be the import.
 
 
 
0 Kudos
Message 3 of 3
(2,057 Views)