I’m using Linux. I wrote a program that uses SDL_image and SDL_ttf
libraries. At this point I am trying to compile a source file - I’m not
linking yet, just compile. Here is my Makefile. It’s not complete yet:
CC=g++
CFLAGS=-O2 -W -Wall -pedantic
LIBS=-lSDL -lpthread
all: character.o ally.o enemy.o party.o allyparty.o enemyparty.o draw.o
character.o: character.cpp
$(CC) $(CFLAGS) -c character.cpp
ally.o: ally.cpp
$(CC) $(CFLAGS) -c ally.cpp character.o
enemy.o: enemy.cpp
$(CC) $(CFLAGS) -c enemy.cpp character.o
party.o: character.o party.cpp
$(CC) $(CFLAGS) -c party.cpp character.o
allyparty.o: party.o ally.o allyparty.cpp
$(CC) $(CFLAGS) -c allyparty.cpp party.o ally.o
enemyparty.o: party.o enemy.o enemyparty.cpp
$(CC) $(CFLAGS) -c enemyparty.cpp party.o enemy.o
draw.o: draw.cpp allyparty.o enemyparty.o
$(CC) $(CFLAGS) -c draw.cpp enemyparty.o allyparty.o
clean:
rm *.o
rm *~
All targets compile fine, except draw.o. That gives me errors:
michael at camille OurRPG $ make
g++ -O2 -W -Wall -pedantic -c draw.cpp enemyparty.o allyparty.o
In file included from draw.cpp:1:
draw.h:4:23: error: sdl_image.h: No such file or directory
draw.h:5:21: error: sdl_ttf.h: No such file or directory
/usr/lib/gcc/i686-pc-linux-gnu/4.1.2/include/g+±v4/memory: In function
’std::pair<_Tp*, int> std::__get_temporary_buffer(ptrdiff_t, _Tp*)’:
/usr/lib/gcc/i686-pc-linux-gnu/4.1.2/include/g+±v4/memory:83: error:
‘nothrow’ was not declared in this scope
/usr/lib/gcc/i686-pc-linux-gnu/4.1.2/include/g+±v4/memory: In function
’void std::return_temporary_buffer(_Tp*)’:
/usr/lib/gcc/i686-pc-linux-gnu/4.1.2/include/g+±v4/memory:123: error:
‘nothrow’ was not declared in this scope
party.h: At global scope:
party.h:7: warning: ‘class Party’ has virtual functions but non-virtual
destructor
allyparty.h:9: warning: ‘class AllyParty’ has virtual functions but
non-virtual destructor
enemyparty.h:8: warning: ‘class EnemyParty’ has virtual functions but
non-virtual destructor
draw.h:29: error: ISO C++ forbids declaration of ‘TTF_Font’ with no type
draw.h:29: error: expected ‘;’ before ‘*’ token
draw.cpp: In member function ‘void Draw::Init()’:
draw.cpp:28: error: ‘TTF_Init’ was not declared in this scope
draw.cpp:34: error: ‘font’ was not declared in this scope
draw.cpp:34: error: ‘TTF_OpenFont’ was not declared in this scope
draw.cpp:36: warning: missing initializer for member 'SDL_Color::unused’
draw.cpp:37: warning: missing initializer for member 'SDL_Color::unused’
draw.cpp:44: error: ‘sprintf_s’ was not declared in this scope
draw.cpp:46: error: ‘TTF_RenderText_Shaded’ was not declared in this
scope
draw.cpp: In member function ‘void Draw::draw(int)’:
draw.cpp:102: error: ‘IMG_Load’ was not declared in this scope
draw.cpp: At global scope:
draw.cpp:84: warning: unused parameter 'state’
make: *** [draw.o] Error 1
Here are the #include lines from draw.h:
#include <SDL/SDL.h>
#include <sdl_image.h>
#include <sdl_ttf.h>
I ran configure, make, and make install on the SDL_image and SDL_ttf
packages, so they’re in /usr/local/lib and /usr/local/include. What do
I need to set to get this thing to compile?