GPWiki.org
GPWiki.org
It is currently Mon May 20, 2013 8:42 pm

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Mon Apr 16, 2012 9:44 pm 
Hello everybody,

I have some trouble with running SDL. I already made a working zombie game for school and i wanted to make a new game on my own. The problem is that i can't even find a way to get SDL to work.

here is my code ..

//stdafx
Code:
#pragma once

#include "targetver.h"

#include <stdio.h>
#include <tchar.h>

#include <iostream>
#include <string>

#include <Windows.h>
#include <time.h>

#include "SDL\sdl.h"


//main
Code:
// SDL_TEST.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"


#include "stdafx.h"

const int screen_w = 640;
const int screen_h = 480;
const int screen_bpp = 32;

SDL_Surface * screen = NULL;

bool init()
{
   if (SDL_INIT_EVERYTHING == -1)
      return false;

   screen = SDL_SetVideoMode(screen_w, screen_h, screen_bpp, SDL_SWSURFACE);

   if (screen = NULL)
      return false;
   
   SDL_WM_SetCaption("TEST SDL", NULL);

   return true;
}

int _tmain(int argc, _TCHAR* argv[])
{

   bool End = false;

   if (init() == true)
   {
      while (End == false)
      {
      
         End = true;

      }
   }

return 0;

}


Error:
Code:
1>------ Build started: Project: SDL_TEST, Configuration: Debug Win32 ------
1>  SDL_TEST.cpp
1>SDL_TEST.obj : error LNK2019: unresolved external symbol _SDL_WM_SetCaption referenced in function "bool __cdecl init(void)" (?init@@YA_NXZ)
1>SDL_TEST.obj : error LNK2019: unresolved external symbol _SDL_SetVideoMode referenced in function "bool __cdecl init(void)" (?init@@YA_NXZ)
1>c:\users\pogg\documents\visual studio 2010\Projects\SDL_TEST\Debug\SDL_TEST.exe : fatal error LNK1120: 2 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


Thank you!
Pierre-Olivier Girard

NOTE: I am fairly new to computer programming and my English is kinda bad.


Top
  
 
PostPosted: Tue Apr 17, 2012 5:17 am 
Harmlessness does no harm
User avatar

Joined: Tue Sep 14, 2004 8:37 pm
Posts: 3807
Location: Ferriday, LA, US
It would appear that you are not linking to the SDL library correctly... the most common cause for this particular error is that your code does not correct to the correct header file.

You'll need to set up your IDE to know where to find the SDL library, either by setting the project properties to include the path to the SDL library code (note that the "standard" for including the SDL header uses the relative path "SDL/sdl.h", so be sure that the path you set in the IDE has the SDL headers etc. in an SDL/ child directory); or, by simply copy-pasting the files into the default include/ and lib/ paths used by your IDE.

If you need any help in doing this, be sure and post back with details regarding the IDE you are using, as well as the compiler suite. Different IDEs and compilers work differently, and it's difficult to give step-by-step directions without knowing what tools you are using. :)

_________________
What most people don't understand about "enlightenment" is that it is not an end-goal; but where you find yourself just before taking a new "first step."


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 1 guest


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

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group