Dodle Posted February 3, 2009 Report Share Posted February 3, 2009 I have a sample program "hello world" written in C++ & wxWidgets, but I am having trouble compiling it. My main problem is that for every header file that I want to include I have to type out the exact directory sting, e.g.: #include "C:\DEV\wxWidgets-2.8.9\include\wx\wx.h"This is the wx.h file://///////////////////////////////////////////////////////////////////////////// Name: wx/wx.h// Purpose: wxWidgets central header including the most often used ones// Author: Julian Smart// Modified by:// Created: 01/02/97// RCS-ID: $Id: wx.h 40943 2006-08-31 19:31:43Z ABX $// Copyright: (c) Julian Smart// Licence: wxWindows licence/////////////////////////////////////////////////////////////////////////////#ifndef _WX_WX_H_#define _WX_WX_H_#include "C:\DEV\wxWidgets-2.8.9\include\wx\defs.h"//#include "wx/defs.h"#include "wx/object.h"#include "wx/dynarray.h"#include "wx/list.h"#include "wx/hash.h"#include "wx/string.h"#include "wx/hashmap.h"#include "wx/arrstr.h"#include "wx/intl.h"#include "wx/log.h"#include "wx/event.h"#include "wx/app.h"#include "wx/utils.h"#include "wx/stream.h"#include "wx/memory.h"#include "wx/math.h"#include "wx/stopwatch.h"#include "wx/module.h"#if wxUSE_GUI#include "wx/window.h"#include "wx/containr.h"#include "wx/panel.h"#include "wx/toplevel.h"#include "wx/frame.h"#include "wx/gdicmn.h"#include "wx/gdiobj.h"#include "wx/region.h"#include "wx/bitmap.h"#include "wx/image.h"#include "wx/colour.h"#include "wx/font.h"#include "wx/dc.h"#include "wx/dcclient.h"#include "wx/dcmemory.h"#include "wx/dcprint.h"#include "wx/dcscreen.h"#include "wx/button.h"#include "wx/menuitem.h"#include "wx/menu.h"#include "wx/pen.h"#include "wx/brush.h"#include "wx/palette.h"#include "wx/icon.h"#include "wx/cursor.h"#include "wx/dialog.h"#include "wx/timer.h"#include "wx/settings.h"#include "wx/msgdlg.h"#include "wx/cmndata.h"#include "wx/dataobj.h"#include "wx/control.h"#include "wx/ctrlsub.h"#include "wx/bmpbuttn.h"#include "wx/checkbox.h"#include "wx/checklst.h"#include "wx/choice.h"#include "wx/scrolbar.h"#include "wx/stattext.h"#include "wx/statbmp.h"#include "wx/statbox.h"#include "wx/listbox.h"#include "wx/radiobox.h"#include "wx/radiobut.h"#include "wx/textctrl.h"#include "wx/slider.h"#include "wx/gauge.h"#include "wx/scrolwin.h"#include "wx/dirdlg.h"#include "wx/toolbar.h"#include "wx/combobox.h"#include "wx/layout.h"#include "wx/sizer.h"#include "wx/mdi.h"#include "wx/statusbr.h"#include "wx/choicdlg.h"#include "wx/textdlg.h"#include "wx/filedlg.h"// always include, even if !wxUSE_VALIDATORS because we need wxDefaultValidator#include "wx/validate.h"#if wxUSE_VALIDATORS #include "wx/valtext.h"#endif // wxUSE_VALIDATORS#endif // wxUSE_GUI#endif // _WX_WX_H_To get the compiler to work I'll have to change each one of the include paths. I know there is a simpler way to do this, I just haven't figured it out yet. Do I need to have a wxWidgets environment variable? Quote Link to comment Share on other sites More sharing options...
Dodle Posted February 3, 2009 Author Report Share Posted February 3, 2009 ...Scratch that. Editing the wx.h file does no good. Quote Link to comment Share on other sites More sharing options...
catgate Posted February 3, 2009 Report Share Posted February 3, 2009 Is anyone familiar with MinGW and/or wxWidgets?A chap I knew was familiar with MinGe and wxDidgets Quote Link to comment Share on other sites More sharing options...
ɹəuəllıʍ ʇɐb Posted February 4, 2009 Report Share Posted February 4, 2009 I know there is a simpler way to do this, I just haven't figured it out yet.What is your development environment - Visual Studio? In there you can specify the source/include path (Tools | Options | tab Directories). Quote Link to comment Share on other sites More sharing options...
Dodle Posted February 4, 2009 Author Report Share Posted February 4, 2009 I'm not using a development environment. I've wanted to learn how to manually code. I did try Dev-C++ and wxDev-C++, but I couldn't figure out how to compile this program with those either. hworld.cpp:/* * hworld.cpp * Hello world sample by Robert Roebling */#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( _T("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((wxFrame *)NULL, -1, title, pos, size){ wxMenu *menuFile = new wxMenu; menuFile->Append( ID_About, _T("&About...") ); menuFile->AppendSeparator(); menuFile->Append( ID_Quit, _T("E&xit") ); wxMenuBar *menuBar = new wxMenuBar; menuBar->Append( menuFile, _T("&File") ); SetMenuBar( menuBar ); CreateStatusBar(); SetStatusText( _T("Welcome to wxWindows!") );}void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event)){ Close(TRUE);}void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event)){ wxMessageBox(_T("This is a wxWindows Hello world sample"), _T("About Hello World"), wxOK | wxICON_INFORMATION, this);}I just need to MinGW compiler to know where to find the wx directory. I've tried setting an environment varialble: WX=C:\DEV\wxWidgets-2.8.9\includeBut that didn't do any good. Quote Link to comment Share on other sites More sharing options...
ɹəuəllıʍ ʇɐb Posted February 4, 2009 Report Share Posted February 4, 2009 Sorry, I don't know MinGW. Doesn't it have any documentation on its website, e.g. Programmer's Guide? Quote Link to comment Share on other sites More sharing options...
Dodle Posted February 4, 2009 Author Report Share Posted February 4, 2009 The documentation says that I need to put the header files in MinGW's search path (this is the simplest suggestion), which is the "include" folder in MinGW's directory. But I must be doing something wrong because it's not working. I take C:\DEV\wxWidgets-2.8.9\include\wx and place it in C:\DEV\MinGW\include, but still no good. Quote Link to comment Share on other sites More sharing options...
ɹəuəllıʍ ʇɐb Posted February 5, 2009 Report Share Posted February 5, 2009 That is exactly the point; how do you define the MinGW search path - an environment variable? Quote Link to comment Share on other sites More sharing options...
Dodle Posted February 8, 2009 Author Report Share Posted February 8, 2009 That's what their website said: MinGW searches in the "include" folder. Quote Link to comment Share on other sites More sharing options...
Dodle Posted February 9, 2009 Author Report Share Posted February 9, 2009 I think I'm going to give up and try Visual C++. Quote Link to comment Share on other sites More sharing options...
ɹəuəllıʍ ʇɐb Posted February 9, 2009 Report Share Posted February 9, 2009 That seems like a sensible idea; no point of messing with something that nobody has ever heard of.Do you have Visual Studio (or Visual C++) installed? If not, you know that there is a free version of Visual Studio, called Visual Studio Express ? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.