I use CodeBlocks IDE with the default MinGW compiler. I am going to use SDL for programming practice and probably some small projects. My question is should I link to SDL globally or for each individual CodeBlocks project? And why?
I tried That but it kept saying that the directory "seems" right but it couldn't locate SDL.h, any idea why?
EDIT: Also I would still like to know the pros and cons of linking globally or individually for each project (if it makes any real difference). I think I read somewhere that it was bad to link globally but I am not sure why
As far as compiling and linking goes, it makes no difference.
It is an extra dependency on projects that don't actually use SDL, but I think the linker is smart enough not to put it in the executable's dependencies if it is not used. But even if that is so, it is extra work that doesn't need to be done if the project doesn't need it.
I'd have to fire up C::B to figure out how to do it. Perhaps someone else here will answer the question, or you can ask over at http://forums.codeblocks.org/
A library like SDL produces two kinds of dependencies in your program.
One is on the source code. You have to #include all the required headers so that the compiler knows everything it needs to call the functions in the SDL library.
The other is on the resulting executable. When the executable is loaded by the OS, it discovers that it needs specific DLLs that provide the functions your code uses. It finds the .dll (or .so, if you are on *nix) and hooks everything up so that it works together.
If the first is missing, your program won't compile.
If the second is missing, your program won't execute.
At this point, I'm not sure I understood your original question. What exactly are you trying to do?
#include is used for loading the declarations in other source files. However, the program needs to know that the functions are actually created somewhere. This is why you need to link to an 'import library'. It tells the program that the DLL it is associated with contains a set of functions, which are exported and can be accessed from your program. This means that the program can then load the DLL at runtime and use those functions that it finds within the DLL.
Basically, to set up SDL, you need to use your IDE to link to the libraries associated with the DLL's that you will use. Depending on your compiler, the libraries are normally called ".lib" or ".a".