Setting up wxWidgets with wxChartDir for Visual Studio 2019.

Do you have a question about makefiles, a compiler or IDE you are using and need to know how to set it up for wxWidgets or why it doesn't compile but other IDE's do ? Post your questions here.
Post Reply
User avatar
Riser
In need of some credit
In need of some credit
Posts: 8
Joined: Tue Sep 14, 2021 6:47 pm

Setting up wxWidgets with wxChartDir for Visual Studio 2019.

Post by Riser »

I already have wxWidgets up and running, I want to use ChartDirector with it, at the bottom of this (1) page it says ChartDirector is already included within wxChartDir (Well, the trial version is, but that's all I need) so I'll only need to install that, but I don't know how to approach this, the github repository (2) mentions Premake which I never used before....

So can someone either provide me with or point towards a step-by-step guide to installing wxChartDir?

I apologize for the amateur question, it's just that I worked with the standard C++ library for most of my projects up to this point so I'm not used to handling 3rd party libraries.

Thank you.


1: (https://www.wxwidgets.org/blog/2018/08/ ... lications/)
2: (https://github.com/utelle/wxchartdir)
utelle
Moderator
Moderator
Posts: 1125
Joined: Tue Jul 05, 2005 10:00 pm
Location: Cologne, Germany
Contact:

Re: Setting up wxWidgets with wxChartDir for Visual Studio 2019.

Post by utelle »

Riser wrote: Wed Sep 15, 2021 2:31 pm I already have wxWidgets up and running, I want to use ChartDirector with it, at the bottom of this (1) page it says ChartDirector is already included within wxChartDir (Well, the trial version is, but that's all I need) so I'll only need to install that, but I don't know how to approach this, the github repository (2) mentions Premake which I never used before....
In fact, you don't need Premake to use wxChartDir, unless you want to regenerate the build files which are included with wxChartDir.

BTW, the ChartDirector trial version is identical with the production version. The only difference is that you need a license file to remove the trial version banner from the resulting graphics.
Riser wrote: Wed Sep 15, 2021 2:31 pm So can someone either provide me with or point towards a step-by-step guide to installing wxChartDir?
For compiling and testing the sample applications you find ready made solution files for VC++ 2019 (aka wxchartdir_vc16.sln) in the subdirectory wxdemo/build (wxWidgets based samples) resp cppdemo/build (C++ samples just demonstrating the capabilities of ChartDirector). Depending on your wxWidgets installation you may need to adjust the property file wx_setup.props.

For your own applications you typically only need the wxChartViewer component (source files located in subdirectory wxdemo/common). Of course, you can use the library built together with the demo applications, but frequently developers just add the wxChartViewer source files to their own project.

If you have issues with wxChartDir I would recommend that you use the wxChartDir issue tracker. The advantage compared to the wxWidgets forum is that I will be notified, when new issues are created, while I have to actively visit the forum to detect new postings related to my wxWidgets components.

Kind regards,
Ulrich
User avatar
Riser
In need of some credit
In need of some credit
Posts: 8
Joined: Tue Sep 14, 2021 6:47 pm

Re: Setting up wxWidgets with wxChartDir for Visual Studio 2019.

Post by Riser »

I'm trying to make my own apps, you're telling it's as simple as just adding the source files to my project?
Should've tried that first.
But before I try that, the documentation class list contains two classes: wxChartViewer & wxViewPortControl...

You mentioned the first, but they both have the same description, do I need the second?
https://utelle.github.io/wxchartdir/doc ... tated.html
utelle
Moderator
Moderator
Posts: 1125
Joined: Tue Jul 05, 2005 10:00 pm
Location: Cologne, Germany
Contact:

Re: Setting up wxWidgets with wxChartDir for Visual Studio 2019.

Post by utelle »

Riser wrote: Wed Sep 15, 2021 5:03 pm I'm trying to make my own apps, you're telling it's as simple as just adding the source files to my project?
Yes, in principle it is as simple as that. Of course, you need to add references to the ChartDirector library (header include path, link libraries etc). Inspect the Visual C++ project and solution file to find out what you need to specify.
Riser wrote: Wed Sep 15, 2021 5:03 pm But before I try that, the documentation class list contains two classes: wxChartViewer & wxViewPortControl...

You mentioned the first, but they both have the same description, do I need the second?
It depends. You always need the wxChartViewer class to display a chart on screen. The viewport control displays a miniature "overall chart" that shows the full data range of a chart. This control allows the user to interactively select the portion of the chart that should be displayed in the chart viewer control. That is, the class wxViewPortControl is only required if your application should support such user interaction.

Please inspect the samples coming with wxChartDir to get an impression what you can do with the viewport control. Thereafter you can decide whether you want to use it or not.

BTW, both classes are implemented in a single source file. That is, when you compile the sources you always have both classes ready for use.
User avatar
Riser
In need of some credit
In need of some credit
Posts: 8
Joined: Tue Sep 14, 2021 6:47 pm

Re: Setting up wxWidgets with wxChartDir for Visual Studio 2019.

Post by Riser »

Ok, I've been going through the folder for a while now, and I'm confused as to which files I should grab...

There's the chartdir files file(s) in the "include" folder, but the ChartViewer class files are in the "wxdemo/common" folder, which ones do I need?

As for library linking, I'm assuming you're just talking about what's in the "lib" folder right?
I'm using Windows x64 so I'm guessing I only need to look at the corresponding file, kind of forgot how set them up but I'll figure it out.
utelle
Moderator
Moderator
Posts: 1125
Joined: Tue Jul 05, 2005 10:00 pm
Location: Cologne, Germany
Contact:

Re: Setting up wxWidgets with wxChartDir for Visual Studio 2019.

Post by utelle »

Riser wrote: Wed Sep 15, 2021 7:52 pm Ok, I've been going through the folder for a while now, and I'm confused as to which files I should grab...
At first glance, the folder structure may be a bit confusing. However, I closely followed the folder structure you find in the ChartDirector distribution. The reason for this approach is that this allows developers to make use of the original ChartDirector documentation, which you will have to consult anyway when you start implementing your own graphics charts.
Riser wrote: Wed Sep 15, 2021 7:52 pm There's the chartdir files file(s) in the "include" folder, but the ChartViewer class files are in the "wxdemo/common" folder, which ones do I need?
Both. Folder include contains the header files for the ChartDirector library. wxChartViewer needs them, but your own application will need them, too. Folder wxdemo/common contains all source files required for the wxWidgets related controls wxChartViewer and wxViewportControl. And for linking and runtime you need the files in folder lib, in your case the files in folder lib/win64.
Riser wrote: Wed Sep 15, 2021 7:52 pm As for library linking, I'm assuming you're just talking about what's in the "lib" folder right?
Yes, that is correct.
Riser wrote: Wed Sep 15, 2021 7:52 pm I'm using Windows x64 so I'm guessing I only need to look at the corresponding file, kind of forgot how set them up but I'll figure it out.
There is not so much to do. For the C++ preprocessor you need to specify the path to the ChartDirector header files, that is folder include and of course the wxChartViewer header files (wherever you place them). For the linker you need to specify the library path, that is folder lib/win64, and the name of the library itself, that is chartdir70.lib. That should be all.
User avatar
Riser
In need of some credit
In need of some credit
Posts: 8
Joined: Tue Sep 14, 2021 6:47 pm

Re: Setting up wxWidgets with wxChartDir for Visual Studio 2019.

Post by Riser »

Ok, I got ChartDirector working, with some tweaking I got one of the samples working, creating a chart and outputting to it PNG, thank you.
(By the way, since I have my target platform set to win32, it did not work until I linked the win32 lib instead of the 64 one).

But now I want to be able to display the chart within the frame and have the option to interact with it.
However I can't seem to be able to get wxChartViewer and wxViewportControl to work.
Tried testing the "Hello World sample" but it gave me a linking error:
1>helloworld.obj : error LNK2019: unresolved external symbol "public: __thiscall wxChartViewer::wxChartViewer(class wxWindow *,int,class wxPoint const &,class wxSize const &,long,class wxString const &)" (??0wxChartViewer@@QAE@PAVwxWindow@@HABVwxPoint@@ABVwxSize@@JABVwxString@@@Z) referenced in function "public: void __thiscall HelloWorld::CreateControls(void)" (?CreateControls@HelloWorld@@QAEXXZ)
1>D:\Projects\Practice\C++\Attempts\First wxWidgets App\Debug\wxWidgetsApp.exe : fatal error LNK1120: 1 unresolved externals
1>Done building project "wxWidgetsApp.vcxproj" -- FAILED.
Let me give you a quick run down of what I did:
-Copied the contents of both "include" and "wxdemo/common" to the a folder called "wxCharDir", this folder itself being located in the project folder.
-Added that folder's path to the Additional Include Directories.
-Copied the "lib" folder inside the "wxCharDir" folder.
-Added the win32 path to the Additional Library Directories.
-Added the .lib file to the Additional Dependencies.
-Copied the .dll file from the win32 folder to the project folder.

Did I do anything worng?
User avatar
doublemax
Moderator
Moderator
Posts: 19115
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Setting up wxWidgets with wxChartDir for Visual Studio 2019.

Post by doublemax »

It looks like you only forgot to add wxchartviewer.cpp to the project.
Use the source, Luke!
User avatar
Riser
In need of some credit
In need of some credit
Posts: 8
Joined: Tue Sep 14, 2021 6:47 pm

Re: Setting up wxWidgets with wxChartDir for Visual Studio 2019.

Post by Riser »

Nope, it's there.
User avatar
doublemax
Moderator
Moderator
Posts: 19115
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Setting up wxWidgets with wxChartDir for Visual Studio 2019.

Post by doublemax »

Riser wrote: Thu Sep 16, 2021 11:00 pm Nope, it's there.
With adding i didn't mean copying the file into the folder, i meant adding the source file to the project so that it gets compiled and linked. If the wxChartViewer constructor is not found, that's the only explanation i can think of.
Use the source, Luke!
utelle
Moderator
Moderator
Posts: 1125
Joined: Tue Jul 05, 2005 10:00 pm
Location: Cologne, Germany
Contact:

Re: Setting up wxWidgets with wxChartDir for Visual Studio 2019.

Post by utelle »

Riser wrote: Thu Sep 16, 2021 9:12 pm Ok, I got ChartDirector working, with some tweaking I got one of the samples working, creating a chart and outputting to it PNG, thank you.
(By the way, since I have my target platform set to win32, it did not work until I linked the win32 lib instead of the 64 one).
Well, in one of your first postings you mentioned to use Windows x64. Therefore I assumed you intended to build a 64-bit application. For 64-bit applications you need the library files in lib/win64. However, for 32-bit applications you nee the library files in lib/win32, of course.
Riser wrote: Thu Sep 16, 2021 9:12 pm But now I want to be able to display the chart within the frame and have the option to interact with it.
However I can't seem to be able to get wxChartViewer and wxViewportControl to work.
Tried testing the "Hello World sample" but it gave me a linking error:
1>helloworld.obj : error LNK2019: unresolved external symbol "public: __thiscall wxChartViewer::wxChartViewer(class wxWindow *,int,class wxPoint const &,class wxSize const &,long,class wxString const &)" (??0wxChartViewer@@QAE@PAVwxWindow@@HABVwxPoint@@ABVwxSize@@JABVwxString@@@Z) referenced in function "public: void __thiscall HelloWorld::CreateControls(void)" (?CreateControls@HelloWorld@@QAEXXZ)
1>D:\Projects\Practice\C++\Attempts\First wxWidgets App\Debug\wxWidgetsApp.exe : fatal error LNK1120: 1 unresolved externals
1>Done building project "wxWidgetsApp.vcxproj" -- FAILED.
As doublemax already wrote you need to add the files wxchartviewer.cpp and wxchartviewer*.h physically and logically to your project: physically = copying the files into your project's folder; logically = add the files within your project/solution to the list of source files of the project.
Riser wrote: Thu Sep 16, 2021 9:12 pm Let me give you a quick run down of what I did:
-Copied the contents of both "include" and "wxdemo/common" to the a folder called "wxCharDir", this folder itself being located in the project folder.
-Added that folder's path to the Additional Include Directories.
-Copied the "lib" folder inside the "wxCharDir" folder.
-Added the win32 path to the Additional Library Directories.
-Added the .lib file to the Additional Dependencies.
-Copied the .dll file from the win32 folder to the project folder.

Did I do anything worng?
It looks like that you forgot to add the wxChartViewer source files logically to your project.
User avatar
Riser
In need of some credit
In need of some credit
Posts: 8
Joined: Tue Sep 14, 2021 6:47 pm

Re: Setting up wxWidgets with wxChartDir for Visual Studio 2019.

Post by Riser »

Well that was odd, it worked, in fact I actually only had to include wxChartViewer.cpp for it to work, you can't fault me for not knowing that though, I don't understand why this file is a special case, I didn't have to add any of the other files logically...
Thank you both regardless.

However, there are still issues, I decided to try some of the other samples, and I encountered the same issues with all of them.

They do work, but I have to click my way through all of this:
https://i.imgur.com/bUA18P3.png

I could just check the "Don't show this dialogue again" option and ignore them, but I feel like I shouldn't.

And even after that, it's not working entirely as intended, the icons for the buttons aren't loading.
https://i.imgur.com/1YeiuRz.png
Here's the screenshot that comes with the sample code for comparison.
https://i.imgur.com/22for93.png

Could this be due with the samples' code being incompatible with the current version wxWidgets and/or wxChartDir?
If so then studying them to learn how to use the library might not be a good idea.
utelle
Moderator
Moderator
Posts: 1125
Joined: Tue Jul 05, 2005 10:00 pm
Location: Cologne, Germany
Contact:

Re: Setting up wxWidgets with wxChartDir for Visual Studio 2019.

Post by utelle »

Riser wrote: Fri Sep 17, 2021 8:10 pm Well that was odd, it worked, in fact I actually only had to include wxChartViewer.cpp for it to work, you can't fault me for not knowing that though, I don't understand why this file is a special case, I didn't have to add any of the other files logically...
Well, only if you set up a project for the first time Visual Studio scans the source directory and adds source files to the project automatically. Thereafter adding or deleting source files logically from a project is a manual process. Nothing to be amazed about ...
Riser wrote: Fri Sep 17, 2021 8:10 pm However, there are still issues, I decided to try some of the other samples, and I encountered the same issues with all of them.

They do work, but I have to click my way through all of this:
https://i.imgur.com/bUA18P3.png
Some of the samples need access to external image graphics files. Looking at the details in message box might reveal which file(s) is/are missing.
Riser wrote: Fri Sep 17, 2021 8:10 pm I could just check the "Don't show this dialogue again" option and ignore them, but I feel like I shouldn't.
Of course not. These messages clearly indicate that something is wrong. In this case image graphics files are not accessible. In the folder wxdemo/wxdemo you find subfolders icons and images - these folders contain the graphics files on which some of the samples depend. For your own project you need to make the graphics files accessible that the application depends on. Usually the application looks for the graphics files in the working directory.
Riser wrote: Fri Sep 17, 2021 8:10 pm And even after that, it's not working entirely as intended, the icons for the buttons aren't loading.
https://i.imgur.com/1YeiuRz.png
Here's the screenshot that comes with the sample code for comparison.
https://i.imgur.com/22for93.png
Again, you are getting these messages only, because the required graphics files are not found.
Riser wrote: Fri Sep 17, 2021 8:10 pm Could this be due with the samples' code being incompatible with the current version wxWidgets and/or wxChartDir?
If so then studying them to learn how to use the library might not be a good idea.
Nonsense. As soon as you make the graphics files accessible to the application, it will work as expected.
Post Reply