Sign in to follow this  
BloodLust666

including SDL into a program

Recommended Posts

BloodLust666    104
I have compiler options to check the folder "SDL/include" for the include files and "SDL/lib" for the lib files. then i explicitly include the library in the code by doing #pragma comment(lib, "sdl.lib"), but when i run the program it's saying that it's missing "sdl.dll", how do i link that or however i need to add that?

Share this post


Link to post
Share on other sites
BloodLust666    104
ah.. ok, i had to put it in the same folder. thanks, but now i'm getting an error with the Uint8 type... i guess it's not seeing it or something. is ther something wrong with it? ic an't just declare a variable with type "Uint8"?

Share this post


Link to post
Share on other sites
Frequency    442
I'd check all the spelling/caps on "Uint8", since it sucks to miss really stupid errors - but I never had a problem with that when I set up. Maybe it's a linker thing?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
It's Uint8. But incase you don't have it:

typedef unsigned char Uint8;
typedef unsigned short int Uint16;
typedef unsigned long int Uint32;
typedef unsigned long long int Uint64;



I'm not sure if the Uint64 was supported everywhere, though.

C++

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
Quote:
Original post by Frequency
I'd check all the spelling/caps on "Uint8", since it sucks to miss really stupid errors - but I never had a problem with that when I set up. Maybe it's a linker thing?


Also, try:

#pragma comment(lib, "SDLmain.lib")
#pragma comment(lib, "SDL.lib")



I think you are missing the 'main' one. It's the one that defines SDL_Main and other things, among which may be Uint8.

Share this post


Link to post
Share on other sites
Drew_Benton    1861
You will need to include "SDL.h" in that file that it's not found in. As the other AP above posted, Uint8's are just typedefs and right now, that definition is missing.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
Quote:
Original post by Drew_Benton
You will need to include "SDL.h" in that file that it's not found in. As the other AP above posted, Uint8's are just typedefs and right now, that definition is missing.


Good point.

Although, if he was missing that wouldn't he get undefined's for everything with 'SDL_'?

C++

Share this post


Link to post
Share on other sites
Drew_Benton    1861
Quote:
Original post by Anonymous Poster
Although, if he was missing that wouldn't he get undefined's for everything with 'SDL_'?


He would, except in the most common case that this is happening in another file, perhaps a header file, that does not yet use any SDL code. For example:

KeyBoardInput.h

#ifndef KB_H_
#define KB_H_

class KB_Input
{
private:
vector <Uint8*> bufferedKeyArray;
public:
KB_Input();
... member functions ...
}

#endif





KeyBoardInput.cpp

#include "KeyBoardInput.h"
#include "SDL.h"

KB_Input::KB_Input()
{
}

... rest of member implementations ...


Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
Quote:
Original post by Drew_Benton
Quote:
Original post by Anonymous Poster
Although, if he was missing that wouldn't he get undefined's for everything with 'SDL_'?


He would, except in the most common case that this is happening in another file, perhaps a header file, that does not yet use any SDL code. For example:

KeyBoardInput.h
*** Source Snippet Removed ***

KeyBoardInput.cpp
*** Source Snippet Removed ***


Ooohh.... Gotcha!

Off topic, but why did you use a vector, if SDL_GetKeyState(...) returns a snapshot of the program?

Share this post


Link to post
Share on other sites
Rob Loach    1504
Quote:
Original post by Anonymous Poster
Off topic, but why did you use a vector, if SDL_GetKeyState(...) returns a snapshot of the program?
I'm assuming he'd be using a polling system for the input so that he can buffer the input in order to be able to get more then just three key presses at a time.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this