I have been unable to compile wxWebView in my C++ code.
#include <wx/wx.h>
#include <wx/wxhtml.h>
#include <wx/webview.h>
class MyFrame : public wxFrame
{
public:
MyFrame();
wxPanel *panel;
wxBoxSizer *topsizer;
wxMenuBar *menubar;
wxMenu *file;
wxWebView *webView; // <---- HERE
wxString editorURL;
};
I get the following compiler errors (snippet):
g++ -c `wx-config --cxxflags` -o helloworld.o helloworld.cpp
helloworld.cpp:20:5: error: ‘wxWebView’ does not name a type; did you mean ‘wxWeakRef’?
wxWebView *webView;
^~~~~~~~~
wxWeakRef
Some more information on system configuration:
The only thing I can think of is I am missing a package in apt-get or I have conflicting packaging.
$ dpkg -l | grep webview
ii libwxgtk-webview3.0-gtk3-0v5:amd64 3.0.4+dfsg-3 amd64 wxWidgets Cross-platform C++ GUI toolkit (GTK+ 3 webview library runtime)
ii libwxgtk-webview3.0-gtk3-dev 3.0.4+dfsg-3 amd64 wxWidgets Cross-platform C++ GUI toolkit (GTK+ 3 webview library development)
$ dpkg -l | grep webkit
ii gir1.2-webkit-3.0:amd64 2.4.11-3ubuntu3 amd64 Web content engine library for GTK+ - GObject introspection data
ii gir1.2-webkit2-4.0:amd64 2.20.3-0ubuntu0.18.04.1 amd64 Web content engine library for GTK+ - GObject introspection data
ii libwebkit2gtk-4.0-37:amd64 2.20.3-0ubuntu0.18.04.1 amd64 Web content engine library for GTK+
ii libwebkitgtk-1.0-0:amd64 2.4.11-3ubuntu3 amd64 Web content engine library for GTK+
ii libwebkitgtk-3.0-0:amd64 2.4.11-3ubuntu3 amd64 Web content engine library for GTK+
ii libwebkitgtk-3.0-dev:amd64 2.4.11-3ubuntu3 amd64 Web content engine library for GTK+ - development files
ii libwebkitgtk-dev:amd64 2.4.11-3ubuntu3 amd64 Web content engine library for GTK+ - development files
If you can help me figure out which packages I need for wxWebView to compile and what do I need to update in the Makefile to get it to compile.
It looks like your version of wxWidgets was built without wxWebView support. You can check it by greeping for wxUSE_WEBVIEW
in the setup.h
file included in your wxWidgets package.
If this is indeed the case, you will need to build your own version of the library. Luckily, this is as simple as the usual ./configure && make
under Unix (you don't even need to install it, although you may do it, of course).
Last but not least: don't forget that you need to explicitly ask for webview library when using this class, i.e. use wx-config --libs std,webview
instead of just wx-config --libs
.