【问题标题】:Cannot link to SDL2 libs while compiling编译时无法链接到 SDL2 库
【发布时间】:2020-04-22 16:11:13
【问题描述】:

我正在尝试编译需要 SDL2 的应用程序。我的系统上已经安装了所有依赖项(基于 Arch 的 Linux 发行版)。 但由于某种原因,链接器无法找到所需的 SDL2 库。

我试试:

制作参数

成功构建了几个东西,然后:

Linking...
/usr/bin/ld: cannot find -lSDL2
/usr/bin/ld: cannot find -lunwind-generic
/usr/bin/ld: cannot find -lunwind
/usr/bin/ld: cannot find -lglib-2.0
/usr/bin/ld: cannot find -lgobject-2.0
/usr/bin/ld: cannot find -lgio-2.0
/usr/bin/ld: cannot find -libus-1.0
/usr/bin/ld: cannot find -ldbus-1
/usr/bin/ld: cannot find -lSDL2
collect2: error: ld returned 1 exit status
make: *** [Makefile:169: build/release] Error 1

据此

ldconfig -p | grep SDL

我的系统有:

    libSDL2pp.so.8 (libc6,x86-64) => /usr/lib/libSDL2pp.so.8
    libSDL2pp.so (libc6,x86-64) => /usr/lib/libSDL2pp.so
    libSDL2_ttf-2.0.so.0 (libc6,x86-64) => /usr/lib/libSDL2_ttf-2.0.so.0
    libSDL2_ttf-2.0.so.0 (libc6) => /usr/lib32/libSDL2_ttf-2.0.so.0
    libSDL2_mixer-2.0.so.0 (libc6,x86-64) => /usr/lib/libSDL2_mixer-2.0.so.0
    libSDL2_mixer-2.0.so.0 (libc6) => /usr/lib32/libSDL2_mixer-2.0.so.0
    libSDL2_image-2.0.so.0 (libc6,x86-64) => /usr/lib/libSDL2_image-2.0.so.0
    libSDL2_image-2.0.so.0 (libc6) => /usr/lib32/libSDL2_image-2.0.so.0
    libSDL2-2.0.so.0 (libc6,x86-64) => /usr/lib/libSDL2-2.0.so.0
    libSDL2-2.0.so.0 (libc6) => /usr/lib32/libSDL2-2.0.so.0
    libSDL2-2.0.so (libc6,x86-64) => /usr/lib/libSDL2-2.0.so
    libSDL2-2.0.so (libc6) => /usr/lib32/libSDL2-2.0.so
    libSDL_ttf-2.0.so.0 (libc6,x86-64) => /usr/lib/libSDL_ttf-2.0.so.0
    libSDL_ttf-2.0.so.0 (libc6) => /usr/lib32/libSDL_ttf-2.0.so.0
    libSDL_sound-1.0.so.1 (libc6,x86-64) => /usr/lib/libSDL_sound-1.0.so.1
    libSDL_net-1.2.so.0 (libc6,x86-64) => /usr/lib/libSDL_net-1.2.so.0
    libSDL_mixer-1.2.so.0 (libc6,x86-64) => /usr/lib/libSDL_mixer-1.2.so.0
    libSDL_mixer-1.2.so.0 (libc6) => /usr/lib32/libSDL_mixer-1.2.so.0
    libSDL_image-1.2.so.0 (libc6,x86-64) => /usr/lib/libSDL_image-1.2.so.0
    libSDL_image-1.2.so.0 (libc6) => /usr/lib32/libSDL_image-1.2.so.0
    libSDL-1.2.so.0 (libc6,x86-64) => /usr/lib/libSDL-1.2.so.0
    libSDL-1.2.so.0 (libc6) => /usr/lib32/libSDL-1.2.so.0

可能是什么问题?

【问题讨论】:

  • 你能用 SDL2 编译/链接最小的程序吗(比如只有 SDL_Init)?如果没有,请在测试程序、构建命令及其完整输出中进行编辑。

标签: linux build compilation sdl lib


【解决方案1】:

您似乎在 arch linux 软件包的列表中遗漏了一些 files。最重要的是 libSDL2.so。如果可能,可能需要重试安装并使用包管理器。

【讨论】:

  • 我已经安装了 sdl2 包,看来我确实有这个文件。 ls /usr/lib/ | grep libSDL2.so 回复我libSDL2.so
猜你喜欢
  • 1970-01-01
  • 2019-10-15
  • 2015-03-17
  • 1970-01-01
  • 2020-02-09
  • 1970-01-01
  • 1970-01-01
  • 2013-07-30
  • 1970-01-01
相关资源
最近更新 更多