简体   繁体   中英

unresolved externals in C++ DLLs

I am trying to develop a DLL that can be instantiated and then keep its data between calls. It has been many years since i did this, so i am running into lots of problems. First, i declare the DLL like this:

namespace LibTest {
class TestClass
{
public:
    static void __declspec(dllexport) initialize();
    static void __declspec(dllexport) add(double v);
    static double __declspec(dllexport) report();
protected:
    static double DV;
};

}

and the DLL code looks like:

namespace LibTest {
 void TestClass::initialize()
{
    DV = 0;
 }
 void TestClass::add(double v)
{
    DV = DV+v;
 }  
 double TestClass::report()
{
    return DV;
 }

}

When i tried to compile it with Visual Studio, it reports an "unresolved external".
Couple of questions here a. Did i have the declaration right for what i need to do? (keeping the variables between calls) b. how to resolve the external references

As i mentioned, it has been many years since i do any programming, so any help will be much appreciated.

Regards

Chien

You forgot to declare member variable:

    double TestClass::DV;

EDIT: This should be within namespace LibTest , of course

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM