It is currently Wed Sep 08, 2010 6:15 am

All times are UTC - 5 hours [ DST ]




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: Undefined symbols error from the tutorials
PostPosted: Wed Jul 21, 2010 9:38 am 
Joined: Wed Jul 21, 2010 9:19 am
Posts: 5

Starting with the SDL Events tutorial, my code no longer compiles with the following error:

Code:
Undefined symbols:
  "CEvent::OnUser(unsigned char, int, void*, void*)", referenced from:
      vtable for CAppin CApp_OnEvent.o
      vtable for CEventin CEvent.o
  "CEvent::OnMinimize()", referenced from:
      vtable for CAppin CApp_OnEvent.o
      vtable for CEventin CEvent.o
  "CEvent::OnJoyBall(unsigned char, unsigned char, short, short)", referenced from:
      vtable for CAppin CApp_OnEvent.o
      vtable for CEventin CEvent.o
  "CEvent::OnJoyAxis(unsigned char, unsigned char, short)", referenced from:
      vtable for CAppin CApp_OnEvent.o
      vtable for CEventin CEvent.o
  "CEvent::OnJoyButtonUp(unsigned char, unsigned char)", referenced from:
      vtable for CAppin CApp_OnEvent.o
      vtable for CEventin CEvent.o
  "CEvent::OnJoyHat(unsigned char, unsigned char, unsigned char)", referenced from:
      vtable for CAppin CApp_OnEvent.o
      vtable for CEventin CEvent.o
  "CEvent::OnRestore()", referenced from:
      vtable for CAppin CApp_OnEvent.o
      vtable for CEventin CEvent.o
  "CEvent::OnJoyButtonDown(unsigned char, unsigned char)", referenced from:
      vtable for CAppin CApp_OnEvent.o
      vtable for CEventin CEvent.o
  "CEvent::OnExit()", referenced from:
      vtable for CEventin CEvent.o
  "CEvent::OnExpose()", referenced from:
      vtable for CAppin CApp_OnEvent.o
      vtable for CEventin CEvent.o
  "CEvent::OnResize(int, int)", referenced from:
      vtable for CAppin CApp_OnEvent.o
      vtable for CEventin CEvent.o
ld: symbol(s) not found
collect2: ld returned 1 exit status


I'm not sure what to do, and this is using the exact files from the tutorials, so I don't know where there would be a mistake.
I realize that the compiler can't find the definitions of the symbols above (that is the problem, right?), but I don't know where it wants them.
If it helps, I'm using Xcode, and it hasn't marked errors in any of my files.

_________________
//Pazmivaniye


Offline
 Profile  
 Post subject: Re: Undefined symbols error from the tutorials
PostPosted: Fri Jul 23, 2010 1:30 pm 
Joined: Wed Jul 21, 2010 9:19 am
Posts: 5

Anyone have an idea?

_________________
//Pazmivaniye


Offline
 Profile  
 Post subject: Re: Undefined symbols error from the tutorials
PostPosted: Fri Jul 23, 2010 6:31 pm 
Joined: Wed Jul 21, 2010 9:19 am
Posts: 5

The error has changed now:

Code:
Undefined symbols:
  "CApp::SetCell(int, int)", referenced from:
      CApp::OnLButtonDown(int, int)in CApp_OnEvent.o
      CApp::OnLButtonDown(int, int)in CApp_OnEvent.o
ld: symbol(s) not found
collect2: ld returned 1 exit status


Does anyone have an idea? :|

_________________
//Pazmivaniye


Offline
 Profile  
 Post subject: Re: Undefined symbols error from the tutorials
PostPosted: Sat Jul 24, 2010 1:38 pm 
Joined: Wed Jul 21, 2010 9:19 am
Posts: 5

Okay, now the program compiles, runs, etc. but I'm not sure how I fixed it. I shrunk from the big group of errors to the one about SetCell by editing CApp.cpp without actually changing it, saving, and building, and I tried that today and all the errors vanished. Any ideas why that would happen?

_________________
//Pazmivaniye


Offline
 Profile  
 Post subject: Re: Undefined symbols error from the tutorials
PostPosted: Sun Jul 25, 2010 7:38 am 
User avatar
Joined: Tue Apr 06, 2010 4:54 pm
Posts: 25

Hi Pazmivaniye.

What IDE are you using?

Regarding your first and second error messages, it mentions the vtable (virtual table). This is a table containing pointers to virtual functions that is used to deduce what type of object you are dealing with when you are dealing with derived classes. Also, it says that there are undefined symbols and shows you the .o files. In my experience, this typically means that you defined a function (a virtual one in this case), but the implementation is missing.

How did you edit CApp.cpp without changes? Did you change something then change it back again?

_________________
- NordCoder


Offline
 Profile  
 Post subject: Re: Undefined symbols error from the tutorials
PostPosted: Sun Jul 25, 2010 11:14 am 
Joined: Wed Jul 21, 2010 9:19 am
Posts: 5

I used Xcode, and yes, I did change something, then changed it back and saved. Now I keep getting a returned 225, but I think I can find the problem.

_________________
//Pazmivaniye


Offline
 Profile  
 Post subject: Re: Undefined symbols error from the tutorials
PostPosted: Mon Jul 26, 2010 3:11 am 
User avatar
Joined: Tue Apr 06, 2010 4:54 pm
Posts: 25

Does main return 225? :shock: Yikes! Well, if you can find the problem then no worries.

_________________
- NordCoder


Offline
 Profile  
 Post subject: Re: Undefined symbols error from the tutorials
PostPosted: Tue Jul 27, 2010 10:28 pm 
Joined: Thu Jun 18, 2009 11:47 pm
Posts: 33

For the return error, maybe you miss an "return 0" in the end of the main() function. For the vtable error and linking errors, i got some similar results using gcc instead of g++ when linking .o objects already compiled. I've never used Xcode, but you maybe there's some similar option in there.

Have you tried compiling them by hand, using the command line?


Offline
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC - 5 hours [ DST ]


 Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
 
cron