ubuntu18.04,配以用wxWidgets编写linux小程序

需要安装的东西主要是codebocks与wxWidgets。

1,codebocks可以在图形界面中安装codebocks-IDE.

这个的安装比较简单,如果电脑中已安装好gnu工具它会自动找出。这时已可以写简单的小程序了。

2,要用wxWidgets,主要是开发图开界面应用,所以还需要安装编缉界面元素的plugin。这个只能用命令安装。

sudo apt-get update

sudo apt-cache search codeblocks

sudo apt-get install codeblocks-contrib

还能看到其它的一些codeblocks模块,用到时再去安装吧。

3,wxWidgets用源码安装,下载wxWidgets-3.0.4.tar.bz2http://www.wxwidgets.org/.

解码到一个目录。

./configure --with-x11
make

sudo make install

设置其动态库目录:

cd /etc/ld.so.conf.d/
sudo touch wxWidgets.conf
sudo gedit wxWidgets.conf  #增加其内容为/usr/local/lib
重新加载动态库配置信息: 
sudo ldconfig

错误处理

1,pangoxft找不到的错误,解决方法一是/configure --with-x11 --disable-unicode ,这个方法中文显示有问题。再就是apt升级一下它。

这里升级时用个问题,在中国的服务器,和美国的可升级的最新版本是有差别的。有用官方支中国区升级服务器,不能成功安装。这就要改/etc/apt/sources.list换成如下内容:这个文件我是在github上找到的。

2,codeblock不需要配置就应当可以用的。但网上有说法有一wx的变量在要codeblock的setting中设为wxWidgets的源码目录。但我配和这个变量,再删去一样好用。

4,ubuntu用的是x11而不是gtk但gtk对中文的支持好一些,如果出问题可以试一下把wxWidgets编译成用gtk.

/configure --with-gtk --disable-shared

--disable-shared在新电脑上安装时,会用重新一一把需要更新库。

 gtk也是要安装的,安装时会遇到依赖错误,这个错误也是原因最新软件包找不到引起的。当然也可能是别的问题。换用美国的服务器试一下。这个需要开通ipv6才好用。

用gtk,x11基本的中文都没什么问题。用codeblock新建的工程试一下。把它符成改一部分为中文编译没问题,但新编译的程序中文显示可能还是有问题。这个可以用代码解决。

bool sample2App::OnInit()中加入如下代码。
       //用中文的关键
           if ( setlocale (LC_ALL,"") == NULL ) {
                //(void) fprintf (stderr, "%s: cannot set locale.n",
                //program_name );
                exit (1);
        }

X11与gtk的显示视觉效果有一点差别。但影响不大。

/#sources.list using us server

# deb cdrom:[Ubuntu 18.04 LTS _Bionic Beaver_ - Release amd64 (20180426)]/ bionic main restricted

# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://us.archive.ubuntu.com/ubuntu/ bionic main restricted
# deb-src http://us.archive.ubuntu.com/ubuntu/ bionic main restricted

## Major bug fix updates produced after the final release of the
## distribution.
deb http://us.archive.ubuntu.com/ubuntu/ bionic-updates main restricted
# deb-src http://us.archive.ubuntu.com/ubuntu/ bionic-updates main restricted

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://us.archive.ubuntu.com/ubuntu/ bionic universe
# deb-src http://us.archive.ubuntu.com/ubuntu/ bionic universe
deb http://us.archive.ubuntu.com/ubuntu/ bionic-updates universe
# deb-src http://us.archive.ubuntu.com/ubuntu/ bionic-updates universe

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu 
## team, and may not be under a free licence. Please satisfy yourself as to 
## your rights to use the software. Also, please note that software in 
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://us.archive.ubuntu.com/ubuntu/ bionic multiverse
# deb-src http://us.archive.ubuntu.com/ubuntu/ bionic multiverse
deb http://us.archive.ubuntu.com/ubuntu/ bionic-updates multiverse
# deb-src http://us.archive.ubuntu.com/ubuntu/ bionic-updates multiverse

## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
# deb-src http://us.archive.ubuntu.com/ubuntu/ bionic-backports main restricted universe multiverse

## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
# deb http://archive.canonical.com/ubuntu bionic partner
# deb-src http://archive.canonical.com/ubuntu bionic partner

deb http://security.ubuntu.com/ubuntu bionic-security main restricted
# deb-src http://security.ubuntu.com/ubuntu bionic-security main restricted
deb http://security.ubuntu.com/ubuntu bionic-security universe
# deb-src http://security.ubuntu.com/ubuntu bionic-security universe
deb http://security.ubuntu.com/ubuntu bionic-security multiverse
# deb-src http://security.ubuntu.com/ubuntu bionic-security multiverse

猜你喜欢

转载自blog.csdn.net/qushaobo/article/details/83213248