SDL 2.0 Build Error

旧街凉风 提交于 2019-12-13 04:39:37

问题


Apparently, I don't have SDL installed correctly since a sample program I found in some of the tutorials for SDL 2.0 don't buid correctly.

Mind you, I am using Ubuntu 12.04 as my operating system, used the instructions in the source code of SDL 2.0.3 to install it on my OS, am using CodeLite 5.4, and am using C as my programming language.

Here is the code I try to test:

#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;
}

However, I get this:

/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

Can someone please explain to me what the issue is and how I can fix it?

来源:https://stackoverflow.com/questions/23172804/sdl-2-0-build-error

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!