wxWidgets和Codeblocks的编译安装,GUI程序开发平台的搭建具体步骤如下:
(1)基本编译环境安装
安装编译工具(gcc之类)sudo apt-get install build-essential
安装X11sudo apt-get install libx11-dev
安装GTK需要的东西sudo apt-get install?gnome-core-devel
(2)下载wxWidgets源码包并解压缩到 #{wxdir}
(3)创建基于gtk和x11的编译目录${wx}
mkdir ${wx}/buildgtk
mkdir ${wx}/buildx11
(4)编译wxgtk
cd ${wx}/buildgtk
sudo ${wxdir}/configure –with-gtk
sudo make
sudo make install
sudo ldconfig
(5)编译wxx11
cd ${wx}/buildxll
sudo ${wxdir}/configure -–with-x11
sudo make
sudo make install
sudo ldconfig
(6)此时wxGTK与wxX11就都编译并且安装完成了,以后编译程序的时候只需要调用不用的类库即可。
(7)wxconfig --help
1.#include <wx/string.h>
#include <wx/utils.h>#include <wx/datetime.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
int main()
{
wxPrintf(wxT("开发平台描述\n"));
wxPrintf(wxGetOsDescription());
wxPrintf(wxT("the amount of free memory:\n"));
long mem = wxGetFreeMemory().ToLong();
wxPrintf(wxT("Memory: %ld\n"), mem);
wxPrintf("主机名\n");
wxPuts(wxGetUserName());
wxPuts(wxGetFullHostName());
wxDateTime now = wxDateTime::Now();
wxString date1 = now.Format();
wxString date2 = now.Format(wxT("%X"));
wxString date3 = now.Format(wxT("%x"));
wxPuts(date1);
wxPuts(date2);
wxPuts(date3);
return 0;
}
2.#include <wx/file.h>
#include<wx/string.h>
#include <wx/textfile.h>
int main()
{
wxFile file1;
file1.Create(wxT("stu.txt"), true);
wxString str1,str2;
wxPrintf("输入学生信息:\n");
str1="Mary 0001";
str2="Mike 0002";
file1.Write(str1);
file1.Write(str2);
wxTextFile file(wxT("stu.txt"));
file.Open();
wxPrintf(wxT("行数: %d\n"), file.GetLineCount());
wxPrintf(wxT("第一行: %s\n"), file.GetFirstLine().c_str());
wxPrintf(wxT("最后一: %s\n"), file.GetLastLine().c_str());
wxPuts(wxT("-------------------------------------"));
wxString s;
for ( s = file.GetFirstLine(); !file.Eof(); s = file.GetNextLine() )
{
wxPuts(s);
wxPrintf("\n");
}
file.Close();
return 0;
}