【发布时间】:2018-04-23 00:25:09
【问题描述】:
我一直在尝试让 SDL2 在 Ubuntu 上与 Eclipse 一起工作。
我已尝试关注this、this 和this,但我就是无法正常工作。
如何让 SDL2 与 Eclipse 一起工作并将所有内容正确链接在一起?
编辑: 当我编译程序时,它会返回说 SDL.h 丢失或没有这样的目录,即使我可以在项目列表的包含中看到 SDL。
编译时我尝试过使用:
gcc SDLTest.cpp
g++ SDLTest.cpp
gcc -o test SDLTest.cpp `sdl-config --cflags --libs`
我不确定使用 GCC 或 G++ 之间的区别,我从 here. 获得了第三个编译器
我已将 SDL 包含文件夹添加到项目中,但仍然没有任何内容
Image Project Explorer and Code
#include <SDL2/SDL.h>
#include <stdio.h>
int main(int argc, char* argv[])
{
SDL_Window *window;
SDL_Init(SDL_INIT_VIDEO);
window = SDL_CreateWindow(
"an SDL2 Window",
20,
20,
640,
480,
SDL_WINDOW_OPENGL);
if (window == NULL)
{
printf("Could not create window: %s\n", SDL_GetError());
return 1;
}
SDL_Delay(3000);
SDL_DestroyWindow(window);
SDL_Quit();
return 0;
}
`
【问题讨论】:
-
您尝试的方法是如何不起作用的? Eclipse 是否删除了您的主目录?导致内核恐慌?
-
当我编译程序时,它会返回说 SDL.h 丢失或没有这样的目录,即使我可以在项目列表的包含中看到 SDL。编译时我尝试使用:
gcc SDLTest.cpp
标签: c++ linux eclipse ubuntu sdl