Using SFont with SDL

Started by
10 comments, last by Drew_Benton 18 years, 10 months ago
error C3861: 'IMG_Load': identifier not found, even with argument-dependent lookup I'm getting the above error when I try to use the SFont library to load fonts. Anyone got any suggestions?


#include <stdio.h>
#include <stdlib.h>
#include "SFont.h"
#include "SDL.h"
#include "SDL_timer.h"


SFont_Font* Font;

Font = SFont_InitFont(IMG_Load("24P_Copperplate_Blue.png"));


If I try to add SDL_Image.h to the includes VS.NET complains...
Advertisement
Do you actually have SDL_image installed?
Chess is played by three people. Two people play the game; the third provides moral support for the pawns. The object of the game is to kill your opponent by flinging captured pieces at his head. Since the only piece that can be killed is a pawn, the two armies agree to meet in a pawn-infested area (or even a pawn shop) and kill as many pawns as possible in the crossfire. If the game goes on for an hour, one player may legally attempt to gouge out the other player's eyes with his King.
no, is there documentation for setting it up under VS.NET? All I can find are setups for Linux/Unix.
You use it the same way you did with SDL. Actually all you have to do is copy the SDL_Image.lib to where your SDL.lib and SDLmain.lib are, copy the SDL_Image.h file to where your SDL.h file is, and finally copy all the .dlls to either your system32 folder or the current project's directory. When all that is done, all you need to do is #include "SDL_Image.h" and you are all set!
So I can put the SDL DLL files under system32 as well?
Now I'm getting unresolved externals
Quote:Original post by murdock
Now I'm getting unresolved externals


Did you link in SDL_Image.lib as you did with SDL.lib and SDLmain.lib?
the SDL_Image.lib is in the same directory as the SDL.lib
SDL_image.h is in the same file as the other SDL_???.h files..
ok if I go to project->properties then the linker tab and command line

If I add the sdl_image.lib to the additional options everything works

Is there a way to make this change more permanent so I don't have to add this for every new project?
Quote:Original post by murdock
Is there a way to make this change more permanent so I don't have to add this for every new project?


Not really. Setting the project settings is a once per project thing. I mean you could probabally override the default program template or make your own so it is auto-linked, but that might be too much trouble.

Alternatively, you can simply link in Microsoft based compiler with the line:
#pragma comment ( lib, "SDL_Image.lib" )

So what you can do is open up your SDL.h header file and add this to the top:
#pragma comment ( lib, "SDLmain.lib" )
#pragma comment ( lib, "SDL.lib" )

In the SDL_Image.h file:
#pragma comment ( lib, "SDL_Image.lib" )

That way, those libraries are auto linked whenever you use the header files [wink] I've used methods such as those before in frameworks to "make life easier"™ Have fun!

This topic is closed to new replies.

Advertisement