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
(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;