RE: Compiling a C++/Wx program

  • From: "Graham Hardy" <graham.hardy@xxxxxxxxx>
  • To: <programmingblind@xxxxxxxxxxxxx>
  • Date: Tue, 27 Nov 2007 17:02:28 -0800

I am glad you asked, Jamal, because it seems to be me who have all the
problems with compiling. Then again, I still can't figure out how to link
standard Win32 API programs. I keep expecting it to be in tutorials that I
read, but most of them get down to the code itself and seem to assume that,
if you haven't figured it out already, you will always be able to consult
another tutorial. I also find Makefiles particularly difficult, because they
aren't just instruction, and it's often impossible to know which of the many
things they do are important.

-----Original Message-----
From: programmingblind-bounce@xxxxxxxxxxxxx
[mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Jamal Mazrui
Sent: November 27, 2007 2:48 PM
To: programmingblind@xxxxxxxxxxxxx
Subject: Compiling a C++/Wx program

Jaffar's tutorial helped me build the Wx libraries with Microsoft Visual
C++ 2005 Express.  I initially chose the ANSI and release options.  I 
C++ now
have a fruit basket program that compiles but fails to link (many unresolved
symbols).  Can anyone help me write a batch file or make file that builds an
executable out of the code below?

Jamal
#include "wx/wx.h"

class FruitBasket : public wxApp {
public:
wxDialog *dlg;
wxListBox *lstBasket;
wxTextCtrl *txtFruit;
wxButton *btnAdd, *btnDelete;

bool OnInit() {
dlg = new wxDialog(NULL, wxID_ANY, "Fruit Basket", wxDefaultPosition,
wxSize(513, 176)); new wxStaticText(dlg, wxID_ANY, "&Fruit:", wxPoint(14,
14), wxDefaultSize); txtFruit = new wxTextCtrl(dlg, wxID_ANY, "",
wxPoint(43, 14), wxDefaultSize, wxTE_LEFT);

new wxStaticText(dlg, wxID_ANY, "&Basket:", wxPoint(251, 14),
wxDefaultSize); lstBasket = new wxListBox(dlg, wxID_ANY, wxPoint(293,14),
wxDefaultSize, 0);

btnAdd = new wxButton(dlg, wxID_ANY, "&Add", wxPoint(190, 121),
wxDefaultSize);
btnAdd->SetDefault();
dlg->Connect(btnAdd->GetId(), wxEVT_COMMAND_BUTTON_CLICKED,
wxCommandEventHandler(FruitBasket::OnAdd));

btnDelete = new wxButton(dlg, wxID_ANY, "&Delete", wxPoint(217, 121),
wxDefaultSize);
dlg->Connect(btnDelete->GetId(), wxEVT_COMMAND_BUTTON_CLICKED,
wxCommandEventHandler(FruitBasket::OnDelete));

dlg->Connect(wxEVT_CLOSE_WINDOW,
wxCommandEventHandler(FruitBasket::OnClose));
dlg->Centre();
dlg->Show(true);
return true;
} // OnInit

void OnAdd(wxCommandEvent& event) {
wxString sValue = txtFruit->GetValue();
if (sValue == "") {
wxMessageBox("No fruit to add!", "Alert", wxICON_EXCLAMATION, dlg); } else {
lstBasket->Append(sValue);
txtFruit->Clear();
int iFruit = lstBasket->GetCount() - 1;
lstBasket->SetSelection(iFruit);
}
} // OnAdd

void OnDelete(wxCommandEvent& event) {
int iFruit = lstBasket->GetSelection();
if (iFruit == -1) {
wxMessageBox("No fruit to delete!", "Alert", wxICON_EXCLAMATION, dlg); }
else {
lstBasket->Delete(iFruit);
if (iFruit == lstBasket->GetCount()) {iFruit--;}
lstBasket->SetSelection(iFruit);
}
} // OnDelete

void OnClose(wxCommandEvent& event) {
if (wxMessageBox("Exit program?", "Confirm", wxYES_NO, dlg) == wxYES)
{dlg->Destroy();} } // OnClose };

IMPLEMENT_APP(FruitBasket)

__________
View the list's information and change your settings at
//www.freelists.org/list/programmingblind

__________
View the list's information and change your settings at 
//www.freelists.org/list/programmingblind

Other related posts: