|
WxWidgets
wxWidgets is a development framework / library that allows you to use the same code cross-platform development on Windows, Mac, Linux in. It is mainly written in C ++, but can also bind such as Python, Perl, Ruby and other languages.
For this tutorial I will show you how to like Ubuntu and Linux Mint compiled wxwidgets 3.0+ in Debian based linux box.
WxWidgets from source compiler is not difficult, just take a few minutes. Library can be compiled in different ways, such as static or dynamic libraries.
1. Download wxWidgets
The first step you need to download the source files from wxWidgets wxwidgets.org.
After the finish, extract to a directory.
2. Set the build environment
To compile wxwidgets, we need some tools include a C ++ compiler on Linux g ++. All of these tools can be installed via apt-get from the warehouse.
We also need to rely on wxWidgets GTK development library.
$ Sudo apt-get install libgtk-3-dev build-essential checkinstall
This is called checkinstall tool allows us to create an installation package for wxwidgets, so then you can easily use the package manager to uninstall.
3. Compile wxWidgets
WxWidgets into the directory after decompression. To clean, use a compiler to create the directory.
$ Mkdir gtk-build
$ Cd gtk-build /
Now run configure and make commands. Each will take some time to complete.
$ ../configure --disable-Shared --enable-unicode
$ Make
"--disable-Shared" option will compile a static library instead of dynamic libraries.
After the make command completes, the compiler will be successful. It is time to install wxWidgets to the correct directory.
For more information see install.txt and readme.txt, which can be found at wxwidgets in the / docs / gtk / directory.
4. Install checkinstall
Now we do not use "make install" command, we use the checkinstall command to create a wxwidgets the deb package. Run the command:
$ Sudo checkinstall
checkinstall will ask a few questions, please ensure that after questioning a version number, otherwise it will fail.
After the completion of all this, wxWidgets is now installed, deb file will be created in the same directory.
5. Tracking installed files
If you want to check the location of the installation file, using dpkg command followed by the package name checkinstall provided.
$ Dpkg -L package_name
/.
/ Usr
/ Usr / local
/ Usr / local / lib
/usr/local/lib/libwx_baseu-3.0.a
/usr/local/lib/libwx_gtk3u_propgrid-3.0.a
/usr/local/lib/libwx_gtk3u_html-3.0.a
/usr/local/lib/libwxscintilla-3.0.a
/usr/local/lib/libwx_gtk3u_ribbon-3.0.a
/usr/local/lib/libwx_gtk3u_stc-3.0.a
/usr/local/lib/libwx_gtk3u_qa-3.0.a
/usr/local/lib/libwx_baseu_net-3.0.a
/usr/local/lib/libwxtiff-3.0.a
6. Compiling the Sample
After compiling wxWidgets can compile immediately complete sample program. In the same directory, a new sample catalog has been created.
Enter it and run the following command
$ Compile samples
$ Cd samples /
$ Make
After the make command completes, enter the sample subdirectory, where there is a running immediately Demo program.
7. Compile your first program
After you have completed compilation demo program, you can write your own program to compile. This is also very simple.
Suppose you are using C ++, so you can also use the editor's highlight features. For example, gedit, kate, kwrite like. Or use the full-featured IDE such as Geany, Codelite, Codeblocks like.
However, your first program just use a text editor to quickly complete.
as follows:
#include
classSimple: public wxFrame
{
public:
Simple (const wxString & title)
: WxFrame (NULL, wxID_ANY, title, wxDefaultPosition, wxSize (250,150))
{
Centre ();
}
};
classMyApp: public wxApp
{
public:
boolOnInit ()
{
Simple * simple = newSimple (wxT ( "Simple"));
simple-> Show (true);
returntrue;
}
};
wxIMPLEMENT_APP (MyApp);
Now save and compile with the following command.
# Compile
$ G ++ basic.cpp `wx-config --cxxflags --libs std`-o program
# Run
$ ./program
And non-standard libraries compiled together
Surface display wx-config command by default only supports the standard library. If you are using Aui library, then you need to specify the additional use of the library.
$ G ++ code.cpp `wx-config --cxxflags --libs std, aui`-o program
|
|
|
|