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

标签 c ubuntu sdl sdl-2 codelite

我实际上还没有能够在我的笔记本电脑上使用 SDL 2.0,所以我再次重新发布整个帖子。希望其他人可以帮助我,因为我有点绝望。

“显然,我没有正确安装 SDL,因为我在一些 SDL 2.0 教程中找到的示例程序没有正确构建。

请注意,我使用 Ubuntu 12.04 作为我的操作系统,使用 SDL 2.0.3 源代码中的说明将其安装在我的操作系统上,使用 CodeLite 5.4,并使用 C 作为我的编程语言。

这是我尝试测试的代码:

#include <SDL2/SDL.h>
#include <stdio.h>

int main(int argn,char **argv)
{
    if(SDL_Init(SDL_INIT_VIDEO) != 0)
    {
        fprintf(stderr,"Could not initialize SDL: %s\n", SDL_GetError());

    }

    printf("SDL Initialized\n");
    SDL_Quit();
    printf("SDL Shutdown\n");
    return 0;
}

但是,我明白了:

/bin/sh -c 'make -j 1 -e -f  Makefile'
----------Building project:[ SDL - Debug ]----------
make[1]: Entering directory `/home/user/Documents/Programming/C/SDL'
gcc -o ./Debug/SDL @"SDL.txt" -L.
./Debug/main.o: In function `main':
/home/user/Documents/Programming/C/SDL/main.c:6: undefined reference to `SDL_Init'
/home/user/Documents/Programming/C/SDL/main.c:8: undefined reference to `SDL_GetError'
/home/user/Documents/Programming/C/SDL/main.c:13: undefined reference to `SDL_Quit'
collect2: ld returned 1 exit status
make[1]: *** [Debug/SDL] Error 1
make[1]: Leaving directory `/home/user/Documents/Programming/C/SDL'
make: *** [All] Error 2
3 errors, 0 warnings

有人可以向我解释一下问题是什么以及如何解决它吗?”

最佳答案

来自代码: 右键单击事件项目图标(在 TreeView 中)-> 设置 -> 通用设置 -> 链接器 -> 库

并添加: SDL2(无需添加 -l,或者 .a/.so codelite 会为您解决此问题)

按 F7,它应该可以正常链接

埃兰

关于c - SDL 2.0 构建错误(重复),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23377641/

相关文章:

c++ - 尝试在 Visual Studio Express 2012 for Windows Desktop 中安装 SDL_ttf

c++ - 在 g++ 编译中找不到 SDL.h

SDL -(硬件)像素缩放

无法使用 zlib 压缩数据流设置字典

ubuntu - JUnit 找不到类

c - 在函数内编写 C 套接字

Ubuntu 服务器 - HANDSHAKE_FAILURE。如何正确设置证书?

django - 为什么我的 Django 网站出现网络错误?

c++ - 您如何称呼 2 个 .c 文件之间的这种关系?

c - 如何将可变参数函数转换为宏?