Guidance
指路人
g.yi.org
Guidance Forums / wxWidgets (wxWindows) in C++ / undefined reference problem

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
Message1. undefined reference problem
#4970
Posted by: 2004-08-11 22:38:13
this is my code:
class BasicFrame : public wxFrame
{
  public:
   BasicFrame( const wxChar *title,
                int xpos, int ypos,
                int width, int height);
   ~BasicFrame();
    wxTextCtrl *theText;
    wxMenuBar  *menuBar;
   wxMenu     *fileMenu;
   wxMenu     *databaseMenu;
   wxButton   *button;//
   wxStaticText *dytext;///

  
   void OnOpenFile (wxCommandEvent & event);
    void OnAbout    (wxCommandEvent & event);
    void OnExit     (wxCommandEvent & event);
    void OnButtonSelect  (wxCommandEvent & event);
    void OnConnect      (wxCommandEvent  &  event);
  
   
 
  
   DECLARE_EVENT_TABLE()

};
#endif


// For compilers that supports precompilation , includes “wx/wx.h”
#include "wx/wxprec.h"
#ifndef WX_PRECOMP
   #include "wx/wx.h"
#endif
#include "basic.h"
#include "wx/db.h"
#include "wx/dbtable.h"


IMPLEMENT_APP(BasicApplication)

bool BasicApplication::OnInit()
{
  BasicFrame *frame
    = new BasicFrame
       ("wxWindows Basic Steps - Step 1:"
        " A simple application",
         50, 50, 200, 200);

  frame->Show(TRUE);
  SetTopWindow(frame);
 

  return TRUE;   
}

BasicFrame::BasicFrame(const wxChar *title,int xpos, int ypos, int width, int height)
: wxFrame( (wxFrame *) NULL, -1, title,wxPoint(xpos, ypos),wxSize(width, height))
{
theText = (wxTextCtrl *) NULL;

/*theText = new wxTextCtrl( this, -1, wxString("This is a text control\n\n"
                "The text control supports"
                   " basic text editing operations\n"
                "along with copy, cut, paste, "
                   "delete, select all and undo.\n\n"
                "Right click on the control"
                   " to see the pop-up menu.\n"
               ),
       wxDefaultPosition ,     
       wxDefaultSize,
       wxTE_MULTILINE
     );*/
  

  fileMenu = new wxMenu;
  fileMenu->Append(BASIC_OPEN,  "&Open file","open an existing file ");
  fileMenu->Append(BASIC_ABOUT, "&About","who wrote this");
  fileMenu->AppendSeparator();
  fileMenu->Append(BASIC_EXIT,  "E&xit","exit this appplication");


  databaseMenu = new wxMenu;
  databaseMenu->Append(BASIC_CONNECT,  "&Connect","connect to database ");
 
  menuBar = new wxMenuBar;
  menuBar->Append(fileMenu, "&File");
  menuBar->Append(databaseMenu,"&Database");
  SetMenuBar(menuBar);
  CreateStatusBar(3);
  SetStatusText(_T("Welcome TO WSOS XP!!"));///
  wxButton *button =(wxButton*)NULL;//
  button = new wxButton(this,BUTTON_SELECT,"Button!",wxPoint(300,300),wxSize(-1,-1));//
  theText = new wxTextCtrl(this,-1,"DINGGENIUS",wxPoint(225,20),wxSize(200,20),0,wxDefaultValidator, "Dingyao");
  dytext = new wxStaticText(this,-1,"NO More Strawberry!!!", wxPoint(20,20),wxSize(200,20),0,"Dingyao");
 



 
}
BEGIN_EVENT_TABLE (BasicFrame, wxFrame)
  EVT_MENU ( BASIC_EXIT,  BasicFrame::OnExit)
  EVT_MENU ( BASIC_ABOUT, BasicFrame::OnAbout)
  EVT_MENU ( BASIC_OPEN,  BasicFrame::OnOpenFile)
  EVT_MENU ( BASIC_CONNECT,  BasicFrame::OnConnect)
  EVT_BUTTON ( BUTTON_SELECT, BasicFrame::OnButtonSelect)
 
 
END_EVENT_TABLE()

BasicFrame::~BasicFrame()
{

}
void BasicFrame::OnButtonSelect(wxCommandEvent & event)
{
    wxString t2 = theText->GetLineText(0);
   
  //a class called wxMessageDialog
  wxMessageDialog aboutDialog( this, t2, "About Basic", wxOK | wxCANCEL);
  aboutDialog.ShowModal();
 
}   
void BasicFrame::OnOpenFile (wxCommandEvent & event)
{
  theText->LoadFile("data.txt");
}


void BasicFrame::OnAbout (wxCommandEvent & event)
{ wxString t = TITLE;

  t.append( _T("\nDB 2001"));
 
  wxMessageDialog
   aboutDialog
    ( this, t, "About Basic", wxOK | wxCANCEL);
  aboutDialog.ShowModal();
}

void BasicFrame::OnExit (wxCommandEvent & event)
{
  Close(TRUE);
}

void BasicFrame::OnConnect(wxCommandEvent & event)
{
///*   
wxDbConnectInf  *DbConnectInf =NULL;

wxDb        *db =NULL  ;       // The database connection
wxDbTable   *table= NULL;       // The data table to access

wxChar       FirstName[50+1];    // buffer for data from column "FIRST_NAME"
wxChar       LastName[50+1];     // buffer for data from column "LAST_NAME"

bool         errorOccured = FALSE;

const wxChar tableName[]          = "CONTACTS";
const UWORD  numTableColumns      = 2;           // Number of bound columns

FirstName[0] = 0;
LastName[0]  = 0;

DbConnectInf = new wxDbConnectInf(NULL,"MyDSN","MyUserName", "MyPassword");

if (!DbConnectInf || !DbConnectInf->GetHenv())
{
  wxMessageBox("Unable to allocate an ODBC environment handle",
            "DB CONNECTION ERROR", wxOK | wxICON_EXCLAMATION);
  return;
}

// Get a database connection from the cached connections
db = wxDbGetConnection(DbConnectInf);

// Create the table connection
table = new wxDbTable(db, tableName, numTableColumns, "",
                      !wxDB_QUERY_ONLY, "");

//
// Bind the columns that you wish to retrieve. Note that there must be
// 'numTableColumns' calls to SetColDefs(), to match the wxDbTable definition
//
// Not all columns need to be bound, only columns whose values are to be
// returned back to the client.
//
table->SetColDefs(0, "FIRST_NAME", DB_DATA_TYPE_VARCHAR, FirstName,
                  SQL_C_CHAR, sizeof(FirstName), TRUE, TRUE);
table->SetColDefs(1, "LAST_NAME", DB_DATA_TYPE_VARCHAR, LastName,
                  SQL_C_CHAR, sizeof(LastName), TRUE, TRUE);

// Open the table for access
table->Open();

// Set the WHERE clause to limit the result set to only
// return all rows that have a value of 'GEORGE' in the
// FIRST_NAME column of the table.
table->SetWhereClause("FIRST_NAME = 'GEORGE'");

// Result set will be sorted in ascending alphabetical
// order on the data in the 'LAST_NAME' column of each row
table->SetOrderByClause("LAST_NAME");

// No other tables (joins) are used for this query
table->SetFromClause("");

// Instruct the datasource to perform a query based on the
// criteria specified above in the where/orderBy/from clauses.
if (!table->Query())
{
    wxMessageBox("Error on Query()","ERROR!",
                  wxOK | wxICON_EXCLAMATION);
    errorOccured = TRUE;
}

wxString msg;

// Start and continue reading every record in the table
// displaying info about each record read.
while (table->GetNext())
{
   // msg.Printf("Row #%lu -- First Name : %s  Last Name is %s",
    //           table->GetRowNum(), FirstName, LastName);
   // wxMessageBox(msg, "Data", wxOK | wxICON_INFORMATION, NULL);
}

// If the wxDbTable instance was successfully created
// then delete it as I am done with it now.
if (table)
{
    delete table;
    table = NULL;
}

// If we have a valid wxDb instance, then free the connection
// (meaning release it back in to the cache of datasource
// connections) for the next time a call to wxDbGetConnection()
// is made.
if (db)
{
    wxDbFreeConnection(db);
    db = NULL;
}

// The program is now ending, so we need to close
// any cached connections that are still being
// maintained.
wxDbCloseConnections();

// Release the environment handle that was created
// for use with the ODBC datasource connections
delete DbConnectInf;
//*/
}   



compiler settings:-D_X86_=1 -DWIN32 -DWINVER=0x0400 -D__WIN95__ -D__GNUWIN32__ -D__WIN32__ -mthreads -DSTRICT  -D__WXMSW__ -D__WINDOWS__ -Wall -fno-pcc-struct-return -O2 -fno-rtti -fno-exceptions

linker settings:-lwxmswu -lstdc++ -lgcc -lodbc32 -lwsock32 -lwinspool -lwinmm -lshell32 -lcomctl32 -lctl3d32 -ladvapi32 -lopengl32 -lglu32 -lole32 -loleaut32 -luuid 

error msg:
[Linker error] undefined reference to `wxDbTable::SetColDefs(unsigned short, wxString const&, int, void*, short, int, bool, bool, bool, bool)'

 
[Linker error] undefined reference to `wxDbTable::Open(bool, bool)'
 
[Linker error] undefined reference to `wxDbConnectInf::wxDbConnectInf(void*, wxString const&, wxString const&, wxString const&, wxString const&, wxString const&, wxString const&)'


etc

And wxuse ODBC set to 1 already.

So what's wrong. :<


help!
Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Sat 2024-4-20  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0