我看了几个可能的解决方案,试图修复这个问题,但在使用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)
非常感谢提前提供的任何帮助。
libSDL2_ttf.so
或libSDL2_ttf.a
。可能你没有安装该库的开发包(但是你怎么有头文件呢?),已经损坏了,或者是错误的架构。另外,使用编译器标志-w
是最糟糕的想法,虽然与问题无关。 - keltar