简体   繁体   English

dyld 没有加载 Ogre 库

[英]dyld not loading Ogre library

I am trying to setup an environment to develop an Ogre3D application.我正在尝试设置一个环境来开发 Ogre3D 应用程序。 I have manually compiled Ogre into folder /opt/Ogre3D/ogre-1.11.5/build and created a CMake project in CLion with this content:我已经手动将 Ogre 编译到文件夹/opt/Ogre3D/ogre-1.11.5/build并在/opt/Ogre3D/ogre-1.11.5/build创建了一个包含以下内容的 CMake 项目:

cmake_minimum_required(VERSION 3.13)
project(sample)

set(CMAKE_CXX_STANDARD 14)
set(OGRE_DIR /opt/Ogre3D/ogre-1.11.5/build/sdk/cmake)

# specify which version and components you need
find_package(OGRE 1.11 REQUIRED COMPONENTS Bites RTShaderSystem)

# copy resource.cfg next to our binaries where OGRE looks for it
file(COPY ${OGRE_CONFIG_DIR}/resources.cfg DESTINATION ${CMAKE_BINARY_DIR})

add_executable(sample main.cpp)
target_link_libraries(sample ${OGRE_LIBRARIES})

when I try to run it, compilation is OK but then it can't execute it:当我尝试运行它时,编译可以,但无法执行:

/Users/diego/CLionProjects/ogre/sample/cmake-build-debug/sample
dyld: Library not loaded: @executable_path/../Frameworks/OgreBites.framework/Versions/1.11.5/OgreBites
  Referenced from: /Users/diego/CLionProjects/ogre/sample/cmake-build-debug/sample
  Reason: image not found

Process finished with exit code 6

I have looked at otool -l /opt/Ogre3D/ogre-1.11.5/build/lib/macosx/OgreBites.framework/Versions/1.11.5/OgreBites and there is a command LC_ID_DYLIB with the name @executable_path/../Frameworks/OgreBites.framework/Versions/1.11.5/OgreBites , which matches the path given in the runtime error.我查看了otool -l /opt/Ogre3D/ogre-1.11.5/build/lib/macosx/OgreBites.framework/Versions/1.11.5/OgreBites并且有一个名为@executable_path/../Frameworks/OgreBites.framework/Versions/1.11.5/OgreBites的命令LC_ID_DYLIB @executable_path/../Frameworks/OgreBites.framework/Versions/1.11.5/OgreBites ,它匹配运行时错误中给出的路径。 However I don't know which step to take now as I have few experience with native library resolution on macOS.但是我不知道现在该采取哪一步,因为我对 macOS 上的本机库解析几乎没有经验。

Update:更新:

Executing the command install_name_tool makes the linker find the library, but then it fails with the next one.执行命令install_name_tool使链接器找到库,但随后它在下一个失败。 I suppose/hope there is an option in CMake to pass it to the compiler so the binary files created during Ogre's compilation do not use the @execute_path directive?我想/希望 CMake 中有一个选项可以将它传递给编译器,因此在 Ogre 编译期间创建的二进制文件不使用@execute_path指令?

I'm faced with the same problem, when using clion to build ogre in macos.在 macos 中使用 clion 构建 ogre 时,我遇到了同样的问题。

I found the symbolic links were invalid in the directory cmake-build-debug/bin/SampleBrowser.app/Contents/Frameworks .我发现目录 cmake-build-debug/bin/SampleBrowser.app/Contents/Frameworks 中的符号链接无效

I guess these symbolic links should point to these frameworks int the cmake-build-debug/lib/macosx.我猜这些符号链接应该指向 cmake-build-debug/lib/macosx 中的这些框架。 So I modified the file where executed ln to create these symbolic links.所以我修改了执行ln的文件来创建这些符号链接。

In the file Samples/Browser/CMakeLists.txt, change在文件 Samples/Browser/CMakeLists.txt 中,更改

set(OGRE_OSX_BUILD_CONFIGURATION "${CMAKE_OSX_SYSROOT}/$(CONFIGURATION)")

into进入

set(OGRE_OSX_BUILD_CONFIGURATION "macosx")

And clean and rebuild, then the problem will disappear.并清理并重建,然后问题就会消失。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM