Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 SDL_image and SDL_LoadPNG (compile error)
Index -> Programming, C++ -> C++ Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
HyperFlexed




PostPosted: Fri Jun 18, 2010 6:05 pm   Post subject: SDL_image and SDL_LoadPNG (compile error)

I had libsdl-dev and libsdl-image-dev installed (through apt-get). I was getting odd errors on compile:

code:
johnny@picard:~/coding/SDLtest$ g++ main.cpp -o main -lSDL -lSDL_image
main.cpp: In function ?int main(int, char**)?:
main.cpp:15: error: ?SDL_LoadPNG? was not declared in this scope


Because of this, I tried installing libsdl and libsdl_image from source. They compiled fine. The packages are sitting happily under /usr/local/lib

code:
johnny@picard:~/coding/SDLtest$ ls /usr/local/lib -l
total 7700
lrwxrwxrwx 1 root root       20 2010-06-18 18:56 libSDL-1.2.so.0 -> libSDL-1.2.so.0.11.3
-rwxr-xr-x 1 root root  2353825 2010-06-18 18:56 libSDL-1.2.so.0.11.3
-rw-r--r-- 1 root root  4940280 2010-06-18 18:56 libSDL.a
lrwxrwxrwx 1 root root       25 2010-06-18 18:50 libSDL_image-1.2.so.0 -> libSDL_image-1.2.so.0.8.2
-rwxr-xr-x 1 root root   199342 2010-06-18 18:50 libSDL_image-1.2.so.0.8.2
-rw-r--r-- 1 root root   356982 2010-06-18 18:50 libSDL_image.a
-rwxr-xr-x 1 root root      985 2010-06-18 18:50 libSDL_image.la
lrwxrwxrwx 1 root root       25 2010-06-18 18:50 libSDL_image.so -> libSDL_image-1.2.so.0.8.2
-rwxr-xr-x 1 root root      986 2010-06-18 18:56 libSDL.la
-rw-r--r-- 1 root root     4674 2010-06-18 18:56 libSDLmain.a
lrwxrwxrwx 1 root root       20 2010-06-18 18:56 libSDL.so -> libSDL-1.2.so.0.11.3
drwxr-xr-x 2 root root     4096 2010-06-18 18:56 pkgconfig
drwxrwsr-x 4 root staff    4096 2010-05-13 02:10 python2.6


I can't see where I'm going wrong in the source code:

code:
#include "SDL/SDL.h"
#include "SDL/SDL_image.h"

int main(int argc, char *args[]){
        SDL_Surface *screen = NULL;
        SDL_Surface *hello = NULL;
       
        // Initialize SDL
        SDL_Init(SDL_INIT_EVERYTHING);
       
        // Set up screen
        screen = SDL_SetVideoMode(640, 480, 32, SDL_SWSURFACE);
       
        // Load Image
        hello = SDL_LoadPNG("test.png");
       
        // Display image
        SDL_BlitSurface(hello, NULL, screen, NULL);
        SDL_Flip(screen);
       
        SDL_Delay(2000);
       
        // Quit SDL
        SDL_Quit();
       
        return 0;
}


and as far as I can tell libpng and zlib are installed. It seems like the compiler can't find SDL_LoadPNG, but as I understand this should be included with SDL_image. If anyone can recommend further troubleshooting steps or offer some advice, I'd be glad to hear it. This has to be the most complicated hello world I've ever done Razz
Sponsor
Sponsor
Sponsor
sponsor
CodeMonkey2000




PostPosted: Fri Jun 18, 2010 6:17 pm   Post subject: RE:SDL_image and SDL_LoadPNG (compile error)

That's telling you that SDL_LoadPNG is not part of the library. What you want is IMG_load, read the SDL_image documentation

http://jcatki.no-ip.org:8080/SDL_image/SDL_image_frame.html
HyperFlexed




PostPosted: Fri Jun 18, 2010 6:22 pm   Post subject: Re: SDL_image and SDL_LoadPNG (compile error)

My hero! Thanks a tonne. I saw references on forums to some mysterious SDL_LoadPNG function, I guess I'll be sure to check the API next time. Smile
Display posts from previous:   
   Index -> Programming, C++ -> C++ Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: