Linux Format forums Forum Index Linux Format forums
Help, discussion, magazine feedback and more
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Trout Wars and TTF

 
Post new topic   Reply to topic    Linux Format forums Forum Index -> Programming
View previous topic :: View next topic  
Author Message
laymanofsdl



Joined: Sun Jul 31, 2005 1:31 pm
Posts: 2

PostPosted: Sun Jul 31, 2005 1:42 pm    Post subject: Trout Wars and TTF Reply with quote

So I've been meaning to do the Trout Wars tutorials for a long time. Finally I get round to doing it and everything's ok for a while until, naturally, I hit a snag. Unfortunately it seems that the forums have been updated and anything anyone might have written about Trout Wars has gone:( So I don't know if anyone here has any clue what I'm on about but I'd love some help.

So I'm trying to compile the second tutorial in LXF54. Particularly the fonts part. The first part compiled fine but the second part is coming up with errors I don't understand. Here they are.

Code:
richard@ubuntu:~$ g++ TroutWars.cpp -o TroutWars `sdl-config --libs`
/tmp/ccQmHnPf.o(.text+0x59): In function `CTWGame::CTWGame[not-in-charge]()':
: undefined reference to `TTF_Init'
/tmp/ccQmHnPf.o(.text+0x70): In function `CTWGame::CTWGame[not-in-charge]()':
: undefined reference to `TTF_OpenFont'
/tmp/ccQmHnPf.o(.text+0x7a): In function `CTWGame::CTWGame[not-in-charge]()':
: undefined reference to `TTF_Quit'
/tmp/ccQmHnPf.o(.text+0xdb): In function `CTWGame::CTWGame[not-in-charge]()':
: undefined reference to `TTF_RenderText_Blended'
/tmp/ccQmHnPf.o(.text+0x1cb): In function `CTWGame::CTWGame[in-charge]()':
: undefined reference to `TTF_Init'
/tmp/ccQmHnPf.o(.text+0x1e2): In function `CTWGame::CTWGame[in-charge]()':
: undefined reference to `TTF_OpenFont'
/tmp/ccQmHnPf.o(.text+0x1ec): In function `CTWGame::CTWGame[in-charge]()':
: undefined reference to `TTF_Quit'
/tmp/ccQmHnPf.o(.text+0x24d): In function `CTWGame::CTWGame[in-charge]()':
: undefined reference to `TTF_RenderText_Blended'
/tmp/ccQmHnPf.o(.text+0x319): In function `CTWGame::~CTWGame [not-in-charge]()':: undefined reference to `TTF_CloseFont'
/tmp/ccQmHnPf.o(.text+0x363): In function `CTWGame::~CTWGame [in-charge]()':
: undefined reference to `TTF_CloseFont'
collect2: ld returned 1 exit status
richard@ubuntu:~$


As far as I know I've got all the sdl ttf stuff installed and my code is exactly as it describes it in the mag. I seem to have misplaced the disc that came with the mag so I can't even check this. But I don't think it's the codes fault. I'm stumped. Thanks for any help
Back to top
View user's profile Send private message
laymanofsdl



Joined: Sun Jul 31, 2005 1:31 pm
Posts: 2

PostPosted: Sun Jul 31, 2005 2:03 pm    Post subject: Reply with quote

I've solved it myself. Wasn't so much of a mystery after all. A quick look in some SDL_ttf.h documentation and i realise that i should be using "$ g++ TroutWars.cpp -o TroutWars `sdl-config --libs` -lSDL_ttf" and not "$ g++ TroutWars.cpp -o TroutWars `sdl-config --libs".

I had another problem but that was just to do with setting up the path to my font correctly. Sorry for taking up forum space for a problem i could solve myself:)
Back to top
View user's profile Send private message
mota



Joined: Sun Aug 07, 2005 9:47 pm
Posts: 2

PostPosted: Sun Aug 07, 2005 10:12 pm    Post subject: Reply with quote

Glad to meet a fellow procrastinator. Also, I'm glad you "wasted space" with your observations.

I just went throught the first toutorial and was getting segfaults. Googling around I found some references to segfaults in TroutWars, but couldn't find anysolutions (parts of the old forums were still cached).

This was my gdb output:
Code:
(gdb) s
33        while(done==0){
(gdb) s
35          while ( SDL_PollEvent(event)){
(gdb) s

Program received signal SIGSEGV, Segmentation fault.
0x00002aaaaabfe7ea in SDL_PeepEvents () from /usr/lib/libSDL-1.2.so.0
(gdb) s
Single stepping until exit from function SDL_PeepEvents,
which has no line number information.
0x00002aaaaad3cc20 in __pthread_sighandler () from /lib/libpthread.so.0
(gdb) s
Single stepping until exit from function __pthread_sighandler,
which has no line number information.
Fatal signal: Segmentation Fault (SDL Parachute Deployed)

Program exited with code 0365.



I replaced:
Code:
void CTWGame::Play(){
  int done=0;
  while(done==0){
    SDL_Event* event;
    while ( SDL_PollEvent(event)){
      if(event->type==SDL_QUIT) done=1;
    }
    DrawScene();
  }
}


With:
Code:
void CTWGame::Play(){
  int done=0;
  while(done==0){
    SDL_Event event;
    while ( SDL_PollEvent(&event)){
      if(event.type==SDL_QUIT) done=1;
    }
    DrawScene();
  }
}


Now everthing runs as expected. Unfortunatly I couldn't figure out why the origional code broke. If anyone could explain what was wrong with the previous code...or if something was off in my SDL environment I'd be very grateful. If it matters I'm running on gentoo on an AMD64 architecture.
Back to top
View user's profile Send private message
View previous topic :: View next topic  
Display posts from previous:   
Post new topic   Reply to topic    Linux Format forums Forum Index -> Programming All times are GMT
Page 1 of 1

 
Jump to:  
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 vote in polls in this forum
Linux Format forums topic RSS feed 


Powered by phpBB © 2001, 2005 phpBB Group


Copyright 2011 Future Publishing, all rights reserved.


Web hosting by UKFast