Page 1 of 1

How do you build/use a TChart AX wrapper dll, C++ MFC App

Posted: Thu Sep 01, 2016 12:58 am
by 16677390
I built and ran the C++ examples in VS 2008, 32 bit.
I built and ran a basic C++ MFC Dialog app with a CTChart and updated it with an array of data.
I moved the TeeChart files into a TeeChard.dll project in the solution but cant get the executable to link.
It builds a dll and lib file but wont link the exe, looks like the functions aren't exported into the lib file or something?

VS 2008 Output:
1>------ Build started: Project: RTFMChart, Configuration: Debug Win32 ------
1>Linking...
1>RTFMChartDlg.obj : error LNK2001: unresolved external symbol "public: virtual struct CRuntimeClass * __thiscall CTChart::GetRuntimeClass(void)const " (?GetRuntimeClass@CTChart@@UBEPAUCRuntimeClass@@XZ)
1>RTFMChartDlg.obj : error LNK2019: unresolved external symbol "public: void __thiscall CPage::SetMaxPointsPerPage(long)" (?SetMaxPointsPerPage@CPage@@QAEXJ@Z) referenced in function "public: void __thiscall CRTFMChartDlg::OnBnClickedBtnMfchart(void)" (?OnBnClickedBtnMfchart@CRTFMChartDlg@@QAEXXZ)
1>RTFMChartDlg.obj : error LNK2019: unresolved external symbol "public: class CPage __thiscall CTChart::GetPage(void)" (?GetPage@CTChart@@QAE?AVCPage@@XZ) referenced in function "public: void __thiscall CRTFMChartDlg::OnBnClickedBtnMfchart(void)" (?OnBnClickedBtnMfchart@CRTFMChartDlg@@QAEXXZ)
1>RTFMChartDlg.obj : error LNK2019: unresolved external symbol "public: void __thiscall CSeries::FillSampleValues(long)" (?FillSampleValues@CSeries@@QAEXJ@Z) referenced in function "public: void __thiscall CRTFMChartDlg::OnBnClickedBtnMfchart(void)" (?OnBnClickedBtnMfchart@CRTFMChartDlg@@QAEXXZ)
1>RTFMChartDlg.obj : error LNK2019: unresolved external symbol "public: void __thiscall CSeries::Clear(void)" (?Clear@CSeries@@QAEXXZ) referenced in function "public: void __thiscall CRTFMChartDlg::OnBnClickedBtnMfchart(void)" (?OnBnClickedBtnMfchart@CRTFMChartDlg@@QAEXXZ)
1>RTFMChartDlg.obj : error LNK2019: unresolved external symbol "public: class CSeries __thiscall CTChart::Series(long)" (?Series@CTChart@@QAE?AVCSeries@@J@Z) referenced in function "public: void __thiscall CRTFMChartDlg::OnBnClickedBtnMfchart(void)" (?OnBnClickedBtnMfchart@CRTFMChartDlg@@QAEXXZ)
1>RTFMChartDlg.obj : error LNK2019: unresolved external symbol "public: void __thiscall CAspect::SetView3D(int)" (?SetView3D@CAspect@@QAEXH@Z) referenced in function "public: void __thiscall CRTFMChartDlg::OnBnClickedBtnMfchart(void)" (?OnBnClickedBtnMfchart@CRTFMChartDlg@@QAEXXZ)
1>RTFMChartDlg.obj : error LNK2019: unresolved external symbol "public: class CAspect __thiscall CTChart::GetAspect(void)" (?GetAspect@CTChart@@QAE?AVCAspect@@XZ) referenced in function "public: void __thiscall CRTFMChartDlg::OnBnClickedBtnMfchart(void)" (?OnBnClickedBtnMfchart@CRTFMChartDlg@@QAEXXZ)
1>RTFMChartDlg.obj : error LNK2019: unresolved external symbol "public: long __thiscall CTChart::AddSeries(long)" (?AddSeries@CTChart@@QAEJJ@Z) referenced in function "public: void __thiscall CRTFMChartDlg::OnBnClickedBtnMfchart(void)" (?OnBnClickedBtnMfchart@CRTFMChartDlg@@QAEXXZ)
1>C:\DEV_ChartTest\RTFMChart\Debug\RTFMChart.exe : fatal error LNK1120: 9 unresolved externals
1>Build log was saved at "file://c:\DEV_ChartTest\RTFMChart\RTFMChart\Debug\BuildLog.htm"
1>RTFMChart - 10 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 1 up-to-date, 0 skipped ==========

Ive been trying to get it to work for a considerable time now but I'm missing something and need some help. :?

Is there an MFC example of the best way to build and use a TeeChart AX dll wrapper properly???
Ive seen mention of it being done but cant find any details.
Its been a while since I built/used a dll from scratch. Must be getting old.

I've added a TChart to my application on a property page.
Our project already builds 30 dll's and uses a few 3rd party dll's.
The base directory for the exe already has 2,626 cpp and h files, so I don't want to dump another 750+ TeeChart files into it, I'll get fired.
I'd like to put the TeeChart files into a dll project in our solution and have a C or C++ function library dll and lib file like our other dll's. (or COM interface?)
I was told by sales this is possible and it won't effect other developers from building our solution.

Thanks for the help in advance. :D

I asked my boss to get the priority support but I think he forgot. :(

Cheers,
Richard

Re: How do you build/use a TChart AX wrapper dll, C++ MFC App

Posted: Thu Sep 01, 2016 12:09 pm
by Marc
Hello Richard,

Re.
"unresolved external symbol "
This often means that it can't find the referenced file. Check that the source files (not just the headers) are in a Project-pathed location.

This post on StackOverflow offers a couple of suggestions to resolve the issue:

http://stackoverflow.com/questions/7004 ... -externals

Re.
Is there an MFC example of the best way to build and use a TeeChart AX dll wrapper properly???
Sorry, there's no dll example; the examples included with TeeChart are desktop apps. This thread though, seems to cover an area similar to what you are looking for and seems to have helped resolve the question in hand.

http://www.teechart.net/support/viewtop ... ed5#p69362

Regards,
Marc Meumann

Re: How do you build/use a TChart AX wrapper dll, C++ MFC App

Posted: Fri Sep 09, 2016 5:48 pm
by 16677390
Marc,

Thanks for the reply and great links, I really appreciate it.
It's compiling, linking and running fine now as a static lib. ( C++ MFC, Visual studio 2008, 32 bit)

I created a directory and new project in my solution called "MyTeeChart" with all the files from "New VC Classes"
selecting Win32, then Static Libraby in the wizard with
"Use MFC in a Static DLL" option
this built a "Static Libraby (lib)" MyTeeChart.lib
I copy the lib file to our existing lib directory in our solution, using Post-Build Event, command line "copy $(OutDir)\MyTeeChart.lib ..\Lib"

Then in my main project i added the 2 settings
(the lib path is in the "Linker Addition Library Directories" ..\Lib)
C/C++ under "Addition Include Directories" "..\MyTeeChart" directory which has all the Steema "New VC Classes" .h and .cpp files, (I will split this into sub directories (SRC/Inc) next week)
That lets me use the header files like #include "tchart.h" and #include "TeeChartDefines.h" in my .h and .cpp files.
Then add the lib to the "Linker" "Inputs" " MyTeeChart.lib" to the linker inputs
Have to do this at least twice, for both debug and release configuration settings in the main project.

That's the basics but it may help the next developer get up and running fast with a static lib.

May try and use the existing or a ne built dll in our 64 bit future.
I'll probably have my next question in a week or so. :)
Need to add SPC chart lines onto the chart. ie Target level, Adjust limits, Spec limits, etc in µl


Cheers,
Richard

Re: How do you build/use a TChart AX wrapper dll, C++ MFC App

Posted: Fri Sep 09, 2016 5:48 pm
by 16677390
Marc,

Thanks for the reply and great links, I really appreciate it. :)
It's compiling, linking and running fine now as a static lib. ( C++ MFC, Visual studio 2008, 32 bit, Old School)

I created a directory and new project in my solution called "MyTeeChart" with all the files from "New VC Classes"
selecting Win32, then Static Libraby in the wizard with
"Use MFC in a Static DLL" option
this built a "Static Libraby (lib)" MyTeeChart.lib
I copy the lib file to our existing lib directory in our solution, using Post-Build Event, command line "copy $(OutDir)\MyTeeChart.lib ..\Lib"

Then in my main project i added the 2 settings
(the lib path is in the "Linker Addition Library Directories" ..\Lib)
C/C++ under "Addition Include Directories" "..\MyTeeChart" directory which has all the Steema "New VC Classes" .h and .cpp files, (I will split this into sub directories (SRC/Inc) next week)
That lets me use the header files like #include "tchart.h" and #include "TeeChartDefines.h" in my .h and .cpp files.
Then add the lib to the "Linker" "Inputs" " MyTeeChart.lib" to the linker inputs
Have to do this at least twice, for both debug and release configuration settings in the main project.

That's the basics but it may help the next developer get up and running fast with a static lib. :?

May try and use the existing or a ne built dll in our 64 bit future.
I'll probably have my next question in a week or so. :wink:
Need to add SPC chart lines onto the chart. ie Target level, Adjust limits, Spec limits, etc in µl


Cheers,
Richard