【问题标题】:Error: Couldn't open stream with SDL 1.3错误:无法使用 SDL 1.3 打开流
【发布时间】:2011-08-20 00:15:34
【问题描述】:

我尝试在 Ubuntu Linux 上使用 SDL 1.3 库运行以下代码。 我收到以下错误:

错误:无法打开流 错误:无法打开流

SDL_Init 和 SDL_CreateWindow

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


int main(int argc, char** argv) {

    if((SDL_Init(SDL_INIT_VIDEO) != 0))
    {
        printf("[!] can't initialize SDL %s\n", SDL_GetError());
        exit(-1);
    }


//    if((SDL_VideoInit(NULL) != 0))
//    {
//        printf("[!] can't initialize video %s\n", SDL_GetError());
//        exit(-1);
//    }

    SDL_Window* win;

    if(!(win = SDL_CreateWindow("SDL 1.3", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 640, 480, SDL_WINDOW_SHOWN)))
    {
        printf("[!] can't create Window %s", SDL_GetError());
        exit(-1);
    }

    SDL_DestroyWindow(win);
    SDL_Quit();
    return 0;
}

【问题讨论】:

  • 这是一个评论,而不是一个答案。现在你已经标记了你的问题 C,你的代码应该是 C。但我不知道 C 中有任何 cstdlib 标头。另外,如果我是你,我会避免讽刺,寻求免费帮助。跨度>

标签: c linux sdl


【解决方案1】:

在我的 Ubuntu 机器上编译你的代码没有问题:

gcc init.c -o init `pkg-config --cflags --libs sdl`

ldd 的输出显示正在链接的应用程序:

libSDL-1.3.so.0 => /usr/local/lib/libSDL-1.3.so.0 (0x00a94000)

当应用程序被执行时,Initializing touch... 被打印到控制台。顺便说一句,我从源代码下载并编译了 SDL。

【讨论】:

    猜你喜欢
    • 2016-05-06
    • 1970-01-01
    • 2013-06-12
    • 2015-11-04
    • 1970-01-01
    • 2013-09-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多