Storing data members in a dll

Hello,

So I am now good with creating functions and exporting them in a DLL, now what I would like to do is have data members that reside inside the DLL so it doesn't have to rely on inputs to the functions to get all the numbers.

simply put I want to be able to have a string stored in the dll that says "hello im inside a dll!" and be able to call an exported function to return that string, as well as one to edit it.


I looked around for a simple tutorial but the only saw walkthroughs for function exportation on it...



Thank you for the help!
I see no problem.. What did you try and how did it fail ?
well i have an Objects.h file that I put static double myVar inside the class and then declared a get and set which i then wrote the functionality for in the Objects.cpp file...

so then I got a error LNK2001: unresolved external symbol " public: static double Objects::myVar" (when I call the set from another function in my functions.cpp file via obj.setmyVar(12.0))

so essentially....I don't know where I should create/store variables...


Thanks for your help,
~G
Last edited on
A little more info...

the whole process works if I make the variable not static....however I would very much like it to be static so I can have a central storage space that multiple functions can modify.

Thanks!
When you have a static variable, you need to declare it twice.
1
2
3
4
//header
struct S{
   static int x;
};
and
1
2
3
//cpp
#include "header"
int S::x;

Or did you just not mention that..
perfect! exactly what I was looking for!

(completely new to this so sorry for the obvious question)

Thanks!
~G
Topic archived. No new replies allowed.