# including SDL into a program

This topic is 4461 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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 on other sites
sdl.dll needs to be in same place as your .exe or in windows\system32.

##### Share on other sites
The lib files only exists to tell the app how should it use the DLL files.

The license won't let you have the complete SDL embedded in your app.

##### Share on other sites
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 on other sites
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 on other sites
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 on other sites
Quote:
 Original post by FrequencyI'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 on other sites
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 on other sites
Quote:
 Original post by Drew_BentonYou 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 on other sites
Quote:
 Original post by Anonymous PosterAlthough, 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 on other sites
Quote:
Original post by Drew_Benton
Quote:
 Original post by Anonymous PosterAlthough, 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 on other sites
Quote:
 Original post by Anonymous PosterOff 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.