How to compile and install wxWidgets in Ubuntu/Debian/Linux Mint

Source: Internet
Author: User
Tags gtk wxwidgets linux mint

How to compile and install wxWidgets in Ubuntu/Debian/Linux Mint
WxWidgets

WxWidgets is a program development framework/library that allows you to use the same code for cross-platform development in Windows, Mac, and Linux. It is mainly written in C ++, but can also be bound with other languages such as Python, Perl, and Ruby.

In this tutorial, I will show you how to compile wxwidgets 3.0 + In Debian-based linux such as Ubuntu and Linux Mint.

It is not difficult to compile wxWidgets from the source code. It takes only a few minutes. Libraries can be compiled in different ways, such as static or dynamic libraries.

 

1. Download wxWidgets

The first step is to download the wxWidgets source code file from wxwidgets.org.

Decompress the package to the directory.

 

2. Set the compiling environment

To compile wxwidgets, we need some tools including the C ++ compiler, Which is g ++ on Linux. All of these can be installed from the repository through the apt-get tool.

We also need the GTK development library on which wxWidgets depends.

  1. $ sudo apt-get install libgtk-3-dev build-essential checkinstall

This tool called checkinstall allows us to create an installation package for wxwidgets, so that we can easily use the Package Manager to uninstall it.

 

3. Compile wxWidgets

Go to the directory decompressed by wxWidgets. Create a compilation directory to keep it clean.

  1. $ mkdir gtk-build
  2. $ cd gtk-build/

Run the configure and make commands. Each task will take some time to complete.

  1. $ ../configure --disable-shared --enable-unicode
  2. $ make

The "-- disable-shared" option will compile the static library instead of the dynamic library.

After the make command is complete, the compilation is successful. It is time to install wxWidgets to the correct directory.

For more information, see install.txtand readme.txt, which can be found in the/docs/gtk/directory in wxwidgets.

 

4. Install checkinstall

Now we do not use the "make install" command. We use the checkinstall command to create a deb installation package for wxwidgets. Run the following command:

  1. $ sudo checkinstall

Checkinstall will ask several questions. Please ensure that a version number is provided after the question is asked; otherwise, it will fail.

After all this is done, wxWidgets is installed and the deb file is created in the same directory.

 

5. Track installed files

If you want to check the file installation location, use the dpkg command to keep up with the package name provided by checkinstall.

  1. $ dpkg -L package_name
  2. /.
  3. /usr
  4. /usr/local
  5. /usr/local/lib
  6. /usr/local/lib/libwx_baseu-3.0.a
  7. /usr/local/lib/libwx_gtk3u_propgrid-3.0.a
  8. /usr/local/lib/libwx_gtk3u_html-3.0.a
  9. /usr/local/lib/libwxscintilla-3.0.a
  10. /usr/local/lib/libwx_gtk3u_ribbon-3.0.a
  11. /usr/local/lib/libwx_gtk3u_stc-3.0.a
  12. /usr/local/lib/libwx_gtk3u_qa-3.0.a
  13. /usr/local/lib/libwx_baseu_net-3.0.a
  14. /usr/local/lib/libwxtiff-3.0.a

 

6. Compilation example

After wxWidgets is compiled, You can compile the sample program immediately. Under the same directory, a new sample directory has been created.

Enter it and run the following command

  1. $ compile samples
  2. $ cd samples/
  3. $ make

After the make command is complete, enter the sample subdirectory. Here there is a Demo program that can be run immediately.

 

7. compile your first program

After compiling the demo program, you can write your own program to compile it. This is also very simple.

If you use C ++, you can also use the highlight feature of the editor. For example, gedit, kate, and kwrite. Or use a full-featured IDE such as Geany, Codelite, and Codeblocks.

However, you only need to use a text editor to complete your first program quickly.

As follows:

  1. #include<wx/wx.h>
  2. classSimple:public wxFrame
  3. {
  4. public:
  5. Simple(const wxString& title)
  6. : wxFrame(NULL, wxID_ANY, title, wxDefaultPosition, wxSize(250,150))
  7. {
  8. Centre();
  9. }
  10. };
  11. classMyApp:public wxApp
  12. {
  13. public:
  14. boolOnInit()
  15. {
  16. Simple*simple =newSimple(wxT("Simple"));
  17. simple->Show(true);
  18. returntrue;
  19. }
  20. };
  21. wxIMPLEMENT_APP(MyApp);

Save and compile it with the following command.

  1. # compile
  2. $ g++ basic.cpp `wx-config --cxxflags --libs std`-o program
  3. # run
  4. $ ./program

 

Compilation with non-standard Libraries

By default, the wx-config command shown in the preceding figure only supports standard libraries. If you are using the Aui library, you need to specify the library for additional use.

  1. $ g++ code.cpp `wx-config --cxxflags --libs std,aui`-o program

For more information, see here.

 

Resources

Download wxWidgets source code and help https://www.wxwidgets.org/downloads/

Wiki page https://wiki.wxwidgets.org/Compiling compiled by wxWidgetsAndGetting_started

Use the wxWidgets latest version (3.0 +) Case https://wiki.wxwidgets.org/UpdatingToTheLatestVersionOfWxWidgets

WxWidgets details: click here
WxWidgets: click here

Configure wxWidgets/OpenGL and mixed programming for OpenCV in Ubuntu

Code: Blocks + wxWidgets 2.9.3 in 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.