SDL 2.0构建错误(重复)

时间:2014-04-30 00:29:09

标签: c ubuntu sdl sdl-2 codelite

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

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

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

以下是我尝试测试的代码:

#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

有人可以向我解释问题是什么以及我如何解决它?&#34;

1 个答案:

答案 0 :(得分:0)

来自codelite: 右键单击活动项目图标(在树状视图中) - &gt;设置 - &gt;常用设置 - &gt;链接器 - &gt;库

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

点击F7,它应该链接正常

叶兰