c - 从 C 程序链接到 SDL

标签 c sdl

<分区>

我有一个非常简单的 C 程序,它是 taken from the SDL documentation :

#include <stdlib.h>
#include "SDL.h"

int main() {
    if (SDL_Init(SDL_INIT_AUDIO|SDL_INIT_VIDEO) < 0) {
        return EXIT_FAILURE;
    }
    atexit(SDL_Quit);
    return EXIT_SUCCESS;
}

我正在使用 sdl-config --cflags --libs 为 clang 提供参数。它能够链接到 SDL header ,但无法链接到 SDL 库:

/tmp/example-f2Tgg6.o: In function `main':
example.c:7: undefined reference to `SDL_Init'
example.c:8: undefined reference to `SDL_Quit'
clang: error: linker command failed with exit code 1 (use -v to see invocation)

我尝试用 gcc 编译并遇到同样的问题,所以我觉得我错过了一些明显的东西。我正在运行 xubuntu 11.10 以防万一。

最佳答案

尝试安装库。类似于 sudo apt-get install libsdl1.2-dev libsdl1.2debian

关于c - 从 C 程序链接到 SDL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15326429/

相关文章:

c - 删除单链表中两个相邻节点

c - C 中的 execvp 不通过 ar

c - 使用反射输入计算 CRC64 的最有效方法

c - 尝试编译简单的inotify程序

sdl - 编写更好的游戏循环

c - SDL 2.0 构建错误(重复)

c - 通用排序适用于整数但不适用于其他类型

SDL:在非全屏模式下查找最大窗口大小

C++整数除法

Opengl 上下文丢失