zoukankan      html  css  js  c++  java
  • Install wxWidgets-3.0.2 on GNU/Linux Debian

    转载自 http://www.binarytides.com/install-wxwidgets-ubuntu/

    wxWidgets

    wxWidgets is an application development framework/library that allows developer to make cross platform GUI applications for Windows, Mac and Linux using the same codebase.

    Its primarily written in C++ but has bindings for other languages as well like Python, Perl and Ruby.

    In this tutorial I am going to show you how to compile and build wxwidgets 3.0+ on Debian based linux systems like Ubuntu and Linux Mint.

    Compiling wxWidgets from source is not at all difficult as it might sound and takes only a few minutes to do.

    The library can be compiled in different modes like static library or dynamic library.

    1. Download wxWidgets

    The first step would be to download the wxWidgets source files from wxwidgets.org

    Once done, extract the files to a directory.

    2. Setup build environment

    To compile wxwidgets we would need some utility programs including the C++ compiler on Linux called g++. And all of it would be installed from the repositories using apt-get.

    We also need the GTK development libraries which wxWidgets depend on.

    $ sudo apt-get install libgtk-3-dev build-essential checkinstall
    The utility called checkinstall would allow us to create an installation package for wxwidgets, so that later on it can un-installed easily using package managers

    3. Compile wxWidgets

    Get inside the directory where wxWidgets is extracted. In order to keep things clean, create a directory where the compilation would be done.

    $ mkdir gtk-build
    $ cd gtk-build/

    Now run the configure and make commands one by one. Each one would take some time to finish.

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

    The "--disable-shared" option instructs wxwidgets to builds static libraries instead of shared/dynamic ones.

    After the make command finishes, the compilation is done successfully. Its time to install the wxWidgets files to the correct location.

    More information about compile options can be found in install.txt and readme.txt files that can be found in /docs/gtk/ inside the wxwidgets directory.

    4. Install with checkinstall

    Now instead of using the "make install" command, we shall use the checkinstall command to create a deb package for wxwidgets. Run the following command

    $ sudo checkinstall

    Checkinstall would ask few questions during the process and make sure to provide a version number when asked, otherwise it would fail.

    Once the process is over, wxWidgets would be installed and also a deb file would be created in the same directory.

    5. Track the installed files

    If you wish to check where the files are installed, use the dpkg command followed by the name of the package provided during the checkinstall process.

    $ 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. Compile the samples

    After compiling wxWidgets, its time to compile the sample programs to see it in action. In the same directory where we compiled wxwidgets, a new subdirectory called samples would have been created.

    Just enter it and run the make command

    $ compile samples
    $ cd samples/
    $ make

    After the make process finishes, get inside each sample sub directory and there should be an executable file that can be run right away to see the demo.

    7. Compile your first program

    After you are done with the demo programs, its time to write your own program and compile it. Again it is quite easy.

    It is assumed that you are coding in C++ and for that you can use any good editor with syntax highlighting feature. For example gedit, kate, kwrite would do. Or you might want to try fully loaded IDEs like Geany, Codelite, Codeblocks etc.

    However for your first program just use an ordinary text editor get it done quick.

    Here it is

    #include <wx/wx.h>
    
    class Simple : public wxFrame
    {
    public:
        Simple(const wxString& title)
    		: wxFrame(NULL, wxID_ANY, title, wxDefaultPosition, wxSize(250, 150))
    	{
    		Centre();
    	}
    };
    
    class MyApp : public wxApp
    {
    public:
    	bool OnInit()
    	{
    		Simple *simple = new Simple(wxT("Simple"));
    		simple->Show(true);
    		return true;
    	}
    };
    
    wxIMPLEMENT_APP(MyApp);

    Now save the program somewhere and compile it with the following commands

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

    Compiling with non standard libraries

    The wx-config command shown above provides only the standard libraries by default. If you are using the Aui classes for example, then you need to specify additional libraries for it

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

    More information can be found here.

    Resources

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

    wxWidgets wiki page on compile instructions
    https://wiki.wxwidgets.org/Compiling_and_getting_started

    Notes on how to use the latest wxWidgets version (3.0+)
    https://wiki.wxwidgets.org/Updating_to_the_Latest_Version_of_wxWidgets

  • 相关阅读:
    使用 @Autowired 的时候,到底是写接口还是实现类?
    socket的简单例子
    java 将文件夹所有的文件合并到指定的文件夹下
    java 复制某一文件夹下的所有文件到另一个文件夹下
    java Date日期总结的一些转换的方法
    java 可排序的数值得字符串,转化成list集合后进行的排序的几种方法
    java 查看文件的大小的方法
    java 从一个总的list集合中,去掉指定的集合元素,得到新的集合
    java 可拆成数组的字符串,去掉重复元素的一种方法
    将博客搬至CSDN
  • 原文地址:https://www.cnblogs.com/xzpp/p/4622851.html
Copyright © 2011-2022 走看看