GPUOpen-LibrariesAndSDKs / RadeonProRenderSDK

AMD Radeon™ ProRender is a powerful physically-based path traced rendering engine that enables creative professionals to produce stunningly photorealistic images.
https://gpuopen.com/radeon-prorender-suite/
Other
220 stars 46 forks source link

tutorial binaries lacking LC_RPATH loader command in macOS #32

Open dreness opened 3 years ago

dreness commented 3 years ago

Hello!

Maybe I'm the only person to try the samples under macOS, because it seems like they can't possibly work as written. In a nutshell, the built binaries try to load libRadeonProRender64.dylib at the path @rpath/libRadeonProRender64.dylib, however no LC_RPATH loader command is present, so at runtime the dylib is not found and the process exits.

andre@boop RadeonProRenderSDK % ./tutorials/Bin/03_instance64                                            
dyld: Library not loaded: @rpath/libRadeonProRender64.dylib
  Referenced from: /Users/andre/work/RadeonProRenderSDK/./tutorials/Bin/03_instance64
  Reason: image not found
zsh: abort      ./tutorials/Bin/03_instance64

andre@boop RadeonProRenderSDK % otool -l tutorials/Bin/03_instance64 | egrep -A 2 -i 'lc_load_dylib|lc_rpath' 
          cmd LC_LOAD_DYLIB
      cmdsize 64
         name @rpath/libRadeonProRender64.dylib (offset 24)
--
          cmd LC_LOAD_DYLIB
      cmdsize 48
         name /usr/lib/libc++.1.dylib (offset 24)
--
          cmd LC_LOAD_DYLIB
      cmdsize 56
         name /usr/lib/libSystem.B.dylib (offset 24)

Adding a load command to set LC_RPATH solves the problem. In my case:

andre@boop RadeonProRenderSDK % install_name_tool -add_rpath /Users/andre/work/RadeonProRenderSDK/RadeonProRender/binMacOS tutorials/Bin/03_instance64 

andre@boop RadeonProRenderSDK % otool -l tutorials/Bin/03_instance64 | egrep -A 2 -i 'lc_load_dylib|lc_rpath'
          cmd LC_LOAD_DYLIB
      cmdsize 64
         name @rpath/libRadeonProRender64.dylib (offset 24)
--
          cmd LC_LOAD_DYLIB
      cmdsize 48
         name /usr/lib/libc++.1.dylib (offset 24)
--
          cmd LC_LOAD_DYLIB
      cmdsize 56
         name /usr/lib/libSystem.B.dylib (offset 24)
--
          cmd LC_RPATH
      cmdsize 80
         path /Users/andre/work/RadeonProRenderSDK/RadeonProRender/binMacOS (offset 12)

andre@boop RadeonProRenderSDK % ./tutorials/Bin/03_instance64 
Radeon ProRender SDK simple rendering tutorial.
Context successfully created.
Rendering finished.
bsavery commented 3 years ago

Hey @dreness Correct, but to be fair, I think is more just a lack of documentation rather than a bug. But we should note it somewhere.