天天看点

Deepin上编译wxWidgets

系统版本15.11桌面版,全新安装

在$HOME/SoftwareLibrary中克隆wxWidgets

不可以直接从git拉,会少文件

SoftwareLibrary是我自己的建立的目录

https://github.com/wxWidgets/wxWidgets/releases

下载最新的发布包

然后进入wxWidgets目录,

docs/gtk/install.md

有安装教程,说的比较简单粗暴,很适合我:

If you compile wxWidgets on Linux for the first time and don't like to read
install instructions just do (in the base dir):

    > mkdir buildgtk
    > cd buildgtk
    > ../configure --with-gtk
    > make
    > su <type root password>
    > make install
    > ldconfig

[if you get "ldconfig: command not found", try using "/sbin/ldconfig"]

If you don't do the 'make install' part, you can still use the libraries from
the buildgtk directory, but they may not be available to other users.

If you want to remove wxWidgets on Unix you can do this:

    > su <type root password>
    > make uninstall
    > ldconfig

Note that by default, GTK+ 2.x is used. GTK+ 3 can be specified
with --with-gtk=3.
           

中文翻译:

如果你是第一次在Linux上编译wxWidgets,并且不想读安装教程,只需要(在根目录):
    > mkdir buildgtk
    > cd buildgtk
    > ../configure --with-gtk
    > make
    > su <type root password>
    > make install
    > ldconfig
[如果你发现ldconfig:找不到命令,尝试使用“/sbin/ldconfig”]
如果你没有执行"make install"部分,你仍然可以从buildgtk使用库,但是其他用户无法使用。

如果你想要删除wxWigets,可以这样做:
    > su <type root password>
    > make uninstall
    > ldconfig
注意,默认情况下,使用GTK+ 2.x,可以使用--with-gtk=3来指定GTK+ 3

于是直接开始
发现提示我没有装C++ 编译器
           

configure: error: C++ compiler is needed to build wxWidgets

于是用apt-get进行安装

sudo apt-get install g++

再一次

../configure

又出现错误:

configure: error: 
The development files for GTK+ were not found. For GTK+ 2, please
ensure that pkg-config is in the path and that gtk+-2.0.pc is
installed. For GTK+ 1.2 please check that gtk-config is in the path,
and that the version is 1.2.3 or above. Also check that the
libraries returned by 'pkg-config gtk+-2.0 --libs' or 'gtk-config
--libs' are in the LD_LIBRARY_PATH or equivalent.
           

就是提示我没有装GTK+,尝试了一下源码编译,想了想我还是太弱了

GTK+ requires the following packages:

 - The GLib, Pango, GdkPixbuf, ATK and cairo libraries, available at
   the same location as GTK+. GTK+ 3.22.0 requires at least
   GLib 2.49.4, Pango 1.37.3,
   GdkPixbuf 2.30.0, ATK 2.15.1
   and cairo 1.14.0.

 - libepoxy, for cross-platform OpenGL support.
   It can be found here: https://github.com/anholt/libepoxy

 - Each GDK backend has its own backend-specific requirements. For
   the X11 backend, X11 R6 and XInput version 2 (as well as a number
   of other extensions) are required. The Wayland backend requires
   (obviously) the Wayland libraries.

 - gobject-introspection 1.39.0 or newer.

           

sudo apt-get install libgtk-3-dev

还是apt-get轻松

再次

../configure --with-gtk=3

Configured wxWidgets 3.1.4 for `x86_64-pc-linux-gnu'

  Which GUI toolkit should wxWidgets use?                 GTK+ 3 with support for GTK+ printing
  Should wxWidgets be compiled into single library?       no
  Should wxWidgets be linked as a shared library?         yes
  Should wxWidgets support Unicode?                       yes (using wchar_t)
  What level of wxWidgets compatibility should be enabled?
                                       wxWidgets 2.8      no
                                       wxWidgets 3.0      yes
  Which libraries should wxWidgets use?
                                       STL                no
                                       jpeg               builtin
                                       png                sys
                                       regex              builtin
                                       tiff               builtin
                                       lzma               no
                                       zlib               sys
                                       expat              sys
                                       libmspack          no
                                       sdl                no

           

看起来OJBK了,直接make

然后就成功了,执行make install

接下来尝试编译一个例子:

https://docs.wxwidgets.org/trunk/overview_helloworld.html

g++ main.cpp `wx-config --libs --cxxflags` -o main

就成功了,然后

./main

执行,窗口就出来了

Deepin上编译wxWidgets

将我的一个Windows上的wxWidgets写的工具扔过来运行效果(上Linux,下Windows):

Deepin上编译wxWidgets
Deepin上编译wxWidgets

继续阅读