LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 03-07-2006, 10:23 PM   #1
kevman
LQ Newbie
 
Registered: Jan 2005
Posts: 20

Rep: Reputation: 0
my own tiny SDL program dumps a lot of symbols when it is run


OK, so I have started to learn SDL, and have made the following tiny, badly-structured program:

Code:
#include <stdio.h>
#include "SDL.h"


int main() {
	if( SDL_Init(SDL_INIT_VIDEO) < 0 ) {
		printf("Could not initialize SDL: %s\n", SDL_GetError());
  		return -1;
		}
	atexit(SDL_Quit);
	printf("SDL initialized\n");

	SDL_Surface* screen = SDL_SetVideoMode(640, 480, 32, 0);
	if( !screen ) {
		printf("Couldn't open a window: %s\n", SDL_GetError());
		return -1;
		}

	SDL_Surface* img = SDL_LoadBMP("image.bmp");

	if( !cubeimg ) {
		printf("Couldn't load the bitmap: %s\n", SDL_GetError());
		return -1;
		}
	img = SDL_DisplayFormat(img);
	SDL_Rect * destrect;
	destrect->x = 200;
	destrect->y = 200;
	SDL_BlitSurface(img, NULL, screen, destrect);
	SDL_UpdateRect(screen, 0, 0, 640, 480);
	sleep(5);
	SDL_FreeSurface(img);
	printf("Quitting SDL\n");
	return 0;
	}
When I compile and run it, it works as expected, but things like
Code:
SDL initialized
     20778:     symbol=SDL_UpperBlit;  lookup in file=./a.out
     20778:     symbol=SDL_UpperBlit;  lookup in file=/usr/lib64/libSDL-1.2.so.0
     20778:     symbol=memcpy;  lookup in file=./a.out
     20778:     symbol=memcpy;  lookup in file=/usr/lib64/libSDL-1.2.so.0
     20778:     symbol=memcpy;  lookup in file=/lib64/tls/libc.so.6
     20778:     symbol=SDL_UpdateRect;  lookup in file=./a.out
...
appear. At the end of all the symbols, it shows this:
Code:
...
     20778:     symbol=__cxa_finalize;  lookup in file=/lib64/tls/libc.so.6
     20778:
     20778:     runtime linker statistics:
     20778:                final number of relocations: 2296
     20778:     final number of relocations from cache: 1168
I don't think this has much to do with SDL, but more of my thinking like a .

Does anybody know why this is happening, and how to stop it?
I think it has something to do with the dynamic linker...

Thanks in advance...
 
Old 03-08-2006, 04:57 PM   #2
xhi
Senior Member
 
Registered: Mar 2005
Location: USA::Pennsylvania
Distribution: Slackware
Posts: 1,065

Rep: Reputation: 45
a guess at what may be a problem would be that you never allocate a SDL_Rect to use with your destrect ptr..
Code:
SDL_Rect * destrect;
destrect->x = 200;
destrect->y = 200;
just do it like this..
Code:
SDL_Rect destrect;
destrect.x = 200;
destrect.y = 200;
SDL_BlitSurface(img, NULL, screen, &destrect);
this may or may not have been the problem.. it wont compile as there are undeclared variables and such in it and i dont feel like fixing it to compile it..
 
Old 03-08-2006, 06:05 PM   #3
kevman
LQ Newbie
 
Registered: Jan 2005
Posts: 20

Original Poster
Rep: Reputation: 0
thx, now it works...i guess i should remember not to trust the default "random" addresses!

BTW, the documentation states that the blit function only looks at the x and y members of a rectangle (for the destination one). so it will compile.

Do you know why it outputs that junk though?

Last edited by kevman; 03-08-2006 at 06:06 PM. Reason: i don't like to show my signature
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to compile a program with SDL RHLinuxGUY Programming 5 01-03-2006 12:12 AM
Looking for an IDE to program using SDL pujolasdf Linux - Software 2 04-02-2005 04:31 PM
Trying to program an SDL application but cannot find the SDL.h file:SuSE 9.2&KDevelop pujolasdf Linux - Newbie 4 03-13-2005 07:50 AM
Anyone gotten Homeworld SDL to run??? JaseP Linux - Games 4 09-27-2004 12:10 PM
Can I use a lot of decimals in my C program? Golradir Programming 14 07-04-2004 12:40 PM


All times are GMT -5. The time now is 12:20 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration