【发布时间】:2015-07-26 03:54:31
【问题描述】:
我是 C++ 和 XCode 的新手,我正在使用 sdl2 创建一个窗口,但是当我编译它时,它会崩溃给我一个线程。我已经包含了 opengl.h 、 stdio.h 和 SDL2.h .有关于
dlyd:library 未加载,但它们不同。
错误信息:
dyld:库未加载:@rpath/SDL2.framework/Versions/A/SDL2 引用自: /Users/shayanrazavi/Library/Developer/Xcode/DerivedData/c++_code-bbdyozxqxxdxosbxuyhcrqobxrkd/Build/Products/Debug/c++ 代码
原因:图片未找到
这是我使用的代码,由于某种原因,我无法将 int main 放入代码块中,但无论如何,我从 https://wiki.libsdl.org/SDL_CreateWindow 获得了此代码。
int main(int argc, char* argv[]) {
SDL_Window *window; // Declare a pointer
SDL_Init(SDL_INIT_VIDEO); // Initialize SDL2
// Create an application window with the following settings:
window = SDL_CreateWindow(
"An SDL2 window", // window title
SDL_WINDOWPOS_UNDEFINED, // initial x position
SDL_WINDOWPOS_UNDEFINED, // initial y position
640, // width, in pixels
480, // height, in pixels
SDL_WINDOW_OPENGL // flags - see below
);
// Check that the window was successfully made
if (window == NULL) {
// In the event that the window could not be made...
printf("Could not create window: %s\n", SDL_GetError());
return 1;
}
// The window is open: enter program loop (see SDL_PollEvent)
SDL_Delay(3000); // Pause execution for 3000 milliseconds, for example
// Close and destroy the window
SDL_DestroyWindow(window);
// Clean up
SDL_Quit();
return 0;
}
【问题讨论】:
标签: c++ osx-mavericks sdl-2 xcode-6.2