c++ - dyld : Library not loaded. ..未找到图像的原因?

标签 c++ osx-mavericks sdl-2 xcode-6.2

我是 c++ 和 XCode 的新手,我正在使用 sdl2 创建一个窗口,但是当我编译它时,它崩溃并给我一个线程。我已经包含了 opengl.h 、 stdio.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;
}

最佳答案

我明白了为什么会发生这种情况,我打算在 XCode 中使用框架之前将其放入 /Library/Frameworks 文件夹中,因为当您下载 SDL 时,它会为您提供一个自述文件并读取我的文件说将其放入该文件夹中。

我想下次我应该尝试阅读自述文件中的所有文本。但如果我尝试在 XCode 中运行它,它会因某种原因崩溃。 (这是有道理的,因为它说dyld:库未加载,我们只是将其放入/Library/Frameworks)

关于c++ - dyld : Library not loaded. ..未找到图像的原因?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31633468/

相关文章:

SDL_PollEvent 与 SDL_WaitEvent

c++ - 使用 C++11 随机库生成随机数

c++ - C++ (03) SFINAE 方面编译器是否独立?

c++ - cmake:如何告诉库在哪里可以找到依赖项

c++ - union 和 struct 的字节大小

python - pip 在虚拟环境中执行错误的 python 库版本

cocoa - 如何处理这个长错误 : This application is trying to draw a very large combo box

macos - .bashrc 文件意外结束

c++ - 为什么转换 SDL Surface 在 Surface 从文件加载时有效,但在 SDL Surface 从字体文件生成时无效