User forums > General (but related to Code::Blocks)
Linking Errors with 'Hello World' program using wxWidgets - HELP! :)
Rytz:
Having some frustrating linking problems. It's probably something simple and I'm just completely retarded.
Specs:
OS: Windows XP
IDE: Code::Blocks
Compiler: MinGW32
Library: wxWidgets
I'm having this problem with the 'Hello World' sample project from the help files included with wxWidgets. I also tried a different 'Hello World' sample from the net for wxWidgets and get the same result.
This is my first time around with the IDE, Compiler, and wxWidgets, so I kind of expected this. I'm used to using VS for just about everything so I wanted to move away from it.
I'll paste the sample 'HW' code and the linker error code below:
HW Code:
--- Code: ---#include <iostream.h>
#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);
private:
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( "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, "&About..." );
menuFile->AppendSeparator();
menuFile->Append( ID_Quit, "E&xit" );
wxMenuBar *menuBar = new wxMenuBar;
menuBar->Append( menuFile, "&File" );
SetMenuBar( menuBar );
CreateStatusBar();
SetStatusText( "Welcome to wxWidgets!" );}
void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) {
Close( true );}
void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event)) {
wxMessageBox( "This is a wxWidgets' Hello world sample",
"About Hello World", wxOK | wxICON_INFORMATION );}
--- End code ---
Linker Errors:
--- Code: ---Compiling: C:\Documents and Settings\Rytz\My Documents\_PROJECTS\CodeBlocks\Test1\test1.cpp
In file included from C:/Program Files/CodeBlocks/bin/../lib/gcc/mingw32/3.4.4/../../../../include/c++/3.4.4/backward/iostream.h:31,
from C:\Documents and Settings\Rytz\My Documents\_PROJECTS\CodeBlocks\Test1\test1.cpp:1:
C:/Program Files/CodeBlocks/bin/../lib/gcc/mingw32/3.4.4/../../../../include/c++/3.4.4/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <iostream> instead of the deprecated header <iostream.h>. To disable this warning use -Wno-deprecated.
Linking console executable: C:\Documents and Settings\Rytz\My Documents\_PROJECTS\CodeBlocks\Test1\test1.exe
C:\Documents and Settings\Rytz\My Documents\_PROJECTS\CodeBlocks\Test1\test1.o:test1.cpp:(.text+0x160): undefined reference to `wxAppConsole::CheckBuildOptions(char const*, char const*)'
C:\Documents and Settings\Rytz\My Documents\_PROJECTS\CodeBlocks\Test1\test1.o:test1.cpp:(.text+0x206): undefined reference to `wxEntry(HINSTANCE__*, HINSTANCE__*, char*, int)'
C:\Documents and Settings\Rytz\My Documents\_PROJECTS\CodeBlocks\Test1\test1.o:test1.cpp:(.text+0x419): undefined reference to `wxFrameNameStr'
C:\Documents and Settings\Rytz\My Documents\_PROJECTS\CodeBlocks\Test1\test1.o:test1.cpp:(.text+0x534): undefined reference to `wxEmptyString'
C:\Documents and Settings\Rytz\My Documents\_PROJECTS\CodeBlocks\Test1\test1.o:test1.cpp:(.text+0x61e): undefined reference to `wxEmptyString'
C:\Documents and Settings\Rytz\My Documents\_PROJECTS\CodeBlocks\Test1\test1.o:test1.cpp:(.text+0x718): undefined reference to `wxMenuBar::wxMenuBar()'
C:\Documents and Settings\Rytz\My Documents\_PROJECTS\CodeBlocks\Test1\test1.o:test1.cpp:(.text+0x7e0): undefined reference to `wxFrameBase::SetMenuBar(wxMenuBar*)'
C:\Documents and Settings\Rytz\My Documents\_PROJECTS\CodeBlocks\Test1\test1.o:test1.cpp:(.text+0x7e5): undefined reference to `wxStatusLineNameStr'
C:\Documents and Settings\Rytz\My Documents\_PROJECTS\CodeBlocks\Test1\test1.o:test1.cpp:(.text+0x825): undefined reference to `wxFrameBase::CreateStatusBar(int, long, int, wxString const&)'
C:\Documents and Settings\Rytz\My Documents\_PROJECTS\CodeBlocks\Test1\test1.o:test1.cpp:(.text+0x895): undefined reference to `wxFrameBase::SetStatusText(wxString const&, int)'
C:\Documents and Settings\Rytz\My Documents\_PROJECTS\CodeBlocks\Test1\test1.o:test1.cpp:(.text+0x97d): undefined reference to `wxFrame::~wxFrame()'
C:\Documents and Settings\Rytz\My Documents\_PROJECTS\CodeBlocks\Test1\test1.o:test1.cpp:(.text+0x9f1): undefined reference to `wxFrameNameStr'
C:\Documents and Settings\Rytz\My Documents\_PROJECTS\CodeBlocks\Test1\test1.o:test1.cpp:(.text+0xb0c): undefined reference to `wxEmptyString'
C:\Documents and Settings\Rytz\My Documents\_PROJECTS\CodeBlocks\Test1\test1.o:test1.cpp:(.text+0xbf6): undefined reference to `wxEmptyString'
C:\Documents and Settings\Rytz\My Documents\_PROJECTS\CodeBlocks\Test1\test1.o:test1.cpp:(.text+0xcf0): undefined reference to `wxMenuBar::wxMenuBar()'
C:\Documents and Settings\Rytz\My Documents\_PROJECTS\CodeBlocks\Test1\test1.o:test1.cpp:(.text+0xdb8): undefined reference to `wxFrameBase::SetMenuBar(wxMenuBar*)'
C:\Documents and Settings\Rytz\My Documents\_PROJECTS\CodeBlocks\Test1\test1.o:test1.cpp:(.text+0xdbd): undefined reference to `wxStatusLineNameStr'
C:\Documents and Settings\Rytz\My Documents\_PROJECTS\CodeBlocks\Test1\test1.o:test1.cpp:(.text+0xdfd): undefined reference to `wxFrameBase::CreateStatusBar(int, long, int, wxString const&)'
C:\Documents and Settings\Rytz\My Documents\_PROJECTS\CodeBlocks\Test1\test1.o:test1.cpp:(.text+0xe6d): undefined reference to `wxFrameBase::SetStatusText(wxString const&, int)'
C:\Documents and Settings\Rytz\My Documents\_PROJECTS\CodeBlocks\Test1\test1.o:test1.cpp:(.text+0xf55): undefined reference to `wxFrame::~wxFrame()'
C:\Documents and Settings\Rytz\My Documents\_PROJECTS\CodeBlocks\Test1\test1.o:test1.cpp:(.text+0xfa5): undefined reference to `wxWindowBase::Close(bool)'
C:\Documents and Settings\Rytz\My Documents\_PROJECTS\CodeBlocks\Test1\test1.o:test1.cpp:(.text+0x1053): undefined reference to `wxMessageBox(wxString const&, wxString const&, long, wxWindow*, int, int)'
C:\Documents and Settings\Rytz\My Documents\_PROJECTS\CodeBlocks\Test1\test1.o:test1.cpp:(.text+0x111b): undefined reference to `wxEventHashTable::wxEventHashTable(wxEventTable const&)'
C:\Documents and Settings\Rytz\My Documents\_PROJECTS\CodeBlocks\Test1\test1.o:test1.cpp:(.text+0x116b): undefined reference to `wxEVT_COMMAND_MENU_SELECTED'
C:\Documents and Settings\Rytz\My Documents\_PROJECTS\CodeBlocks\Test1\test1.o:test1.cpp:(.text+0x11a8): undefined reference to `wxEVT_COMMAND_MENU_SELECTED'
C:\Documents and Settings\Rytz\My Documents\_PROJECTS\CodeBlocks\Test1\test1.o:test1.cpp:(.text+0x11e5): undefined reference to `wxEVT_NULL'
C:\Documents and Settings\Rytz\My Documents\_PROJECTS\CodeBlocks\Test1\test1.o:test1.cpp:(.text+0x122b): undefined reference to `wxEventHashTable::~wxEventHashTable()'
C:\Documents and Settings\Rytz\My Documents\_PROJECTS\CodeBlocks\Test1\test1.o:test1.cpp:(.rdata+0x0): undefined reference to `wxFrame::sm_eventTable'.............[truncated by me]
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 8 seconds)
0 errors, 1 warnings
--- End code ---
So you get the point. The list goes on to be about 3-4 times that size.
Go easy on me please :). I'm spoiled by VS .NET and I hate it. Plus I'm tired of working with MS platforms only.
I apologize if this isn't even Code::Blocks related. This is just really bugging me. Any info would be much appreciated. Thanks :).
sethjackson:
Umm are you linking in the wxWidgets libs?
Rytz:
--- Quote from: sethjackson on May 18, 2006, 01:00:33 am ---Umm are you linking in the wxWidgets libs?
--- End quote ---
Thanks for the response. I did put the lib directories for both Code::Blocks and wxWidgets. Do I need to do add each lib file individually on the linker tab?
georgie:
The problem is of course, with the many different directions on how to build wxwidgets, and the resulting different names for the libraries that are created by the build of wxwidgets, that it's no wonder you and many many others are having difficulties in getting something as simple as "hello world" to compile and link.
sethjackson:
--- Quote from: Rytz on May 18, 2006, 02:51:50 am ---
--- Quote from: sethjackson on May 18, 2006, 01:00:33 am ---Umm are you linking in the wxWidgets libs?
--- End quote ---
Thanks for the response. I did put the lib directories for both Code::Blocks and wxWidgets. Do I need to do add each lib file individually on the linker tab?
--- End quote ---
Yes something like wxmsw26. Look in path_to_wxWidgets\lib\gcc_dll or path_to_wxWidgets\lib\gcc_lib.
Navigation
[0] Message Index
[#] Next page
Go to full version