dyld:库未加载...找不到原因图像?

dyld: Library not loaded...reason image not found?

我是 c++ 和 XCode 的新手,我正在使用 sdl2 创建一个 window 但是当我编译它时,它崩溃了,给我一个 thread.I 包括 opengl.hstdio.hSDL2.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;
}

我明白了为什么会发生这种情况 我打算先将框架放在 /Library/Frameworks 文件夹中,然后再在 XCode 中使用它,因为当您下载 SDL 时,它会为您提供自述文件和阅读我的文件说要把它放在那个文件夹里。

我想下次我应该尝试阅读自述文件中的所有文本。但是如果我在 XCode 中尝试 运行 这个,它会因为某种原因崩溃。 (有道理,因为它说 dyld: Library not loaded and we just put it in /Library/Frameworks