Wheli being relatively trained with Linux/Debian, I recently got a MAC
and I've installed wxmac and wxmac-shlibs (v. 2.6.1-1) to compile my old
wxwindows applications.
These applications where developped under wxwindows 2.4
Then I compile the Helloword example, I got the following error:
g++ -g3 -O3 -Wall -Wno-deprecated `wx-config --cxxflags` -IInclude -c
HelloWorld.cpp -o Obj/HelloWorld.o
g++ -g3 -o helloworld Obj/HelloWorld.o `wx-config --libs`
/usr/bin/ld: Undefined symbols:
typeinfo for wxListBase
typeinfo for wxApp
typeinfo for wxFrame
typeinfo for wxThread
collect2: ld returned 1 exit status
make: *** [helloworld] Error 1
Here is the result of 'wx-config --cxxflags':
-I/sw/lib/wx/include/mac-ansi-release-2.6 -I/sw/include/wx-2.6
-D__WXMAC__ -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -DNO_GCC_PRAGMA
I really don't why it doesn't compile. Could anyone help me?
Here is the code:
#include <string>
#include <iostream>
#include <sstream>
#include <getopt.h>
using namespace std;
// For compilers that don't support precompilation, includes "wx/wx.h".
#include "wx/wxprec.h"
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif
/**
* Every app should define a new class derived from wxApp.
* By overriding wxApp's OnInit() the program can be initialized, e.g.
by creating a new main window.
*/
class HelloWorldApp : public wxApp {
public:
virtual bool OnInit();
};
/**
* The main window is created by deriving a class from wxFrame and
giving it a menu and a status bar in its constructor.
* Also, any class that wishes to respond to any "event" (such as mouse
clicks or messages from the menu or a button)
* must declare an event table
*/
class HelloWorldFrame: public wxFrame {
private:
DECLARE_EVENT_TABLE()
public:
HelloWorldFrame(const wxString& title, const wxPoint& pos, const
wxSize& size);
void OnQuit(wxCommandEvent& event);
void OnAbout(wxCommandEvent& event);
};
/**
* In order to be able to react to a menu command, it must be given a
* unique identifier such as a const or an enum.
*/
enum {
ID_Quit = 1,
ID_About
};
// Now procede to implement an event table in which the events are
routed to their respective
// handler functions in the class HelloWorldFrame.
BEGIN_EVENT_TABLE(HelloWorldFrame, wxFrame)
EVT_MENU(ID_Quit, HelloWorldFrame::OnQuit)
EVT_MENU(ID_About, HelloWorldFrame::OnAbout)
END_EVENT_TABLE()
// As in all programs there must be a "main" function.
// Under wxWindows main is implemented using this macro, which creates
an application
// instance and starts the program.
IMPLEMENT_APP(HelloWorldApp)
//
/**
* wxApp::OnInit() is called upon startup and should be used to
initialize the program.
* The frame should get a title bar text ("Hello World") and a position
and start-up size.
* One frame can also be declared to be the top window.
* Returning TRUE indicates a successful intialization.
*/
bool HelloWorldApp::OnInit() {
HelloWorldFrame *frame = new HelloWorldFrame( "Hello World",
wxPoint(50,50), wxSize(450,340));
frame->Show( TRUE );
SetTopWindow( frame );
return TRUE;
}
/**
* Constructor of HelloWorldFrame
*/
HelloWorldFrame::HelloWorldFrame(const wxString& title,
const wxPoint& pos,
const wxSize& size) :
wxFrame((wxFrame *)NULL, -1, title, pos, size)
{
/* Creation du menu */
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 ); // ajout de la barre de menu
CreateStatusBar();
SetStatusText( "Welcome to wxWidgets!" );
}
/**
* HelloWorldFrame::OnQuit() closes the main window by calling Close().
* The paramter TRUE indicates that other windows have no veto power
such as
* after asking "Do you really want to close?"
*/
void HelloWorldFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) {
Close(TRUE);
}
/**
* MyFrame::OnAbout() will display a small window with some text in it.
*/
void HelloWorldFrame::OnAbout(wxCommandEvent& WXUNUSED(event)) {
wxMessageBox("This is a wxWidgets Hello world sample",
"About Hello World", wxOK | wxICON_INFORMATION,
this);
}
--
Sébastien VARRETTE |\/\/\/\/\/|
-------------------------------- | |
Ph.D student in Computer Science | __ __|
ID-IMAG Laboratory - Univ. of Luxembourg | / \/ \
(Grenoble, FRANCE) (LUXEMBOURG) | (o )o )
---------------------------------- /C \__/ --.
Mail : Sebastien...@imag.fr \_ , -'
Web : http://www-id.imag.fr/~svarrett/ | '\_______)
Phone : +352 46 66 44 600 | _)
+33 (O)6 74 57 90 05 | |
---------------------------- /`-----'\
Computing Security Research / \
---------------------------------------------------------------------
To unsubscribe, e-mail: wx-users-u...@lists.wxwidgets.org
For additional commands, e-mail: wx-use...@lists.wxwidgets.org
I finally solved the problem: I used g++ 4.0 yet if I compile with g++
3.3 everything goes well. I really don't know why g++ 4.0 break here.
If you also had this problem, pay attention to the wx-config you use as
Tiger comes with wx-windows 2.5: there coexist /sw/bin/wx-config (v.
2.6) and /usr/bin/wx-config (v 2.5) (for me, that wasn't a problem as
the PATH was correctly ordered)
So the problem is solved yet the g++ 4 issue remains. I would appreciate
to be personnaly notified if someone found a solution for this issue.
Best regards,
SV> I finally solved the problem: I used g++ 4.0 yet if I compile with g++
SV> 3.3 everything goes well. I really don't know why g++ 4.0 break here.
Because it's not compatible with g++ 3.3. You must build the main
application using the same compiler as you (or someone else in case you use
a prebuilt version) used to build the library.
Regards,
VZ
--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/