Successfully developed a graphical interface program using wxwidgets on Ubuntu

Source: Internet
Author: User
Tags gtk wxwidgets

compiling wxwidgets

Download the latest version of the source code, wxWidgets-3.0.2. Wxwidgets in Liunx is achieved through WXGTK. WXGTK and Wxwidgets source are packaged together. WXGTK relies on GTK +, and the current version relies on versions higher than 2.8.2. I installed the 3.0 version of GTK +. Apt-get install Gtk+-3.0-dev. The general development of the library, there is a-dev end, this is a convention. The library for development contains header files and documents and things like that.

In order for the different platforms to be wxwidgets compiled and placed under their respective folders, first create a directory under the extracted folder.
mkdir Gtk-build,release compiled. mkdir Gtkd-build,debug compiled.

Enter the Gtkd-build. Execute the following configuration directives.

.. /configure--with-gtk=3--enable-unicode--disable-shared--enable-debug

The execution process checks to see if the compilation environment meets the requirements. is a variety of compilation software, a variety of dependent libraries are available. Check the process to be prompted, the failure of the place is said to explicitly rely on software. The direct Apt-get installation is good. Once the configuration is successful, execute the Make command. will be able to complete the compilation.

.. /configure the various parameters of the Doc folder under the Install.txt are described. The ability to turn on and off some features on demand at compile time will save you from things.

Because Wxwidgets is already installed in the system, you cannot make install, which can cause conflicts if compiled into a dynamic version.

Write the first program

Using Codeblocks, you can easily create a wxwidgets project by following the wizard. Remember, the designer chooses Wxsmith. This and codeblocks are integrated. I chose the dialogbased application.
Then start editing the project to compile the options.
This is the most brain-wound. It takes me the longest time. Not familiar with the basic concept of Linux GUI program development
, there are not many people cooked, there is also a lack of reference on the network. Even less information is available in English, not to mention Chinese.

First, add the dependency of wxwidgets to Linker Settings->link libraries. They are libwx_gtk3u_core-3.0.a, libwx_baseu-3.0.a, libwx_baseu_net-3.0.a, libwx_baseu_xml-3.0.a, respectively. Because the default program uses the basic interface space, these are just a few.

Resolve compilation errors


Compiling, manipulating, a whole bunch of bugs. It's so daunting that Windows just compiles and passes. Because Windows does not have such a dependency wxwidgets->wxgtk+->gtk+->gtk->x11.

First error, No target! You should use Wx-config program for compilation flags!. A search on the internet, a result. The method above does not solve the problem at all. Double-click the error line to find out that the code was thrown out by preprocessing instructions. Looking at the code context, the original world needs to define a constant that indicates what wxwidgets downlevel relies on. Then add __wxgtk__ and __wxgtk3__, and then compile, this error is gone. The rest is a variety of errors that can not be found. Is that you also need to add dependencies.

The first is gtk+3.0. Add "Pkg-config--libs gtk+-3.0" to other options, I can't. Search Ah search ah, found that it was mentioned that the GCC in the order of storage to be in accordance with the order of dependence. View the command-line arguments at compile time, the results of "Pkg-config--libs gtk+-3.0" are placed in front of wxwidgets and WXGTK. There is no way to control the console after the Pkg-config--libs gtk+-3.0. Add the results manually to the dependencies.

And then x11,x11 fortunately as long as this one project. Added directly to dependencies. Recompile and error, undefined reference to symbol ' [email protected] @GLIBC_2.2.5 '. This is inside the pthread, adding Libpthread to the dependency. These things apt-get install build-essential when all have, as long as know the name, directly to join the dependence on it. X11 is the Linux under the X Windows Environment graphical interface program needs to rely on things, if you use DIRECTFB will not X11.

Next is a variety of codec image can not find, first to wxwidgets under look for there is no, some words add in. Nothing is provided by the system.

There are also undefined reference to symbol ' deflate '. Internet search This is the zlib compression and decompression of things in the library. Add the Libz to the dependency.

Undefined reference to symbol ' [email protected] @GLIBC_2.2.5 '. This thing is not found in the DL library that loads the dynamic connection library. Add the DL to the dependency.

And the last one is these three.
Undefined reference to ' smcopenconnection '
Undefined reference to ' Smcvendor '
Undefined reference to ' smccloseconnection '

To search the Internet, a result is not. No way to read the source directly. Look at these things imported from that header file. Then you use the header file name and the information given by the header to search for a bit. Found this is the X11 used to manage the session in the library. Finally find the name of this library called SM, join the dependency.

Finally able to compile the pass.

Open source stuff, all have this characteristic, everybody you contribute a little, I contribute a little. If you want to not reinvent the wheel, you have to find it, find what you need from there, and assemble it.

Successfully developed a graphical interface program using wxwidgets on Ubuntu

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.