SDL_TTF : 对 "TTF_INIT" 的未定义引用
SDL_TTF : undefined reference to "TTF_INIT"
我正在尝试学习如何使用 SDL_TTF 库。但我无法解决类型错误:
对 "TTF_INIT"
的未定义引用
这是我尝试编译和使用的简单代码:
#include <stdlib.h>
#include <stdio.h>
#include <SDL2/SDL.h>
#include <SDL2/SDL_ttf.h>
int main(int argc, char *argv[]){
TTF_INIT();
TTF_Quit();
return EXIT_SUCCESS;
}
这是我的 makefile 的 CFLAGS:
CFLAGS= `sdl2-config --cflags --libs`-lSDL2_ttf
预先感谢您的回答。
PS:我使用 sudo apt
安装 SDL2 和 SDL2_TTF
首先,您在 CFLAGS
中的最后一个反引号后缺少 space。即便如此,它看起来应该更像:
CFLAGS=`sdl2-config --cflags`
LFLAGS=`sdl2-config --libs` -lSDL2_ttf
此外,TTF_Init()
(注意不是全部大写)必须在SDL_Init()
之后。
在 http://lazyfoo.net/tutorials/SDL/16_true_type_fonts/index.php . You may want to start at the beginning, though (http://lazyfoo.net/tutorials/SDL/index.php 查看 LazyFoo 的所有相关教程。
编辑:我想我会从评论中提到虽然反引号有效,但写 $(shell sdl2-config --cflags)
更常见
你可能已经解决了它,但我进入了这个页面,不,TTF_Init() 不需要像@contrapants 所建议的那样在 SDL_Init 之后出现,正如我们在manual.
的第 2.2 章
所以您的代码的问题实际上是在大写中编写 TTF_Init() 并且缺少 ` 和 - 之间的 space。
我正在尝试学习如何使用 SDL_TTF 库。但我无法解决类型错误: 对 "TTF_INIT"
的未定义引用这是我尝试编译和使用的简单代码:
#include <stdlib.h>
#include <stdio.h>
#include <SDL2/SDL.h>
#include <SDL2/SDL_ttf.h>
int main(int argc, char *argv[]){
TTF_INIT();
TTF_Quit();
return EXIT_SUCCESS;
}
这是我的 makefile 的 CFLAGS:
CFLAGS= `sdl2-config --cflags --libs`-lSDL2_ttf
预先感谢您的回答。
PS:我使用 sudo apt
安装 SDL2 和 SDL2_TTF
首先,您在 CFLAGS
中的最后一个反引号后缺少 space。即便如此,它看起来应该更像:
CFLAGS=`sdl2-config --cflags`
LFLAGS=`sdl2-config --libs` -lSDL2_ttf
此外,TTF_Init()
(注意不是全部大写)必须在SDL_Init()
之后。
在 http://lazyfoo.net/tutorials/SDL/16_true_type_fonts/index.php . You may want to start at the beginning, though (http://lazyfoo.net/tutorials/SDL/index.php 查看 LazyFoo 的所有相关教程。
编辑:我想我会从评论中提到虽然反引号有效,但写 $(shell sdl2-config --cflags)
你可能已经解决了它,但我进入了这个页面,不,TTF_Init() 不需要像@contrapants 所建议的那样在 SDL_Init 之后出现,正如我们在manual.
的第 2.2 章所以您的代码的问题实际上是在大写中编写 TTF_Init() 并且缺少 ` 和 - 之间的 space。