this question was solved and the details is at the end


I want to print a qrcode to terminal in Mac Recovery. My process ends up needing dynamic linked libraries.

On Big Sur, qrencode from homebrew is ok with golang to call the cmd:

echo 'http://www.google.com' | qrencode -o - -t UTF8

the result is as follow: enter image description here

Next I copy the qrencode to usb-stick from system: /usr/local/bin/qrencode

But if I run qrencode from Recovery, there is errors:

enter image description here

I’m not sure how to manage these dependences on dyld stored in /usr/local/Cellar

The qrencode source link is : https://fukuchi.org/works/qrencode/index.html.en

I don't know how to compile for macos with all dependences to make this a portable app.

Is there a guide or process I might adapt for this?

  • 2
    Hopefully someone has worked on a similar issue and you don’t have to copy all the libraries to USB and then relink to a relative path like this person describes.
    – bmike
    Apr 8, 2022 at 10:04
  • Does this command: 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.
    – jaume
    Apr 8, 2022 at 13:23
  • 1
    @bmike I read the link and do as that, and it works fine , Thank you ! Apr 8, 2022 at 14:14
  • 2
    Wow! That’s great. It would be super if you made a proper answer - however little or much detail, I’ll vote up your answer and you can accept it. You won’t be the first person wanting portable tools for recovery :)
    – bmike
    Apr 8, 2022 at 16:23
  • @bmike Thank you ! Do I need to do something to accept what you said? I found the title of my question is edited? I'm a freshman of StackExchange :) Apr 8, 2022 at 16:38

1 Answer 1


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 :


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:


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

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:


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .