From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
01-06-2016 10:15 AM - edited 01-06-2016 10:30 AM
Ok, here's a strange problem. I'm very new to creating DLLs, so I'm sure I just have a setup problem.
But I'm trying to pass a global variable from a host program to its attached DLL. I had this working when I was on CVI 2014. I recently upgraded to 2015, and then started getting "undefined symbols" errors. With some wrestling, I got it to compile again, but broke the variable connection in the process.
I've compiled my DLL in debug mode so that I step into it from the test project. Right now, my global variable exists in the test project as well as in the DLL.
Do I need to export the variable as well as use DLLEXPORT/DLLIMPORT? Confused, and oddly not finding anything quite like this on the forums.
EDIT: this Stack Overflow post pretty well describes my experience. I'm statically linking as well.
Solved! Go to Solution.
01-07-2016 01:05 PM
Hi ElectroLund,
I see that you are working this same issue with one of our support engineers. Once there is a solution to this, I think that we should post it here for the rest of the forum users to see.
--G-IV
01-13-2016 03:55 PM
UPDATE
Support was unable to help resolve, particularly because this was more of a C programming question, rather than a CVI framework question.
01-14-2016 08:54 AM
Well, what do you know? I figured out my issue. This NI article and example project were vital to the solution. Also helpful was this article called, "Using the Export Qualifier Method". I'll cut to the chase...
If you use an export qualifier on the definition and an import qualifier on the declaration, LabWindows/CVI exports the symbol.
That's the key right there.
So in my example, it should look like this:
DLL file.c
int DLLEXPORT varName = 0;
DLL header.h
int DLLIMPORT varName;
Project that uses DLL.c
#include "DLL header.h" varName != 1; // some method of changing this variable in local usage
Pretty easy, huh? But wow, this took a long time to find.
01-15-2016 03:19 AM
ElectroLund ha scritto:
But wow, this took a long time to find.
So thank you for describing the solution: it will save time to others who may be in the same situation
01-27-2016 08:50 AM
Hi Electrolund,
Here is a pair of tightly related web resources that you may also want to keep in your repertoire when writing DLLs:
The Ultimate (DLL) Header File:
http://www.flounder.com/ultimateheaderfile.htm
CodeProject source code for "The Ultimate (DLL) Header File"
http://www.codeproject.com/Articles/812/The-Ultimate-DLL-Header-File
Same author for both of these, BTW...
JB