系統版本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
執行,窗口就出來了
將我的一個Windows上的wxWidgets寫的工具扔過來運行效果(上Linux,下Windows):