I has core dll library called Lib1, I has main application that depends on Lib1 and another extension dll library called POS, It also depend on Lib1, I add the Lib1 as in the references of the project properties, it see the .lib automatically. I added the following .h and .cpp files to the Lib1
//MenuBarEx.h
class AMNLIB1_API TMenuBarEx : public CMFCMenuBar
{
DECLARE_DYNAMIC(TMenuBarEx)
public:
TMenuBarEx()
{
NONCLIENTMETRICS ncm;
ncm.cbSize = sizeof(NONCLIENTMETRICS) - sizeof(ncm.iPaddedBorderWidth);
ZeroMemory(&m_logFont, sizeof(LOGFONT));
if (SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &ncm, 0))
{
m_logFont = ncm.lfMenuFont;
TCHAR fontName[] = _T("tahoma");
_tcscpy_s(m_logFont.lfFaceName, fontName);
CMFCMenuBar::SetMenuFont(&m_logFont);
}
}
virtual ~TMenuBarEx()
{
}
BOOL LoadState(LPCTSTR lpszProfileName /* = NULL */, int nIndex /* = -1 */, UINT uiID /* = */ )
{
return TRUE;
}
BOOL SaveState(LPCTSTR lpszProfileName /* = NULL */, int nIndex /* = -1 */, UINT uiID /* = */ )
{
return TRUE;
}
protected:
static LOGFONT m_logFont;
//DECLARE_MESSAGE_MAP()
};
//-------------------------------------------
//.cpp
#include "stdafx.h" // precompiled header
#include "MenuBarEx.h"
IMPLEMENT_DYNAMIC(TMenuBarEx, CMFCMenuBar)
LOGFONT TMenuBarEx::m_logFont;
The Lib1 build successfully and the main application that uses the class TMenuBarEx also build successfully, the library POS fail in build giving the error
POSMain.obj : error LNK2001: unresolved external symbol "protected: static struct tagLOGFONTA TMenuBarEx::m_logFont" (?m_logFont@TMenuBarEx@@1UtagLOGFONTA@@A)
this is really strange because it is defined in the cpp and worked in the main application, and many other extension libraries are using the core Lib1 and build successfully.
when I want to pass through this I redefine it again in the POSMain.cpp this is so bad but I do it to finish the release How can I fix it or even track it???