470,833 Members | 1,375 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,833 developers. It's quick & easy.

static member variable in a DLL...

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!

Apr 10 '06 #1
1 2672
On 9 Apr 2006 23:37:03 -0700, "medleykupps" <me*********@hotmail.com>
wrote in comp.lang.c++:
Hi!

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


Off-topic here, try news:comp.os.ms-windows.programmer.win32 or one of
Microsoft's support groups in the news:microsoft.public.* family. We
only discuss the standard C++ language here, not OS specific
extensions like DLLs.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://c-faq.com/
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
Apr 10 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by IHateSuperman | last post: by
29 posts views Thread by Alexander Mahr | last post: by
16 posts views Thread by Eric | last post: by
7 posts views Thread by ank | last post: by
10 posts views Thread by Rene | last post: by
1 post views Thread by mangalalei | last post: by
5 posts views Thread by John Goche | last post: by
13 posts views Thread by yanlinlin82 | last post: by
reply views Thread by mihailmihai484 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.