Sign in to follow this  
murdock

Using SFont with SDL

Recommended Posts

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...

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites
I have not used that library, so I'm not sure. Someone that has will have to reply... Looking at the screenshots on the front page makes it appear so. Try looking at the 3 sample programs included to see if you can find the answer as well.

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