Wxwidgets Installation and demos compilation under Linux

Source: Internet
Author: User
Tags gtk wxwidgets

Wxwidgets under Linux have WXGTK and wxX11 for use, each need GTK and X11 development environment;

Wxwidgets has WXGTK and wxX11 for use under Linux, but the GTK and X11 development environments need to be configured separately, and the development environment is configured as follows:

X11 installation (if you choose to use wxX11):

Apt-get Install Libx11-dev

GTK Installation (if you choose to use WXGTK):

Apt-get Install Gnome-core-devel #这将安装 Libgtk2.0-dev Libglib2.0-dev and other development-related library files

In the www.wxwidgets.org download WXGTK or wxX11, this is the Wxwidgets library, the following is the compilation method, in WXGTK for example:

TAR-ZXF wxgtk-2.8.11.tar.gz

CD wxGTK-2.8.11

./configure

Make

sudo make install

sudo ldconfig

Enter Wx-config--cxxflags to check if WXGTK is properly configured for installation

If you can see the path to the Wx-config header file, the configuration is successful.

Let me give you an example of how to compile the WXGTK program using Wx-config

The

Hello.cpp contents are as follows:

#include "wx/wx.h"

class Helloworldapp:public Wxapp
{
Public:
     virtual bool OnInit ();
Private:
    Wxbutton *button;
};


Implement_app (helloworldapp)

/* This was executed upon startup, like ' main () ' in Non-wxwidgets Programs */

bool Helloworldapp::oninit ()
{
    wxframe *frame = new Wxframe ((wxframe*) NULL,-1, _t ("Hello wxWidgets World");
    Frame->createstatusbar ();
    Frame->setstatustext (_t ("Hello World");
    button = new Wxbutton ((Wxframe *) frame,-2, _t ("123"));
    frame->show (TRUE);
    Settopwindow (frame);

    return true;
}

Perform compilation:
$ (wx-config --cxx)   hello.cpp  $ (wx-config --libs --cxxflags)  -O   Hello
Execute program:
./hello

Can see WXGTK window, feel also can, I do not map, more critical is, with Wx-config,makefile writing is also a lot easier, we can makefile by executing the shell to get the information including file and library file, As we can write at the beginning of makefile.

cxx:=$ (Shell Wx-config--cxx)

libs:=$ (Shell Wx-config--libs)

cxxflags:=$ (Shell Wx-config--cxxflags)

In the back you can use cxx as a compiler, using Libs as a connection library, with Cxxflags as the inclusion of the library use, but do not forget to use the $ (CXX), $ (Libs) and $ (cxxflags), so makefile writing is a lot easier. The specific makefile here will not write, or believe you understand.

Wxwidgets Installation and demos compilation under Linux

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.