From: Luigino on
> This is linker error message. The real reason for the error message is
> that the linker does not see the implementation. Either you do not have
> the implementation for the CCaChart:.CCaChart(void) constructor of you
> are not including relevant object file on command line.

HI ismo,

as I said the VS DLL ClassWizard added the constructor and destructor
which are:

..CPP

CCaChart::CCaChart()
{
iGraphType = GRAPH_BARS;
RegisterWindowClass();
}

CCaChart::~CCaChart()
{
}

..H

class CCaChart : public CWnd
{
DECLARE_DYNAMIC(CCaChart)

public:
CCaChart();

public:
virtual ~CCaChart();
..
..
..
(plus other functions...)
}

and as I said before, I added in test application's properties the
path and the name of the lib file...
even I also added in the test application file the include to the
header...
So in fact it's weird to get this error... that's why I'm here asking
you...

Thanks
Luigi
From: Joseph M. Newcomer on
See below...
On Fri, 16 Oct 2009 00:59:16 -0700 (PDT), Luigino <npuleio(a)rocketmail.com> wrote:

>I tried this too:
>
>CStatic* c_CStaticPlaced = (CStatic *)GetDlgItem(IDC_MYSTATIC);
****
It is completely silly to use GetDlgItem in this case; you should create a control
variable!
****
>CRect r;
>c_CStaticPlaced->GetWindowRect(&r);
>ScreenToClient(&r);
>CCaChart* c_MyControl = new CCaChart();
****
Why do you new a 'new' here? This is silly. You can simply declare a CCaChart variable
in your class definition! There is ABSOLUTELY no reason to do a 'new'.
****
>CWnd* pWnd = c_CStaticPlaced->GetDlgItem(c_CStaticPlaced->GetDlgCtrlID
>());
>c_MyControl->Create(r, pWnd);
>c_CStaticPlaced->DestroyWindow();
>
>but I get this error:
>
>1>test_chartDlg.obj : error LNK2019: unresolved external symbol
>"public: __thiscall CCaChart::CCaChart(void)" (??0CCaChart@@QAE(a)XZ)
>referenced in function "protected: virtual int __thiscall
>Ctest_chartDlg::OnInitDialog(void)" (?
>OnInitDialog(a)Ctest_chartDlg@@MAEHXZ)
****
OnInitDialog is always virtual, so I see no issue here; I see no reference to CaChart as
virtual; what you probably failed to do was include the .lib file for your DLL, which is a
common mistake.
****
>
>but the constructor CaChart isn't declared as virtual in the header's
>class, plus it's public...
>
>Any suggest?...
>Thanks
>Ciao
>Luigi
Joseph M. Newcomer [MVP]
email: newcomer(a)flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
From: Joseph M. Newcomer on
So what? VS adding a declaration does not make that declaration visible to the client of
the DLL if you fail to include the .lib file in the linker command line. You are
confusing the C++ compiler with the linker here. They are different, and what you do in
C++ has no implicit effect on the linker. Go to the Linker, Inputs, and add your .lib
file to the additional libraries line.
joe
On Fri, 16 Oct 2009 05:19:05 -0700 (PDT), Luigino <npuleio(a)rocketmail.com> wrote:

>> This is linker error message. The real reason for the error message is
>> that the linker does not see the implementation. Either you do not have
>> the implementation for the CCaChart:.CCaChart(void) constructor of you
>> are not including relevant object file on command line.
>
>HI ismo,
>
>as I said the VS DLL ClassWizard added the constructor and destructor
>which are:
>
>.CPP
>
>CCaChart::CCaChart()
>{
> iGraphType = GRAPH_BARS;
> RegisterWindowClass();
>}
>
>CCaChart::~CCaChart()
>{
>}
>
>.H
>
>class CCaChart : public CWnd
>{
> DECLARE_DYNAMIC(CCaChart)
>
>public:
> CCaChart();
>
>public:
> virtual ~CCaChart();
>.
>.
>.
>(plus other functions...)
>}
>
>and as I said before, I added in test application's properties the
>path and the name of the lib file...
>even I also added in the test application file the include to the
>header...
>So in fact it's weird to get this error... that's why I'm here asking
>you...
>
>Thanks
>Luigi
Joseph M. Newcomer [MVP]
email: newcomer(a)flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
From: Luigino on

> confusing the C++ compiler with the linker here. They are different, and what you do in
> C++ has no implicit effect on the linker. Go to the Linker, Inputs, and add your .lib
> file to the additional libraries line.

Ehm I did... I put under Linker-General in Additional Library
Directories the path of that Debug directory where the .lib file is
created once compiled the DLL and I added under Linker-Input, in
Additional Dependencies that CACharts.lib.....
So I also created now a control variable (from the class add variable
wizard) for this and implemented the code:

CRect rect;
c_MyStaticControl.GetWindowRect(&rect);
ScreenToClient(&rect);
CCaChart c_MyControl;
c_MyControl.Create(rect, GetDlgItem
(c_MyStaticControl.GetDlgCtrlID()));
c_MyStaticControl.DestroyWindow();

but I get these linker errors:

1>test_chartDlg.obj : error LNK2019: unresolved external symbol
"public: virtual __thiscall CCaChart::~CCaChart(void)" (??
1CCaChart@@UAE(a)XZ) referenced in function "protected: virtual int
__thiscall Ctest_chartDlg::OnInitDialog(void)" (?
OnInitDialog(a)Ctest_chartDlg@@MAEHXZ)
1>test_chartDlg.obj : error LNK2019: unresolved external symbol
"public: virtual int __thiscall CCaChart::Create(class CRect const
&,class CWnd *)" (?Create(a)CCaChart@@UAEHABVCRect@@PAVCWnd@@@Z)
referenced in function "protected: virtual int __thiscall
Ctest_chartDlg::OnInitDialog(void)" (?
OnInitDialog(a)Ctest_chartDlg@@MAEHXZ)
1>test_chartDlg.obj : error LNK2019: unresolved external symbol
"public: __thiscall CCaChart::CCaChart(void)" (??0CCaChart@@QAE(a)XZ)
referenced in function "protected: virtual int __thiscall
Ctest_chartDlg::OnInitDialog(void)" (?
OnInitDialog(a)Ctest_chartDlg@@MAEHXZ)

So, suspecting a possible issue of my VS2008, I tried to create from
scratch with class wizards a simple stupid DLL without adding or
modifying anything and trying to create a Test file from Visual Studio
IDE itself and when it asks me to choose the DLL project to test, it
returns "Unknown address 0"... then I try to create a test project for
the example, adding the .lib and I get same linker error I pasted
before...
From: Stephen Myers on
Luigino wrote:
>> confusing the C++ compiler with the linker here. They are different, and what you do in
>> C++ has no implicit effect on the linker. Go to the Linker, Inputs, and add your .lib
>> file to the additional libraries line.
>
> Ehm I did... I put under Linker-General in Additional Library
> Directories the path of that Debug directory where the .lib file is
> created once compiled the DLL and I added under Linker-Input, in
> Additional Dependencies that CACharts.lib.....
> So I also created now a control variable (from the class add variable
> wizard) for this and implemented the code:
>
> CRect rect;
> c_MyStaticControl.GetWindowRect(&rect);
> ScreenToClient(&rect);
> CCaChart c_MyControl;
> c_MyControl.Create(rect, GetDlgItem
> (c_MyStaticControl.GetDlgCtrlID()));
> c_MyStaticControl.DestroyWindow();
>
> but I get these linker errors:
>
> 1>test_chartDlg.obj : error LNK2019: unresolved external symbol
> "public: virtual __thiscall CCaChart::~CCaChart(void)" (??
> 1CCaChart@@UAE(a)XZ) referenced in function "protected: virtual int
> __thiscall Ctest_chartDlg::OnInitDialog(void)" (?
> OnInitDialog(a)Ctest_chartDlg@@MAEHXZ)
> 1>test_chartDlg.obj : error LNK2019: unresolved external symbol
> "public: virtual int __thiscall CCaChart::Create(class CRect const
> &,class CWnd *)" (?Create(a)CCaChart@@UAEHABVCRect@@PAVCWnd@@@Z)
> referenced in function "protected: virtual int __thiscall
> Ctest_chartDlg::OnInitDialog(void)" (?
> OnInitDialog(a)Ctest_chartDlg@@MAEHXZ)
> 1>test_chartDlg.obj : error LNK2019: unresolved external symbol
> "public: __thiscall CCaChart::CCaChart(void)" (??0CCaChart@@QAE(a)XZ)
> referenced in function "protected: virtual int __thiscall
> Ctest_chartDlg::OnInitDialog(void)" (?
> OnInitDialog(a)Ctest_chartDlg@@MAEHXZ)
>
> So, suspecting a possible issue of my VS2008, I tried to create from
> scratch with class wizards a simple stupid DLL without adding or
> modifying anything and trying to create a Test file from Visual Studio
> IDE itself and when it asks me to choose the DLL project to test, it
> returns "Unknown address 0"... then I try to create a test project for
> the example, adding the .lib and I get same linker error I pasted
> before...
I thought you needed to export the symbols in the library.

In CaChart.h

Something like

#ifdef MYLIB_BUILD
#define MYDLL_IO _declspec(dllexport) //conditional on MYLIB_BUILD
#else
#define MYDLL_IO _declspec(dllimport)
#endif

class MYDLL_IO CCaChart: public ...

Then add MYLIB_BUILD to the library project
Configuration Properties
C/C++
Preprocessor
Preprocessor Defines

Steve