You cannot directly place dylib inside an executable. (This is pretty much what was created for bundles, but it does not help you with command line tools.)
You can rebuild each dylib as a static (.a) library, in which case the entire executable will be copied to the executable, and you do not need to distribute anything with it. If you have a source for libraries, this is usually very simple, but without knowing exactly how you build things, it's hard to say what to change.
One thing to consider when statically binding is that it affects the sharing of different licenses. In particular, if any of the libraries that you use is LGPL licensed, their static link has consequences that do not have dynamic linking. See this question (and answer links) for more details, but in fact you should not trust the answers to Stack for legal advice on licenses. Anyway, this is probably not a problem for OP βI want to create a program and pass it on to my friendβ, but for others who read this question later, it may be.
If static linking is not possible or desirable, all you have to do is combine the executable and dylib together and upload them to your friends machine. Since he apparently does not want to run the installer, this means tarball or zipfile.
The only tricky part is making sure exe knows where to find the dilibs. If each dylib is not in the dyld search path (see the man page for dyld for more details, but this will not help you if you do not want to install anything), or in the same place as at the time you associated with it, the launch of the executable file will fail with the error "image not found" from dyld.
Fortunately, "exact location" can mean a magic path, for example "@ executable_path / libfoo.dylib", which means "in the same directory as myexe", and not an absolute path, for example / opt / local / lib / libfoo .dylib "or relative path, for example" ../../foo/build/Release/libfoo.dylib ". (Note that normal relative paths refer to the current working directory, and not to the executable or package directory.)
You can see where myexe looks like by doing this:
otool -L myexe
Everything that is not searched in @executable_path (except for files in / lib and / usr / lib, which are part of the OS and do not need to be distributed), you can fix this:
install_name_tool -change ../../../mydl/build/Release/libmydl.dylib @executable_path/libmydl.dylib myexe
Now you just need to copy all these dylib right next to myexe, pick it up and pass it to your friend, and he can just deploy it and run exe.