Major problem, please help

Started by
9 comments, last by zike22 18 years, 9 months ago
I'm reciving these 2 errors, and i don't know what to do... - [Linker error] undefined reference to `libmsvcrt_a_iname' - [Linker error] undefined reference to `_nm__atexit' Here's my source, I searched online for a solution for a bit, but most of the information was etheir out of date, irrelavent, or to confusing for me to understand

// player = (SPRITE*)malloc(sizeof(SPRITE));
// the (SPRITE*) is major important

#include <stdio.h>
#include <allegro.h>
#include "mappyal.h"


#define MODE GFX_AUTODETECT_WINDOWED
#define WIDTH 640
#define HEIGHT 480
#define JUMPIT 1600

//define the sprite structure
typedef struct SPRITE
{
    int dir, alive;
    int x,y;
    int width,height;
    int xspeed,yspeed;
    int xdelay,ydelay;
    int xcount,ycount;
    int curframe,maxframe,animdir;
    int framecount,framedelay;
}SPRITE;

//declare the bitmaps and sprites
BITMAP *player_image[8];
SPRITE *player;
BITMAP *buffer;	
BITMAP *temp;


//tile grabber
BITMAP *grabframe(BITMAP *source, 
                  int width, int height, 
                  int startx, int starty, 
                  int columns, int frame)
{
    BITMAP *temp = create_bitmap(width,height);
    int x = startx + (frame % columns) * width;
    int y = starty + (frame / columns) * height;
    blit(source,temp,x,y,0,0,width,height);
    return temp;
}


int collided(int x, int y)
{
    BLKSTR *blockdata;
	blockdata = MapGetBlock(x/mapblockwidth, y/mapblockheight);
	return blockdata->tl;
}


int main (void)
{
    int mapxoff, mapyoff;
    int oldpy, oldpx;
    int facing = 0;
    int jump = JUMPIT;
    int n;

	allegro_init();	
	install_timer();
	install_keyboard();


	set_color_depth(16);
	set_gfx_mode(MODE, WIDTH, HEIGHT, 0, 0);


    temp = load_bitmap("guy.bmp", NULL);
    for (n=0; n<8; n++)
        player_image[n] = grabframe(temp,50,64,0,0,8,n);
    destroy_bitmap(temp);

    player = (SPRITE*)malloc(sizeof(SPRITE));
    player->x = 80;
    player->y = 100;
    player->curframe=0;
    player->framecount=0;
    player->framedelay=6;
    player->maxframe=7;
    player->width=player_image[0]->w;
    player->height=player_image[0]->h;


    //load the map
	if (MapLoad("sample.fmp")) exit(0);	

    //create the double buffer
	buffer = create_bitmap (WIDTH, HEIGHT);
	clear(buffer);

    //main loop
	while (!key[KEY_ESC])
	{

		oldpy = player->y; 
        oldpx = player->x;

		if (key[KEY_RIGHT]) 
        { 
            facing = 1; 
            player->x+=2; 
            if (++player->framecount > player->framedelay)
            {
                player->framecount=0;
                if (++player->curframe > player->maxframe)
                    player->curframe=1;
            }
        }
        else if (key[KEY_LEFT]) 
        { 
            facing = 0; 
            player->x-=2; 
            if (++player->framecount > player->framedelay)
            {
                player->framecount=0;
                if (++player->curframe > player->maxframe)
                    player->curframe=1;
            }
        }
        else player->curframe=0;

        //handle jumping
        if (jump==JUMPIT)
        { 
            if (!collided(player->x + player->width/2, 
                player->y + player->height + 5))
                jump = 0; 

		    if (key[KEY_SPACE]) 
                jump = 30;
        }
        else
        {
            player->y -= jump/3; 
            jump--; 
        }

		if (jump<0) 
        { 
            if (collided(player->x + player->width/2, 
                player->y + player->height))
			{ 
                jump = JUMPIT; 
                while (collided(player->x + player->width/2, 
                    player->y + player->height))
                    player->y -= 2; 
            } 
        }

        //check for collided with foreground tiles
		if (!facing) 
        { 
            if (collided(player->x, player->y + player->height)) 
                player->x = oldpx; 
        }
		else 
        { 
            if (collided(player->x + player->width, 
                player->y + player->height)) 
                player->x = oldpx; 
        }
		
        //update the map scroll position
		mapxoff = player->x + player->width/2 - WIDTH/2 + 10;
		mapyoff = player->y + player->height/2 - HEIGHT/2 + 10;


        //avoid moving beyond the map edge
		if (mapxoff < 0) mapxoff = 0;
		if (mapxoff > (mapwidth * mapblockwidth - WIDTH))
            mapxoff = mapwidth * mapblockwidth - WIDTH;
		if (mapyoff < 0) 
            mapyoff = 0;
		if (mapyoff > (mapheight * mapblockheight - HEIGHT)) 
            mapyoff = mapheight * mapblockheight - HEIGHT;

        //draw the background tiles
		MapDrawBG(buffer, mapxoff, mapyoff, 0, 0, WIDTH-1, HEIGHT-1);

        //draw foreground tiles
		MapDrawFG(buffer, mapxoff, mapyoff, 0, 0, WIDTH-1, HEIGHT-1, 0);

        //draw the player's sprite
		if (facing) 
            draw_sprite(buffer, player_image[player->curframe], 
                (player->x-mapxoff), (player->y-mapyoff+1));
		else 
            draw_sprite_h_flip(buffer, player_image[player->curframe], 
                (player->x-mapxoff), (player->y-mapyoff));

        //blit the double buffer 
		vsync();
        acquire_screen();
		blit(buffer, screen, 0, 0, 0, 0, WIDTH-1, HEIGHT-1);
        release_screen();

	} //while

    for (n=0; n<8; n++)
        destroy_bitmap(player_image[n]);
    free(player);
	destroy_bitmap(buffer);
	MapFreeMem ();
	allegro_exit();
	return 0;
}

END_OF_MAIN();



------------------------------------------------------------------------------------------- My Email: [email=zike22@aol.com]zike22@aol.com[/email] - My AIM: zike22@AIM
"Facts are chains that bind perception and fetter truth. For a man can remake the world if he has a dream and no facts to cloud his mind." - The Emperor, WarHammer 40K
Advertisement
Are you using functions called iname and atexit anywhere?

If so, why don't you use the Find function in windows to search all your *.lib files for iname and atexit. Believe it or not, this sort of thing has worked for me, although you may get extra results (libs that reference the function but don't define it).

Mike C.
http://www.coolgroups.com/zoomer

Mike C.http://www.coolgroups.com/zoomer/http://www.coolgroups.com/ez/
I'm gonna sound like a noob, but how would i go about that, just open all my lib functions and search. And if i do happen to find them, what should i do then, erase those functions???
------------------------------------------------------------------------------------------- My Email: [email=zike22@aol.com]zike22@aol.com[/email] - My AIM: zike22@AIM
"Facts are chains that bind perception and fetter truth. For a man can remake the world if he has a dream and no facts to cloud his mind." - The Emperor, WarHammer 40K
zike 22 it's a joke ?
use windows search. search inside of file u have this feature. I use it sometimes and it often helps. Usually you should link this library to your project
You're probably not linking with the C Runtime libraries. What compiler/linker are you using, and what is the command line?
Dubito, Cogito ergo sum.
1) What compiler are you using? If it is the express edition, chances are you don't have the platform SDK. You need this to develop windows applications.

2) If you are, try compiling it as a multi-threaded DLL application. I dunno, it does the trick for most of SDL's linker errors.

3) For the love of all that is good and holy, please don't use allegro... DOS is dead. END_OF_MAIN? what kind of cheap macro hack is that?

4) Include <stdlib.h>, that might make some of your errors go away.
HxRender | Cornerstone SDL TutorialsCurrently picking on: Hedos, Programmer One
Dev-C++, Allegro library, programing in C++
------------------------------------------------------------------------------------------- My Email: [email=zike22@aol.com]zike22@aol.com[/email] - My AIM: zike22@AIM
"Facts are chains that bind perception and fetter truth. For a man can remake the world if he has a dream and no facts to cloud his mind." - The Emperor, WarHammer 40K
You may not be linking to the library.
Which library would it be, I really don't understand the whole gcc & mingw thing. Also if you knew the name of the lib file that would really help.
------------------------------------------------------------------------------------------- My Email: [email=zike22@aol.com]zike22@aol.com[/email] - My AIM: zike22@AIM
"Facts are chains that bind perception and fetter truth. For a man can remake the world if he has a dream and no facts to cloud his mind." - The Emperor, WarHammer 40K
Well it seems the VC++ run time libraries.

What compiler are you using?

This topic is closed to new replies.

Advertisement