글
이 글은 wxWidgts 설치 및 sample code 를 만들어 실행시키는 방법을 설명한다.
wxWidgets is a C++ library that lets developers create applications for Windows, OS X, Linux and UNIX on 32-bit and 64-bit architectures as well as several mobile platforms including Windows Mobile, iPhone SDK and embedded GTK+. (http://www.wxwidgets.org/)
1. wxWidgets 설치
wxWidgets is not built into useable libraries when you "install" the wxMSW installer. This is because there are so many configurable elements, which is precisely what the setup.h you refer to is for.
If you just want to build it with default options as quickly as possible and move on, here is how:
1) Start the "Visual Studio Command Prompt." You'll find this in the start menu under "Microsoft Visual Studio -> Visual Studio Tools".
2) Change to folder: [WXWIN root]\build\msw
3) Build default debug configuration: nmake -f makefile.vc BUILD=debug
4) Build default release configuration: nmake -f makefile.vc BUILD=release
5) Make sure the DLLs are in your PATH. They'll be found in [WXWIN root]\lib\vc_dll
6) Under the DLL folder mentioned above, you will find subfolders for each build variant (The instructions above made two, debug and release.) In each variant folder you'll find a 'wx' folder containing a 'setup.h" file. You'll see that the setup.h files are actually different for each build variant. These are the folders you need to add to your project build configuration include path, one per build variant. So, for example, you'd add [WXWIN root]\lib\vc_dll\mswud to the include path for your debug build, [WXWIN root]\lib\vc_dll\mswu for your release build.
7) It is possible to build lots of other variant combinations: static libs, monolithic single library, non-Unicode, etc. See [WXWIN root]\docs\msw\install.txt for much more extensive instructions.
2. Sample Program 생성
- Win32 Application 프로젝트 선택 -> empty project 선택 후 생성
- [source files] 에 hello.cpp 파일을 추가한 후, 아래 내용을 해당 파일에 복사한다.
/*
* hworld.cpp
*/
#include "wx/wx.h"
class MyApp: public wxApp
{
virtual bool OnInit();
};
class MyFrame: public wxFrame
{
public:
MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size);
void OnQuit(wxCommandEvent& event);
void OnAbout(wxCommandEvent& event);
DECLARE_EVENT_TABLE()
};
enum
{
ID_Quit = 1,
ID_About,
};
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_MENU(ID_Quit, MyFrame::OnQuit)
EVT_MENU(ID_About, MyFrame::OnAbout)
END_EVENT_TABLE()
IMPLEMENT_APP(MyApp)
bool MyApp::OnInit()
{
MyFrame *frame = new MyFrame( _("Hello World"), wxPoint(50, 50),
wxSize(450,340) );
frame->Show(true);
SetTopWindow(frame);
return true;
}
MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
: wxFrame( NULL, -1, title, pos, size )
{
wxMenu *menuFile = new wxMenu;
menuFile->Append( ID_About, _("&About...") );
menuFile->AppendSeparator();
menuFile->Append( ID_Quit, _("E&xit") );
wxMenuBar *menuBar = new wxMenuBar;
menuBar->Append( menuFile, _("&File") );
SetMenuBar( menuBar );
CreateStatusBar();
SetStatusText( _("Welcome to wxWidgets!") );
}
void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
{
Close(TRUE);
}
void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
{
wxMessageBox( _("This is a wxWidgets Hello world sample"),
_("About Hello World"),
wxOK | wxICON_INFORMATION, this);
}
- project properties -> Configuration Properties -> C/C++ -> General -> Additional Include Directories -> wxWidgets 설치 include 디렉토리 추가 "C:\work\wxWidgets-3.0.0\include;C:\work\wxWidgets-3.0.0\include\msvc"
- project properties -> Configuration Properties -> Linker -> General -> Additional Library Directories -> wxWidgets 설치 lib 디렉토리 추가 "C:\work\wxWidgets-3.0.0\lib\vc_lib;"
3. 빌드 및 실행
위의 코드를 빌드 후 실행시키면, 아래와 같은 윈도우를 볼 수 있다.
'Biz > Programming' 카테고리의 다른 글
VS - error LNK2019 (0) | 2014.02.13 |
---|---|
[Xcode] Xcode 5 - release mode build setting (0) | 2014.01.28 |
[QT]-[error] close() was not declared in this scope (0) | 2013.12.06 |
How to install qtcreator on Kali 1.0.5 GNOME (0) | 2013.10.15 |
ubuntu 에서 gtk 설치 & sample code (0) | 2013.10.11 |
RECENT COMMENT