static member variable in a DLL...

M

medleykupps

Hi!

My linker is giving me a LNK2001 error while building a DLL.

My program looks somewhat like...

I have a DLL project (C1.dll) that contains a sortable list class
CMyList that has a static member variable ... a function pointer ... to
allow me to compare two objects in the list.

Another project I use is the main MFC application (P.exe). Inside this
I have dialogs that use CMyList without any problem.

Unfortunately, I have yet another DLL project (W.dll) that is used by
P.exe and contains dialogs that should ideally use CMyList as well. The
problem I get is that my linker throws a LNK2001 when building W.dll.

To show some code...

--- C1.dll Project ---

- MyList.h -

typedef int (*mylist_CompareFunction) (const int, const CString *,
const CString *); // my compare function type

class CMyList
{
public:
static mylist_CompareFunction m_compareFn; // function pointer
}

- MyList.cpp -

mylist_CompareFunction MyList::m_compareFn; // definition of compare
function

--- P.exe ---

MyListDlg - uses MyList from C1 without any problems

--- W.dll ---

AnotherListDlg - attempts to use MyList also from C1 but cannot -

error LNK2001: unresolved external symbol

Help pls!
 
J

Jack Klein

Hi!

My linker is giving me a LNK2001 error while building a DLL.

Off-topic here, try or one of
Microsoft's support groups in the family. We
only discuss the standard C++ language here, not OS specific
extensions like DLLs.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,118
Latest member
LatishaWhy
Top