Skip to content

Instantly share code, notes, and snippets.

@7468696e6b
Last active August 9, 2025 21:25
Show Gist options
  • Save 7468696e6b/ec8fa5d6cdb4e80633b9df95869b70c0 to your computer and use it in GitHub Desktop.
Save 7468696e6b/ec8fa5d6cdb4e80633b9df95869b70c0 to your computer and use it in GitHub Desktop.
how to install Okular viewer on macOS Big Sur, using M1/Apple Silicon/arm64
  1. Install homebrew from https://brew.sh/ (follow the instructions there)
  2. tap the https://invent.kde.org/packaging/homebrew-kde/ repo, brew tap kde-mac/kde https://invent.kde.org/packaging/homebrew-kde.git
  3. brew edit okular, workaround now is to comment out or delete the line depends_on "chmlib" (won't compile on macos arm64 for now as of 2021-08-18), then save (if using vim you need to first press i to insert/type, when saving then <esc> then :wq then <enter>.
  4. brew install okular, wait for stuff to compile and/or install
  5. It may ask for keychain credentials (to sign the binaries? because of mac arm64 security policy https://eclecticlight.co/2021/01/26/when-you-dont-have-permission-to-run-an-app-on-an-m1-mac/)
  6. $(brew --repo kde-mac/kde)/tools/do-caveats.sh
  7. Now okular is in your $HOME/Applications/KDE folder, and will show up in Launchpad! You can view pdf, djvu, etc documents.

Edit: as of 2025 there is now a precompiled nightly binary available for download at https://okular.kde.org/download/, or at https://cdn.kde.org/ci-builds/graphics/okular/master/macos-arm64/. It is unsigned so use sudo xattr -rd com.apple.quarantine /Applications/okular.app to bypass quarantine after install.

@JakkuSakura
Copy link

For qt5 cmake error, where did you install qt5? It's better if you check the error log. For me, it's something like /opt/homebrew/lib/cmake/Qt5Gui/Qt5GuiConfig.cmake contains get_filename_component(_qt5Gui_install_prefix ${CMAKE_CURRENT_LIST_DIR}/../../../ ABSOLUTE) but it's invalid.
For the brew tap, you need to

brew untap kde-mac/kde --force
brew tap kde-mac/kde https://github.com/JakkuSakura/homebrew-kde

Then it should be fine

@makotosakuraijp
Copy link

/opt/homebrew/lib/cmake//Qt6BuildInternals/StandaloneTests/Qt5CompatTestsConfig.cmake is what is obtained by find -L /opt/homebrew/lib/cmake/ -name 'Qt5*.cmake'. It says

% cat /opt/homebrew/lib/cmake//Qt6BuildInternals/StandaloneTests/Qt5CompatTestsConfig.cmake
# Copyright (C) 2024 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause

# TODO: Ideally this should look for each Qt module separately, with each module's specific version,
# bypassing the Qt6 Config file, aka find_package(Qt6SpecificFoo) repated x times. But it's not
# critical.
find_package(Qt6 6.8.2
COMPONENTS Core5Compat).

The qt5/6 is as follows:

lrwxr-xr-x 1 sakuraim admin 20 3 20 17:50 qt -> ../Cellar/qt/6.8.2_1
lrwxr-xr-x 1 sakuraim admin 24 3 21 04:47 qt5 -> ../Cellar/qt@5/5.15.16_1
lrwxr-xr-x 1 sakuraim admin 20 3 20 17:50 qt6 -> ../Cellar/qt/6.8.2_1
lrwxr-xr-x 1 sakuraim admin 24 3 21 04:41 qt@5 -> ../Cellar/qt@5/5.15.16_1
lrwxr-xr-x 1 sakuraim admin 20 3 20 17:50 qt@6 -> ../Cellar/qt/6.8.2_1

by % ls -la /opt/homebrew/opt/. The qt5 is introduced for 2c1970eb750 qt@5: update 5.15.16_1 bottle at /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/q. I guess it is /opt/homebrew/Cellar/qt@5/5.15.16_1 since it says % brew uninstall --ignore-dependencies qt@5
Uninstalling /opt/homebrew/Cellar/qt@5/5.15.16_1... (10,849 files, 341.7MB)

ls says

% ls /opt/homebrew/Cellar/qt@5/5.15.16_1
Frameworks doc
INSTALL_RECEIPT.json include
LICENSE.FDL lib
LICENSE.GPL3-EXCEPT libexec
LICENSE.GPLv2 mkspecs
LICENSE.GPLv3 phrasebooks
LICENSE.LGPLv21 plugins
LICENSE.LGPLv3 qml
LICENSE.QT-LICENSE-AGREEMENT sbom.spdx.json
README share
bin translations

Hope it works.

@makotosakuraijp
Copy link

Some progress:

$ brew link --force qt@5
$ sudo ln -s $(brew --prefix qt@5)/mkspecs /usr/local/mkspecs
$ sudo ln -s $(brew --prefix qt@5)/plugins /usr/local/plugins

Then, by your shell script, it works after ln -s /opt/homebrew/opt/qt@5 /opt/homebrew/opt/qt5. I could install kf5-ki18n.rb.

But, now another problem:

==> Installing kf5-kiconthemes from kde-mac/kde
==> cmake -G Ninja -B build -S . -D BUILD_QCH=ON -D BUILD_TESTING=ON -D BUILD_TE
Last 15 lines from /Users/sakuraim/Library/Logs/Homebrew/kf5-kiconthemes/01.cmake:
"KF5Archive", but CMake did not find one.
` Could not find a package configuration file provided by "KF5Archive"` ` (requested version 5.111.0) with any of the following names:`
KF5ArchiveConfig.cmake
kf5archive-config.cmake
` Add the installation prefix of "KF5Archive" to CMAKE_PREFIX_PATH or set` ` "KF5Archive_DIR" to a directory containing one of the above files. If` ` "KF5Archive" provides a separate development package or SDK, be sure it has` ` been installed.`
``
-- Configuring incomplete, errors occurred!

Some idea?

@makotosakuraijp
Copy link

After brew install kf5-karchive.rb in your fork repository, it delivers some errors for phonon.

@makotosakuraijp
Copy link

I bypassed the errors of phonon by editing the header files of enum to explicity use unsigned. It's like this: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=272029.

I think I managed to install okular, but I still cannot print PDF files in a just size. Thanks a lot!

Note that I also needed things including ln -s /opt/homebrew/lib/libKF5Archive.5.dylib /opt/homebrew/Cellar/kdoctools/5.109.0/bin/../../../../opt/karchive/lib/libKF5Archive.5.dylib.

@makotosakuraijp
Copy link

For some reasons, I cannot use Okular again. (I brew upgrade for some times and this may cause it.) Is there someone who overcame this situation?

@aspauldingcode
Copy link

You can compile okular and other kde applications on macos using nix language.

You’ll have to write your own derivation to get a macos app working tho, and it is very tricky. For me, I have no idea how to get kde gui going but…

@7468696e6b
Copy link
Author

7468696e6b commented Jun 16, 2025 via email

@aspauldingcode
Copy link

Nice!

@makotosakuraijp
Copy link

I didn't know much about the nix language, though I know a little bit about the modern C++. About the nightly prebuild, I wish I could print PDF files. (The printing problem is the one that I am still trying to compile-build from the scratch.)

@7468696e6b
Copy link
Author

7468696e6b commented Jun 17, 2025 via email

@aspauldingcode
Copy link

Print has been broken for me with macOS and Okular since I tried using it in 2023.

@makotosakuraijp
Copy link

I don't know much about the reasons, but I cannot print and/or print-preview. The preview screen shows something like a PS-source text.

@DavidInRacine
Copy link

2025-08-09 Writing to confirm brew install okular still produces KF5I18n errors. The binary download link works.

Printing from Okular's 2025-08-04 MacOS build okular-master-6606-macos-clang-arm64.dmg works from my Mac running OS Sequoia 15.6 using an old Brother MFC laser printer and Brother's terribly antiquated software. Printing is extremely slow but it works.

Thanks y'all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment