c++ - Ubuntu :/usr/bin/ld: cannot find -lSDL2_ttf 上的 SDL2_TTF

标签 c++ sdl-2 sdl-ttf

我已经研究了几种可能的解决方案来尝试解决此问题,但在使用 SDL_ttf 和 SDL2 绘制文本时我仍然遇到以下问题。

julian@julian-linux:~/Documents/SDL/Font Demo/pt2$ make
g++ texttest.cpp -w -lSDL2 -lSDL2_ttf -LSDL2_image  -o texttest
/usr/bin/ld: cannot find -lSDL2_ttf
collect2: error: ld returned 1 exit status
Makefile:23: recipe for target 'all' failed
make: *** [all] Error 1

我的Makefile如下:

OBJS = texttest.cpp

#CC specifies which compiler we're using
CC = g++

#COMPILER_FLAGS specifies the additional compilation options we're using
# -w suppresses all warnings
COMPILER_FLAGS = -w

#LINKER_FLAGS specifies the libraries we're linking against
LINKER_FLAGS = -lSDL2 -lSDL2_ttf -LSDL2_image 

#OBJ_NAME specifies the name of our exectuable
OBJ_NAME = texttest

#This is the target that compiles our executable
all : $(OBJS)
    $(CC) $(OBJS) $(COMPILER_FLAGS) $(LINKER_FLAGS) -o $(OBJ_NAME)

在此先感谢您的帮助。

最佳答案

我通过运行解决了这个问题

sudo apt-get install libsdl2-ttf-dev

我以前尝试修复它的地方

sudo apt-get install libsdl-ttf2.0-dev

关于c++ - Ubuntu :/usr/bin/ld: cannot find -lSDL2_ttf 上的 SDL2_TTF,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40368368/

相关文章:

c++ - SDL2 C++ - multimap 像渲染错误

c++ - 如何将(阿拉伯语)字形与 SDL-TTF v2.20 结合起来?

opengl - 当今 OpenGL 中 NPOT 纹理的状态

c++ - QNX Momentics : GoogleMock - Return has value, 函数返回无效错误

c++ - 从源 SDL_Texture 中提取 SDL_Texture

makefile - SDL2 库在 Make 中找不到,但在 CMake 中找到

c++ - Make_Pair 标识符在一个函数中未找到但在另一个函数中找到

c++ - 类模板实例化 : any way round this circular reference?

c++ - 禁用 move 构造函数

c++ - Qt:拖动时更改鼠标光标