没有加载库,原因是没有找到图像

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

本文关键字:图像 加载      更新时间:2023-10-16

我是c++和XCode的新手,我使用sdl2来创建一个窗口,但当我编译它时,它会崩溃,给我一个线程。我已经包括了opengl.h, stdio.hSDL2.h。有关于

的问题

dlyd:库未加载,但它们不同。

错误信息:

dyld: Library not loaded: @rpath/SDL2.framework/Versions/A/SDL2/用户/shayanrazavi/图书馆/开发/Xcode/DerivedData/c++ _code-bbdyozxqxxdxosbxuyhcrqobxrkd/构建/产品/调试/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: %sn", 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时,它会给你一个read me文件,read me文件说要把它放在那个文件夹中。

我想下次我应该试着阅读我文件中的所有文本。但如果我尝试在XCode中运行它会因为某些原因崩溃。(有意义,因为它说dyld: Library not loaded and we just put it in /Library/Frameworks)