我是 c++ 和 XCode 的新手,我正在使用 sdl2 创建一个窗口,但是当我编译它时,它崩溃并给我一个线程。我已经包含了 opengl.h 、 stdio.h
和 SDL2.h
。有疑问
dlyd:library not loaded but their different.
错误消息:
dyld: Library not loaded: @rpath/SDL2.framework/Versions/A/SDL2 Referenced from: /Users/shayanrazavi/Library/Developer/Xcode/DerivedData/c++_code-bbdyozxqxxdxosbxuyhcrqobxrkd/Build/Products/Debug/c++ code
Reason: image not found
这是我使用的代码,由于某种原因,我无法将 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;
}
最佳答案
我明白了为什么会发生这种情况,我打算在 XCode 中使用框架之前将其放入 /Library/Frameworks
文件夹中,因为当您下载 SDL 时,它会为您提供一个自述文件并读取我的文件说将其放入该文件夹中。
我想下次我应该尝试阅读自述文件中的所有文本。但如果我尝试在 XCode 中运行它,它会因某种原因崩溃。 (这是有道理的,因为它说dyld:库未加载,我们只是将其放入/Library/Frameworks
)
关于c++ - dyld : Library not loaded. ..未找到图像的原因?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31633468/