When i run code it had an error:
src/snake/Screen.hpp:7:10: fatal error: 'SDL_ttf.h' file not found
#include "SDL_ttf.h"
^~~~~~~~~~~
1 error generated.
make: *** [all] Error 1
I included sdl2 library in my project and i only have problems with sdl2_image and sdl2_ttf.
This is my makefile:
SRC_DIR = src/snake
BUILD_DIR = build/debug
CC = g++
SRC_FILES = $(wildcard $(SRC_DIR)/*.cpp)
OBJ_NAME = play
INCLUDE_PATHS = -Iinclude
LIBRARY_PATHS = -Llib
COMPILER_FLAGS = -std=c++11 -Wall -O0 -g
LINKER_FLAGS = -lsdl2 -lsdl2_image -lsdl2_ttf
all:
$(CC) $(COMPILER_FLAGS) $(LINKER_FLAGS) $(INCLUDE_PATHS) $(LIBRARY_PATHS) $(SRC_FILES) -o $(BUILD_DIR)/$(OBJ_NAME)
Use <SDL_ttf.h>
if you have installed the library on your machine, see What is the difference between #include < > and #include " "?
Another case is that you mistyped (lowercased) all the libraries name on LINKER_FLAGS
, thus the compiler did not found any of the library you were specifying, try LINKER_FLAGS = -lSDL2 -lSDL2_image -lSDL2_ttf
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.