dev.gamez.lv Forum Index dev.gamez.lv
Latvian Game Developers Community
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups 

Precīzs ejoša source duplicate liek manam VC6 mest errorus

 
dev.gamez.lv Forum Index -> OpenGL
View previous topic :: View next topic  
Author Message
estetique



Joined: 02 Oct 2008
Posts: 20
Location: Riga

PostPosted: Sat Oct 04, 2008 11:18 pm    Post subject: Precīzs ejoša source duplicate liek manam VC6 mest errorus

Testa nolūkos, nokopēju ejoša piemēra source kodu, un rezultātā saņemu errorus !
Esmu pievienojis Linker : OpenGL32.lib GLu32.lib GLaux.lib
Arī pats SDL priekš VC6 man ir uzstādīts ..

Kur varētu būt problēma ?

Quote:
main.obj : error LNK2001: unresolved external symbol _SDL_LockSurface
main.obj : error LNK2001: unresolved external symbol _SDL_UnlockSurface
main.obj : error LNK2001: unresolved external symbol _SDL_MapRGB
main.obj : error LNK2001: unresolved external symbol _SDL_Flip
main.obj : error LNK2001: unresolved external symbol _SDL_PollEvent
main.obj : error LNK2001: unresolved external symbol _SDL_SetVideoMode
main.obj : error LNK2001: unresolved external symbol _SDL_Quit
main.obj : error LNK2001: unresolved external symbol _SDL_GetError
main.obj : error LNK2001: unresolved external symbol _SDL_Init
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/testsdl1.exe : fatal error LNK1120: 10 unresolved externals
Error executing link.exe.

testsdl1.exe - 11 error(s), 8 warning(s)


Code:
#include <stdio.h>
#include <stdlib.h>

#include <SDL/SDL.h>

void Slock(SDL_Surface *screen)
{
  if ( SDL_MUSTLOCK(screen) )
  {
    if ( SDL_LockSurface(screen) < 0 )
    {
      return;
    }
  }
}

void Sulock(SDL_Surface *screen)
{
  if ( SDL_MUSTLOCK(screen) )
  {
    SDL_UnlockSurface(screen);
  }
}

void DrawPixel(SDL_Surface *screen, int x, int y,
                                    Uint8 R, Uint8 G, Uint8 B)
{
  Uint32 color = SDL_MapRGB(screen->format, R, G, B);
  switch (screen->format->BytesPerPixel)
  {
    case 1: // Assuming 8-bpp
      {
        Uint8 *bufp;
        bufp = (Uint8 *)screen->pixels + y*screen->pitch + x;
        *bufp = color;
      }
      break;
    case 2: // Probably 15-bpp or 16-bpp
      {
        Uint16 *bufp;
        bufp = (Uint16 *)screen->pixels + y*screen->pitch/2 + x;
        *bufp = color;
      }
      break;
    case 3: // Slow 24-bpp mode, usually not used
      {
        Uint8 *bufp;
        bufp = (Uint8 *)screen->pixels + y*screen->pitch + x * 3;
        if(SDL_BYTEORDER == SDL_LIL_ENDIAN)
        {
          bufp[0] = color;
          bufp[1] = color >> 8;
          bufp[2] = color >> 16;
        } else {
          bufp[2] = color;
          bufp[1] = color >> 8;
          bufp[0] = color >> 16;
        }
      }
      break;
    case 4: // Probably 32-bpp
      {
        Uint32 *bufp;
        bufp = (Uint32 *)screen->pixels + y*screen->pitch/4 + x;
        *bufp = color;
      }
      break;
  }
}

void DrawScene(SDL_Surface *screen)
{
  Slock(screen);
  for(int x=0;x<640;x++)
  {
    for(int y=0;y<480;y++)
    {
      DrawPixel(screen, x,y,y/2,y/2,x/3);
    }
  }
  Sulock(screen);
  SDL_Flip(screen);
}

int main(int argc, char *argv[])
{

  if ( SDL_Init(SDL_INIT_AUDIO|SDL_INIT_VIDEO) < 0 )
  {
    printf("Unable to init SDL: %s\n", SDL_GetError());
    exit(1);
  }
  atexit(SDL_Quit);

  SDL_Surface *screen;
  screen=SDL_SetVideoMode(640,480,32,SDL_HWSURFACE|SDL_DOUBLEBUF);
  if ( screen == NULL )
  {
    printf("Unable to set 640x480 video: %s\n", SDL_GetError());
    exit(1);
  }
  int done=0;

  while(done == 0)
  {
    SDL_Event event;

    while ( SDL_PollEvent(&event) )
    {
      if ( event.type == SDL_QUIT )  {  done = 1;  }

      if ( event.type == SDL_KEYDOWN )
      {
        if ( event.key.keysym.sym == SDLK_ESCAPE ) { done = 1; }
      }
    }

    DrawScene(screen);
  }

  return 0;
}
Rolling Eyes
_________________
Pirms keries pie programmeshanas - noperc rezerves smadzenu paari .. noderees Very Happy
Back to top
View user's profile
bubu
Indago Uzvarētājs
Indago Uzvarētājs


Joined: 23 Mar 2004
Posts: 3223
Location: Riga

PostPosted: Sat Oct 04, 2008 11:26 pm    Post subject:

Tu linkerim neesi pievienojis SDL.lib failu, kurā ir visas tas SDL_xxx funkcijas, kā arī SDLmain.lib failu, kurā ir SDL overraidotā main funkcija.

Un vēl es tev ļoti silti ieteiktu izmest VC6 miskastē pēc iespējas ātrāk. Tas ir kautkas aizvēsturisks, kas ļoti slikti kompilē C++ standartam atbilstošu C++ kodu. Tā vietā ņem Code::Blocks + GCC vai arī bezmaksas no Microsoft dabūjamo Visual C++ 2008 Express edition.
Back to top
View user's profile Send e-mail
estetique



Joined: 02 Oct 2008
Posts: 20
Location: Riga

PostPosted: Sat Oct 04, 2008 11:55 pm    Post subject:

Par kodu, un erroriem : paldies par labojumu .. viss aizgaja beidzot ! Par tiem SDL lib failiem nekur infu neredzeju, tadelj ari vinjus nepiemetu.

Par VC6 : nemsu veera ( preciizak - jau kachaju 2008 no Microsoft lapas ) Idea
_________________
Pirms keries pie programmeshanas - noperc rezerves smadzenu paari .. noderees Very Happy
Back to top
View user's profile
Display posts from previous:   
dev.gamez.lv Forum Index -> OpenGL All times are GMT + 2 Hours
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


Powered by phpBB © 2001, 2005 phpBB Group