Follow the link of @bmike, I did:
1.Install qrencode on a normal mac desktop by :
brew install qrencode
now you can use qrencode on this mac well
2.Find where the qrencode is :
find / -name "qrencode"
get the path is : /usr/local/Cellar/qrencode/4.1.1/bin/qrencode
open /usr/local/Cellar/qrencode/4.1.1
you can see the directory: bin , lib
3.Insert a usb storage named: AAA , mkdir a dir /Volumes/AAA/qr
and copy the bin and lib to it
4.Now put the usb to the second mac osx Desktop where qrencode is not installed by brew before,(second mac maybe not necessary ,but it's good to repect the errors and confirm you solved the errors, virtual mac is a good choice)
cd /Volumes/AAA/qr
run the qrencode by :
bin/qrencode
you will see the error as the question.
5.Now you can the error such as:
dyld: Library not loaded: /usr/local/Cellar/qrencode/4.1.1/lib/libqrencode.4.dylib
we can change path of qrencode to find dylib:
install_name_tool -change /usr/local/Cellar/qrencode/4.1.1/lib/libqrencode.4.dylib "@executable_path/../lib/libqrencode.4.dylib" bin/qrencode
maybe this mac shell will required xcode-commandline to installed for run install_name_tool ,if you did not install that, you can installed it as the shell required
after that,you can run qrencode again:
bin/qrencode
it will error again for another dylib,so you chage it again:
install_name_tool -change /usr/local/opt/libpng/lib/libpng16.16.dylib "@executable_path/../lib/libpng16.16.dylib" bin/qrencode
because when we copy qrenocde dir , we forget copy /usr/local/opt/libpng/lib/libpng16.16.dylib to /Volumes/AAA/qr/lib,
so we have to insert usb to first mac,and run :
cp /usr/local/opt/libpng/lib/libpng16.16.dylib /Volumes/AAA/qr/lib/
now put the usb back to the second mac,run qrencode again it will run well and print the usage of qrencode , all is done:
cd /Volumes/AAA/qr
bin/qrencode
I waste some time to know what @executable_path is , if qrencode is in bin dir and *.dylib is in lib dir, such as I did, @executable_path/../lib is good, but if qrencode path is /Volumes/AAA/qr/qrencode and *.dylib is in /Volumes/AAA/qr/lib/, @executable_path/../lib should be edit to @executable_path/lib , I test two situations and understand that.
6.Finally , you can run qrencode on any mac desktop or recovery mod with no errors:
/Volumes/AAA/qr/bin/qrencode
DYLD_LIBRARY_PATH=/usr/local/Cellar/qrencode/4.1.1/lib qrencode/4.1.1/bin/qrencode
work? If that's the case, you can create an alias in your.bashrc
or.zshrc
file.