wxWidget tutorial is insufficient to get started.

This forum can be used to talk about general design strategies, new ideas and questions in general related to wxWidgets. If you feel your questions doesn't fit anywhere, put it here.
Post Reply
49gvs780w
In need of some credit
In need of some credit
Posts: 3
Joined: Sat Jul 01, 2017 11:31 am

wxWidget tutorial is insufficient to get started.

Post by 49gvs780w » Sat Jul 01, 2017 11:47 am

Hi!

I have looked at various cross-platform UI frameworks/libraries. And I have few questions: 1) Do you guys have competition with other UI frameworks on who can make make harder to follow tutorials? At least this is the impression I get.

I downloaded the wxWidgets from:
http://codelite.org/LiteEditor/WxWidgets31Binaries#toc2

Code: Select all

 apt-get install libwxbase3.1-0-unofficial \
                 libwxbase3.1-dev \
                 libwxgtk3.1-0-unofficial \
                 libwxgtk3.1-dev \
                 wx3.1-headers \
                 wx-common \
                 libwxgtk-webview3.1-0-unofficial \
                 libwxgtk-webview3.1-dev \
                 libwxgtk-media3.1-0-unofficial \
                 libwxgtk-media3.1-dev \
                 libwxbase3.1-0-unofficial-dbg \
                 libwxgtk3.1-0-unofficial-dbg \
                 libwxgtk-webview3.1-0-unofficial-dbg \
                 libwxgtk-media3.1-0-unofficial-dbg \
                 wx3.1-i18n \
                 wx3.1-examples
Then I tried to follow your tutorial:
http://docs.wxwidgets.org/stable/overvi ... world.html

And it doesnt even teach how to compile.

Code: Select all

[email protected]:~/cpp/wx$ g++ hello.cpp 
hello.cpp:3:23: fatal error: wx/wxprec.h: No such file or directory
 #include <wx/wxprec.h>
                       ^
compilation terminated.
Can anyone point out what I have to do?

User avatar
doublemax
Moderator
Moderator
Posts: 14875
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxWidget tutorial is insufficient to get started.

Post by doublemax » Sat Jul 01, 2017 12:14 pm

Do you guys have competition with other UI frameworks on who can make make harder to follow tutorials?
This is a user forum. Ranting comments like this won't get you very far.

<wxdir>/docs/gtk/install.txt
Use the source, Luke!

DavidHart
Site Admin
Site Admin
Posts: 3980
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Re: wxWidget tutorial is insufficient to get started.

Post by DavidHart » Sat Jul 01, 2017 12:25 pm

Hi,
1) Do you guys have competition with other UI frameworks on who can make make harder to follow tutorials?
No, it's convergent evolution ;) .
And it doesnt even teach how to compile.
Well, the answer will be different for different platforms...

Instead wx provides samples that will compile. You downloaded them: the wx3.1-examples package. They will have installed to /usr/share/doc/wx3.1-examples/; ./examples/ has a readme and installing script. Start with 'minimal'.

For the tutorial you need to invoke the wx-config script, which is how most wx builds are accessed on Linux. So your compile line should have read:

Code: Select all

g++ hello.cpp $(wx-config --cxxflags --libs) -o hello
Regards,

David

49gvs780w
In need of some credit
In need of some credit
Posts: 3
Joined: Sat Jul 01, 2017 11:31 am

Re: wxWidget tutorial is insufficient to get started.

Post by 49gvs780w » Sat Jul 01, 2017 2:19 pm

Thanks.

Sorry for harsh start.

When I run run it on machine where I compiled (64 bit debian 9) it runs fine, but when I try to run it on 32 bit linux mint it says

Code: Select all

bash: ./hello: cannot execute binary file: Exec format error
I guess it's a problem of being compiled to 64-bit by default? How do I exactly compile it for 32 bit? when I try -m32 it complains:

Code: Select all

[email protected]:~/cpp/wx$ g++ -m32 hello.cpp $(wx-config --cxxflags --libs) -o hello
In file included from /usr/include/assert.h:35:0,
                 from /usr/include/wx-3.1-unofficial/wx/debug.h:13,
                 from /usr/include/wx-3.1-unofficial/wx/defs.h:743,
                 from /usr/include/wx-3.1-unofficial/wx/wxprec.h:12,
                 from hello.cpp:3:
/usr/include/features.h:364:25: fatal error: sys/cdefs.h: No such file or directory
 #  include <sys/cdefs.h>
                         ^
compilation terminated.

DavidHart
Site Admin
Site Admin
Posts: 3980
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Re: wxWidget tutorial is insufficient to get started.

Post by DavidHart » Sat Jul 01, 2017 4:03 pm

I guess it's a problem of being compiled to 64-bit by default?
Building on one distro/version and expecting the binary to run on another is optimistic. It might work, but only if every dependency is present and ABI-compatible. That's why debs/rpms etc are used.
when I try -m32 it complains
I've never been tempted to try that.

The time-honoured solution is to distribute a source tarball plus instructions, and/or binaries built for each target distro/version. Nowadays there are alternatives (e.g. snappy, flatpak) which I've also never been tempted to try.

49gvs780w
In need of some credit
In need of some credit
Posts: 3
Joined: Sat Jul 01, 2017 11:31 am

Re: wxWidget tutorial is insufficient to get started.

Post by 49gvs780w » Sat Jul 01, 2017 5:35 pm

Thanks for info.

So every time I distribute my app I must distribute entire wxWidgets also? Like now way I could just have one 32 binary that runs on all 32 bit linuxes? Thought it was possible since it uses native GUI elements.

DavidHart
Site Admin
Site Admin
Posts: 3980
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Re: wxWidget tutorial is insufficient to get started.

Post by DavidHart » Sat Jul 01, 2017 6:36 pm

So every time I distribute my app I must distribute entire wxWidgets also?
No, not on Linux.

The standard solution (assuming you aren't going to rely on the end-user building from source) is to create an appropriate binary package for each target distro/version i.e debs for debian/ubuntu/mint, rpms for fedora/opensuse/ etc. Those packages will know (because you tell them, or the build-process does) that they 'depend' on various runtime libs, including the wx ones. As you will have been careful to build against that distro/version's wxWidgets (rather than the unofficial wx3.1 that you are currently using) there will be no need to include wx itself in the package.
If you don't create debs/rpms, just a binary for each distro/version, then you have to tell the end-users (very loudly) that they must first install the distro's wx, plus all other libs that your binary requires (doing: ldd /path/to/my/binary might help there).

The alternative method, far less common on Linux, is to create a static-linking wx build instead of the standard dynamic-linking one. You do that by passing --disable-shared in the configure options. When you build your package against the static build, the necessary wx libs get included in the binary. The disadvantages: the binary is much larger (not important nowadays), and there's still the risk that other, non-wx, dependencies won't always be present and compatible.
Like no way I could just have one 32 binary that runs on all 32 bit linuxes?
You could do that, but only for a very simple program that has very few dependencies. And even then you risk linking to an incompatible version of, e.g. glibc.

There's a reason why packages and package managers exist...

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 4152
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: wxWidget tutorial is insufficient to get started.

Post by ONEEYEMAN » Mon Jul 03, 2017 4:22 pm

David,
How good is the source on the CodeLite that (s)he downloaded? Are they patched in any way? Can (s)he rely on them?

Asking because usually the download comes from the wxWidgets site...

Thank you.

DavidHart
Site Admin
Site Admin
Posts: 3980
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Re: wxWidget tutorial is insufficient to get started.

Post by DavidHart » Mon Jul 03, 2017 4:44 pm

How good is the source on the CodeLite that (s)he downloaded? Are they patched in any way?
Slightly, as stated on that CodeLite page; and later the fedora Wayland fixes mentioned here.
Can (s)he rely on them?
Well, I do...
Asking because usually the download comes from the wxWidgets site..
The source tarballs, yes; and Windows binaries. But it's been a long time since there were official debs/rpms.

Post Reply