ubuntu karmic wxwidget 配置

参考:

1.http://wiki.wxwidgets.org/Installing_and_configuring_under_Ubuntu

2.http://wiki.wxwidgets.org/Hello_World

 

首先应该安装一些必要的包。

apt-get install build-essential #一般这一步不用,大家都事先安装好了这个了 apt-get install libwxgtk2.8-dev libwxgtk2.8-dbg

 

在/etc/apt/sources.list 中加入:

deb http://apt.wxwidgets.org/ karmic-wx main
deb-src http://apt.wxwidgets.org/ karmic-wx main 
 




下载密钥:


curl http://apt.wxwidgets.org/key.asc | sudo apt-key add




更新:


apt-get update




下载安装wxwidget 头文件,和库:


sudo apt-get install wx2.8-headers libwxgtk2.8-0 libwxgtk2.8-dev libwxgtk2.6-dev wx2.8-headers




进入: /usr/include


cd /usr/include







建立软连接:


sudo ln -sv wx-2.8/wx wx







最后记住在编译时在G++后加入


`wx-config --cxxflags` `wx-config --libs`







测试hello world:





HelloWorldApp.h


#ifndef INCLUDED_HELLOWORLDAPP_H #define INCLUDED_HELLOWORLDAPP_H // The HelloWorldApp class. This class shows a window // containing a statusbar with the text "Hello World" class HelloWorldApp : public wxApp { public: virtual bool OnInit(); }; DECLARE_APP(HelloWorldApp) #endif // INCLUDED_HELLOWORLDAPP_H




HelloWorldApp.cpp:


// For compilers that don't support precompilation, include "wx/wx.h" #include "wx/wxprec.h" #ifndef WX_PRECOMP # include "wx/wx.h" #endif #include "HelloWorldApp.h" IMPLEMENT_APP(HelloWorldApp) // This is executed upon startup, like 'main()' in non-wxWidgets programs. bool HelloWorldApp::OnInit() { wxFrame *frame = new wxFrame((wxFrame*) NULL, -1, _T("Hello wxWidgets World")); frame->CreateStatusBar(); frame->SetStatusText(_T("Hello World")); frame->Show(true); SetTopWindow(frame); return true; }




编译:


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




运行:


./HelloWorldApp






相册

你可能感兴趣的:(ubuntu karmic wxwidget 配置)