简体   繁体   中英

Starting with wxWidgets and C++

I am trying to understand how wxWidgets actually works. I want to build a C++ GUI app on OSX 10.11.1 just to learn C++.

Now I got wxWidgets from https://www.wxwidgets.org/downloads/ and I got the Linux/OSX version.

I extracted the source and run ./configure && make && make install as I saw from one question in here.

It seemed to have gone on for a while then I got this:

`In file included from ./include/wx/variant.h:401:
./include/wx/any.h:611:5: warning: expression with side effects will be evaluated despite being used as an operand to 'typeid' [-Wpotentially-evaluated-expression]
    WX_DECLARE_ANY_VALUE_TYPE(wxAnyValueTypeImplVariantData)
    ^
./include/wx/any.h:167:25: note: expanded from macro 'WX_DECLARE_ANY_VALUE_TYPE'
        return wxTypeId(*sm_instance.get()) == wxTypeId(*otherType); \
                        ^
./include/wx/typeinfo.h:84:47: note: expanded from macro 'wxTypeId'
#define wxTypeId(OBJ) wxTypeIdentifier(typeid(OBJ).name())
                                              ^
./src/osx/webview_webkit.mm:381:37: warning: incompatible pointer types sending 'WebViewLoadDelegate *' to parameter of type 'id<WebFrameLoadDelegate>' [-Wincompatible-pointer-types]
    [m_webView setFrameLoadDelegate:loadDelegate];
                                    ^~~~~~~~~~~~
./src/osx/webview_webkit.mm:387:34: warning: incompatible pointer types sending 'WebViewPolicyDelegate *' to parameter of type 'id<WebPolicyDelegate>' [-Wincompatible-pointer-types]
    [m_webView setPolicyDelegate:policyDelegate];
                                 ^~~~~~~~~~~~~~
./src/osx/webview_webkit.mm:392:30: warning: incompatible pointer types sending 'WebViewUIDelegate *' to parameter of type 'id<WKUIDelegate> _Nullable' [-Wincompatible-pointer-types]
    [m_webView setUIDelegate:uiDelegate];
                             ^~~~~~~~~~
./src/osx/webview_webkit.mm:464:34: warning: 'WKPreferences' may not respond to 'setUsesPageCache:'
        [[m_webView preferences] setUsesPageCache:NO];
         ~~~~~~~~~~~~~~~~~~~~~~~ ^
./src/osx/webview_webkit.mm:466:34: warning: 'WKPreferences' may not respond to 'setUsesPageCache:'
        [[m_webView preferences] setUsesPageCache:YES];
         ~~~~~~~~~~~~~~~~~~~~~~~ ^
./src/osx/webview_webkit.mm:936:25: error: cannot initialize a variable of type 'WebBackForwardList *' with an rvalue of type 'WKBackForwardList *'
    WebBackForwardList* history = [m_webView backForwardList];
                        ^         ~~~~~~~~~~~~~~~~~~~~~~~~~~~
./src/osx/webview_webkit.mm:954:25: error: cannot initialize a variable of type 'WebBackForwardList *' with an rvalue of type 'WKBackForwardList *'
    WebBackForwardList* history = [m_webView backForwardList];
                        ^         ~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 warnings and 2 errors generated.
make: *** [webviewdll_osx_webview_webkit.o] Error 1`

and it failed.

I have no idea how to fix it.

Is there an easier alternative I can use?

Also another question that I do not seem to get:

1 - It says it is cross platform. I thought by saying that then there would be 1 source folder that will compile differently on each platform, and not have source code for each platform.

2 - Also, where does it install? will it become part of my os libraries and I would be able to just use it in any c++ program I write?

3 - How can I then move my program to another OSX machine? Will I have to build a self-contained app (like in Java) or will that machine need to have the same wxWidgets version as my machine on which the program was developed?

There are many questions there, it would probably be better to ask each one separately, but let me try to briefly address all of them.

The problem you see is due to an incompatible changes in OS X SDK since the last wxWidgets release, as you could have found out if you searched wxTrac and found this bug . As you can also see there, it's fixed since quite some time, so all you need to do is to get the latest version from GitHub. Alternatively, you can build with older SDK but this is not recommended.

Next:

  1. It is cross-platform because you can write a single version of code that compiles and works on multiple platforms. It's obviously impossible to avoid platform-specific code completely, wxWidgets just encapsulates it for you, so that you don't have to write it.
  2. It installs under /usr/local by default as any Unix library, but this can be changed using --prefix option when running configure.
  3. You should include wxWidgets libraries with your program. The simplest way to do it is to link to them statically. Slightly more involved is to put the shared libraries in your application bundle.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM