Have been racking my brain over the last week trying to get this to work. I am a noob so forgive any obvious things I missed.
First, I am using Ubuntu 12.04 LTS and couldn’t find any packages I could install, so I downloaded the source and compiled the SDL2 library. When I check, it looks like the headers have been installed in the /usr/local/include directory and the .so files were installed in /usr/local/lib.
I am using Code::Blocks and added the following to the Project Build options:
Search Directories --> Compiler: /usr/local/include
Search Directories --> Linker: /usr/local/lib
Search Directories --> Resource Compiler: /usr/local/include and /usr/local/lib
Linker Settings --> Other linker options: -SDL2main -lSDL2
In my source code I have the following include statement:
#include <SDL2/SDL.h>
I’m pretty sure I’m at least pointing to the right place because if I change it, it gives me a “No such file or directory” error instead.
When it comes time to compile, it hits the first line I declare an SDL_Texture object, raising an error that “SDL_Texture does not name a type”.
My understanding is that this error usually means that the referenced object is not defined elsewhere. I just migrated from using SDL 1.2 and switched all my SDL_Surfaces to SDL_Textures, but I thought that by including the SDL.h file, it included all the object definitions, so I’m at a loss.
Here is the excerpt from my header file raising the error: “SDL_Texture does not name a type”
#ifndef CSURFACE_H
#define CSURFACE_H
#include <SDL/SDL.h>
class CSurface {
public:
CSurface();
int X;
int Y;
public:
//static SDL_Surface* OnLoad(char* File);
static SDL_Texture* OnLoad(char* file); <------------- Error is here
and here are the file listings where my compiled SDL2 files are.
/usr/local/include/SDL2:
SDL.h
SDL_assert.h
SDL_atomic.h
SDL_audio.h
SDL_bits.h
SDL_blendmode.h
SDL_clipboard.h
SDL_config.h
SDL_cpuinfo.h
SDL_endian.h
SDL_error.h
SDL_events.h
SDL_filesystem.h
SDL_gamecontroller.h
SDL_gesture.h
SDL_haptic.h
SDL_hints.h
SDL_joystick.h
SDL_keyboard.h
SDL_keycode.h
SDL_loadso.h
SDL_log.h
SDL_main.h
SDL_messagebox.h
SDL_mouse.h
SDL_mutex.h
SDL_name.h
SDL_opengl.h
SDL_opengles.h
SDL_opengles2.h
SDL_pixels.h
SDL_platform.h
SDL_power.h
SDL_quit.h
SDL_rect.h
SDL_render.h
SDL_revision.h
SDL_rwops.h
SDL_scancode.h
SDL_shape.h
SDL_stdinc.h
SDL_surface.h
SDL_system.h
SDL_syswm.h
SDL_test.h
SDL_test_assert.h
SDL_test_common.h
SDL_test_compare.h
SDL_test_crc32.h
SDL_test_font.h
SDL_test_fuzzer.h
SDL_test_harness.h
SDL_test_images.h
SDL_test_log.h
SDL_test_md5.h
SDL_test_random.h
SDL_thread.h
SDL_timer.h
SDL_touch.h
SDL_types.h
SDL_version.h
SDL_video.h
begin_code.h
close_code.h
/usr/local/lib:
libSDL2-2.0.so.0
libSDL2-2.0.so.0.2.1
libSDL2.a
libSDL2.la
libSDL2.so
libSDL2_test.a
libSDL2main.a
ocaml
pkgconfig
python2.7
site_ruby
Not sure if it didn’t compile correctly, not sure if I have to manually include all the related SDL headers (I didn’t have to do that on SDL 1.2), not sure if I’m missing something in my linker instructions.
Help!