Ok, here's just a little update if you want to work with wxWidgets and OpenGL inside Eclipse.
It took me a while to figure out how to make Eclipse building my wxWidgets/OpenGL tests but the trick is easy now that I've found it! ^^
Here are the updated-opengl commands to paste into the Linker flags :
Debug Build
-lopengl32 -lglu32 `wx-config --debug=yes --static=no --libs std,gl`
Release Build
-lopengl32 -lglu32 `wx-config --debug=no --static=no --libs std,gl`
Sunday, June 14, 2009
Setting up Eclipse + wxWidgets 2.8.10
After we have built our Debug and Release versions of wxWidgets now I show you how to setup wxWidgets with Eclipse.
Pre-Requisites
- Eclipse
(I prefer the C++ Developers version. It's lighter than the standard version, it comes with the CDT plugin already installed and it solved me some problems I had with the standard version with the CDT manually installed. You can download it here)
- MinGW + MSYS
- Both Debug/Release versions of wxWidgets
Debug Setup
1. Start Eclipse
2. Go to File --> New C++ Project
Under Project Type choose Executable --> Empty Project and under Toolchains select MinGW.
Name your project whatever you like and click Finish.
3. Right click on your project and click on Properties and check that Configuration set to Debug.
4. Go to C/C++ Build --> Tool Chain Editor and where it says Current builder select Gnu Make Builder
5. Go to C/C++ Build and unckeck Use default build command and where it says Build command type mingw32-make
6. Go to C/C++ Build --> Environment
Click on Add and where it says Name type PATH.
Where it says Value copy your wxWidgets Debug bin directory path (mine is D:\wx-Debug\bin)
7. Go to C/C++ Build --> Settings --> GCC C++ Compiler
Where it says Command paste this line: g++ `wx-config --debug=yes --static=no --cxxflags`
8. Go to C/C++ Build --> Settings --> MinGW C++ Linker
Where it says Command line pattern cut the variable ${FLAGS} and paste it at the end of the line.
9. Go to C/C++ Build --> Settings --> MinGW C++ Linker --> Miscellaneous
Where it says Linker flags paste this line: `wx-config --debug=yes --static=no --libs`
That should be all for the Debug setup.
Release Setup
Starting from step 3 of the Debug setup guide change it this way:
1. Check that Configuration is set to Release
2. Go to C/C++ Build --> Tool Chain Editor and where it says Current builder select Gnu Make Builder
3. Go to C/C++ Build and unckeck Use default build command and where it says Build command type mingw32-make
4. Go to C/C++ Build --> Environment
Click on Add and where it says Name type PATH.
Where it says Value copy your wxWidgets Release bin directory path (mine is D:\wx-Release\bin)
7. Go to C/C++ Build --> Settings --> GCC C++ Compiler
Where it says Command paste this line: g++ `wx-config --debug=no --static=no --cxxflags`
8. Go to C/C++ Build --> Settings --> MinGW C++ Linker
Where it says Command line pattern cut the variable ${FLAGS} and paste it at the end of the line.
9. Go to C/C++ Build --> Settings --> MinGW C++ Linker --> Miscellaneous
Where it says Linker flags paste this line: `wx-config --debug=no --static=no --libs`
Add a c++ source file and copy this source inside to test the building:
Let me know if you encounter any problems.
Thanks for reading.
Pre-Requisites
- Eclipse
(I prefer the C++ Developers version. It's lighter than the standard version, it comes with the CDT plugin already installed and it solved me some problems I had with the standard version with the CDT manually installed. You can download it here)
- MinGW + MSYS
- Both Debug/Release versions of wxWidgets
Debug Setup
1. Start Eclipse
2. Go to File --> New C++ Project
Under Project Type choose Executable --> Empty Project and under Toolchains select MinGW.
Name your project whatever you like and click Finish.
3. Right click on your project and click on Properties and check that Configuration set to Debug.
4. Go to C/C++ Build --> Tool Chain Editor and where it says Current builder select Gnu Make Builder
5. Go to C/C++ Build and unckeck Use default build command and where it says Build command type mingw32-make
6. Go to C/C++ Build --> Environment
Click on Add and where it says Name type PATH.
Where it says Value copy your wxWidgets Debug bin directory path (mine is D:\wx-Debug\bin)
7. Go to C/C++ Build --> Settings --> GCC C++ Compiler
Where it says Command paste this line: g++ `wx-config --debug=yes --static=no --cxxflags`
8. Go to C/C++ Build --> Settings --> MinGW C++ Linker
Where it says Command line pattern cut the variable ${FLAGS} and paste it at the end of the line.
9. Go to C/C++ Build --> Settings --> MinGW C++ Linker --> Miscellaneous
Where it says Linker flags paste this line: `wx-config --debug=yes --static=no --libs`
That should be all for the Debug setup.
Release Setup
Starting from step 3 of the Debug setup guide change it this way:
1. Check that Configuration is set to Release
2. Go to C/C++ Build --> Tool Chain Editor and where it says Current builder select Gnu Make Builder
3. Go to C/C++ Build and unckeck Use default build command and where it says Build command type mingw32-make
4. Go to C/C++ Build --> Environment
Click on Add and where it says Name type PATH.
Where it says Value copy your wxWidgets Release bin directory path (mine is D:\wx-Release\bin)
7. Go to C/C++ Build --> Settings --> GCC C++ Compiler
Where it says Command paste this line: g++ `wx-config --debug=no --static=no --cxxflags`
8. Go to C/C++ Build --> Settings --> MinGW C++ Linker
Where it says Command line pattern cut the variable ${FLAGS} and paste it at the end of the line.
9. Go to C/C++ Build --> Settings --> MinGW C++ Linker --> Miscellaneous
Where it says Linker flags paste this line: `wx-config --debug=no --static=no --libs`
Add a c++ source file and copy this source inside to test the building:
#include <wx/wx.h>
class MyApp : public wxApp
{
virtual bool OnInit();
};
IMPLEMENT_APP(MyApp)
class MyFrame : public wxFrame
{
public:
MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size);
void OnQuit(wxCommandEvent& event);
void OnAbout(wxCommandEvent& event);
};
enum
{
ID_Quit=1,
ID_About
};
bool MyApp::OnInit()
{
MyFrame *frame = new MyFrame(_T("Hello World"), wxPoint(50,50),
wxSize(450,350));
frame->Connect( ID_Quit, wxEVT_COMMAND_MENU_SELECTED,
(wxObjectEventFunction) &MyFrame::OnQuit );
frame->Connect( ID_About, wxEVT_COMMAND_MENU_SELECTED,
(wxObjectEventFunction) &MyFrame::OnAbout );
frame->Show(TRUE);
SetTopWindow(frame);
return TRUE;
}
MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
: wxFrame((wxFrame*)NULL,-1,title,pos,size)
{
// create menubar
wxMenuBar *menuBar = new wxMenuBar;
// create menu
wxMenu *menuFile = new wxMenu;
// append menu entries
menuFile->Append(ID_About,_T("&About..."));
menuFile->AppendSeparator();
menuFile->Append(ID_Quit,_T("E&xit"));
// append menu to menubar
menuBar->Append(menuFile,_T("&File"));
// set frame menubar
SetMenuBar(menuBar);
// create frame statusbar
CreateStatusBar();
// set statusbar text
SetStatusText(_T("Welcome to wxWindows!"));
}
void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
{
Close(TRUE);
}
void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
{
wxMessageBox(_T("wxWindows Hello World example."),_T("About Hello World"),
wxOK|wxICON_INFORMATION, this);
}
Let me know if you encounter any problems.
Thanks for reading.
Building WxWidgets on Windows with MinGW + MSYS
This is a short tutorial about how to get Debug and Release builds from wxWidgets sources.
Pre-Requisites:
- Windows 2000/XP (the commands should work on Linux too but I didn't test them yet)
- MinGW + MSYS
- latest stable wxWidgets release (at the time of this writing it's 2.8.10) downloadable here
Debug Build
1. Extract the source archive wherever you want
2. Start MSYS and get into the source directory (in my case cd d:/wxWidgets2.8.10)
3. Type ./configure --enable-shared --enable-debug --with-opengl --prefix=D:/wx-Debug
--enable-shared --> build wxWidgets as a shared library (or dynamic library if you prefer)
--enable-debug --> build a debug version of wxWidgets
--with-opengl --> enable OpenGL widgets (it is not mandatory if you don't plan to use OpenGL)
--prefix=D:/wx-Debug --> the directory where we want to install wxWidgets (it's not mandatory but it helps to make things cleaner)
After configure ends its duties, it should send you back a message about the configuration you choose.
4. Now type: make
and then: make install
Now you should have your wxWidgets Debug version installed.
Release Build
1. Get into your wxWidgets source directory again
2. Type ./configure --enable-shared --disable-debug --with-opengl --prefix=D:/wx-Release
3. Type make
and then make install
Next time I'll show you how to setup Eclipse with wxWidgets!
Stay tune and thanks for reading.
Pre-Requisites:
- Windows 2000/XP (the commands should work on Linux too but I didn't test them yet)
- MinGW + MSYS
- latest stable wxWidgets release (at the time of this writing it's 2.8.10) downloadable here
Debug Build
1. Extract the source archive wherever you want
2. Start MSYS and get into the source directory (in my case cd d:/wxWidgets2.8.10)
3. Type ./configure --enable-shared --enable-debug --with-opengl --prefix=D:/wx-Debug
--enable-shared --> build wxWidgets as a shared library (or dynamic library if you prefer)
--enable-debug --> build a debug version of wxWidgets
--with-opengl --> enable OpenGL widgets (it is not mandatory if you don't plan to use OpenGL)
--prefix=D:/wx-Debug --> the directory where we want to install wxWidgets (it's not mandatory but it helps to make things cleaner)
After configure ends its duties, it should send you back a message about the configuration you choose.
4. Now type: make
and then: make install
Now you should have your wxWidgets Debug version installed.
Release Build
1. Get into your wxWidgets source directory again
2. Type ./configure --enable-shared --disable-debug --with-opengl --prefix=D:/wx-Release
3. Type make
and then make install
Next time I'll show you how to setup Eclipse with wxWidgets!
Stay tune and thanks for reading.
Subscribe to:
Posts (Atom)