0

I am trying to distribute an executable file from a c++ project I made in eclipse. The problem is, it uses the SDL2 and SDL2 Image libraries which works fine on my computer since they are downloaded already, but when I try to run it on another computer I get an error message saying:

dyld[16619]: Library not loaded: /opt/local/lib/libSDL2-2.0.0.dylib
  Referenced from: /Users/garrettmurray/Downloads/Morph Bunny-2/Morph Bunny
  Reason: tried: '/opt/local/lib/libSDL2-2.0.0.dylib' (no such file), '/usr/local/lib/libSDL2-2.0.0.dylib' (no such file), '/usr/lib/libSDL2-2.0.0.dylib' (no such file)
zsh: abort      /Users/garrettmurray/Downloads/Morph\ Bunny-2/Morph\ Bunny

Is there any way to include them into the executable, or do they need to be downloaded as well and if so how do you link them to the executable?

howlger
  • 31,050
  • 11
  • 59
  • 99
  • Usually, you ship the executable with all the dependencies (in case of shared libraries). But if the libraries are static libraries, then you don't need to ship the dependencies - the libraries are included within the executable. – kiner_shah Jan 06 '22 at 04:28
  • SDL2 and SDL Image are shared libraries so I need to ship them with the executable, but I can't figure out how to link them together so that the executable can access them. – Gary Fisher Jan 06 '22 at 04:58
  • Or you can install the libraries in another system. – kiner_shah Jan 06 '22 at 06:41
  • 1
    The usual way to do this is to place the libraries at a known place *relatively* to the executable, and use rpath to make the executable find them. See e.g. https://stackoverflow.com/questions/4677044/how-to-use-dylib-in-mac-os-x-c or https://stackoverflow.com/questions/33991581/install-name-tool-to-update-a-executable-to-search-for-dylib-in-mac-os-x – n. m. could be an AI Jan 06 '22 at 08:37

0 Answers0