Ubuntu的SDL2_TTF: /usr/bin/ld:找不到-lSDL2_ttf

SDL2_TTF on Ubuntu: /usr/bin/ld: cannot find -lSDL2_ttf

本文关键字:找不到 ld -lSDL2 ttf bin Ubuntu SDL2 TTF usr      更新时间:2023-10-16

我已经看过几个可能的解决方案,试图解决这个问题,但我仍然有以下问题与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