Skip to content

macOS build is broken #60

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
noobie-iv opened this issue Mar 26, 2025 · 15 comments
Open

macOS build is broken #60

noobie-iv opened this issue Mar 26, 2025 · 15 comments

Comments

@noobie-iv
Copy link
Member

@gasparschott

Build for Mojave is fixed. Need verification for Sequoia: macos_build branch.

Qt5:

  • Configure:
export CMAKE_PREFIX_PATH=\
/Users/user/Lib/boost-1.87.0:\
/Users/user/Lib/eigen-3.4.0:\
/Users/user/Lib/libjpeg-turbo-3.1.0:\
/Users/user/Lib/libtiff-4.7.0:\
/Users/user/Lib/Qt-5.12.12

cmake\
 -S ./src\
 -B ./build\
 -G Ninja\
 -D OpenCL_INCLUDE_DIR=/Users/user/Lib/OpenCL-2024.10.24/include\
 -D OpenCL_LIBRARY=/Users/user/Lib/OpenCL-2024.10.24/lib/libOpenCL.dylib\
 -D ENABLE_OPENCL=ON\
 -D ENABLE_OPENGL=ON\
 -D ST_USE_QT6=OFF\
 -D ST_NO_TESTS=OFF
  • Build
cmake\
 --build ./build\
 --parallel
  • Install
cmake\
 --install ./build\
 --prefix=$(pwd)/install   
  • Pack
cpack\
 -B ./pkg\
 --config ./build/CPackConfig.cmake

Qt6:

  • Configure:
/Users/user/Lib/boost-1.87.0:\
/Users/user/Lib/eigen-3.4.0:\
/Users/user/Lib/libjpeg-turbo-3.1.0:\
/Users/user/Lib/libtiff-4.7.0:\
/Users/user/Lib/Qt-6.3.2

cmake\
 -S ./src\
 -B ./build\
 -G Ninja\
 -D OpenCL_INCLUDE_DIR=/Users/user/Lib/OpenCL-2024.10.24/include\
 -D OpenCL_LIBRARY=/Users/user/Lib/OpenCL-2024.10.24/lib/libOpenCL.dylib\
 -D ENABLE_OPENCL=ON\
 -D ENABLE_OPENGL=ON\
 -D ST_USE_QT6=ON\
 -D ST_NO_TESTS=OFF 
  • Build
cmake\
 --build ./build\
 --parallel
  • Install
cmake\
 --install ./build\
 --prefix=$(pwd)/install   
  • Pack
cpack\
 -B ./pkg\
 --config ./build/CPackConfig.cmake

I can't check on a virtual machine if OpenCL works:

Image

@gasparschott
Copy link

gasparschott commented Mar 26, 2025 via email

@karipov
Copy link

karipov commented Apr 30, 2025

How can I build the latest version for MacOS? I'm running Sequoia 15.3.2. Are there build instructions for building the main branch?

After installing the required dependencies, I ran the following commands in the macos_build branch:

export CMAKE_PREFIX_PATH="$(brew --prefix qt)/lib/cmake:$(brew --prefix boost):…"
cmake -S . -B build -G Ninja \
      -D ST_USE_QT6=ON  -D ENABLE_OPENCL=ON -D ENABLE_OPENGL=ON

And then

cmake --build build --parallel
cmake --install build --prefix $(pwd)/install
cpack -B pkg --config build/CPackConfig.cmake

But got the following error during the build phase:

Build failure log
/f/scantailor-experimental (macos_build)> cmake --build build --parallel
                                                                          cmake --install build --prefix $(pwd)/install
                                                                          cpack -B pkg --config build/CPackConfig.cmake
[357/492] Building CXX object src/acceleration/opencl/CMakeFiles/opencl.dir/Transpose.cpp.o
FAILED: src/acceleration/opencl/CMakeFiles/opencl.dir/Transpose.cpp.o
/usr/bin/c++ -DBOOST_MULTI_INDEX_DISABLE_SERIALIZATION -DBOOST_TEST_DYN_LINK -DCL_HPP_ENABLE_EXCEPTIONS -DCL_HPP_MINIMUM_OPENCL_VERSION=110 -DCL_HPP_TARGET_OPENCL_VERSION=110 -DCL_TARGET_OPENCL_VERSION=120 -DCL_USE_DEPRECATED_OPENCL_1_1_APIS -DEIGEN_DONT_ALIGN_STATICALLY -DQT_CORE_LIB -DQT_GUI_LIB -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_XML_LIB -I/Users/komron/fun/scantailor-experimental/build/src/acceleration/opencl/opencl_autogen/include -I/Users/komron/fun/scantailor-experimental/src -I/Users/komron/fun/scantailor-experimental/src/foundation -I/Users/komron/fun/scantailor-experimental/src/math -I/Users/komron/fun/scantailor-experimental/src/interaction -I/Users/komron/fun/scantailor-experimental/src/zones -I/Users/komron/fun/scantailor-experimental/build -I/Users/komron/fun/scantailor-experimental/build/src -I/Users/komron/fun/scantailor-experimental/build/src/ui -I/Users/komron/fun/scantailor-experimental/src/acceleration/. -isystem /opt/homebrew/include/eigen3 -isystem /opt/homebrew/include -isystem /opt/homebrew/Cellar/boost/1.88.0/include -F/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks -isystem /opt/homebrew/opt/qt/lib/QtGui.framework/Headers -iframework /opt/homebrew/opt/qt/lib -isystem /opt/homebrew/opt/qt/lib/QtCore.framework/Headers -isystem /opt/homebrew/opt/qt/share/qt/mkspecs/macx-clang -isystem /opt/homebrew/opt/qt/include -isystem /opt/homebrew/opt/qt/lib/QtXml.framework/Headers -isystem /opt/homebrew/opt/qt/lib/QtWidgets.framework/Headers -O3 -DNDEBUG -std=gnu++17 -arch arm64 -DEIGEN_MPL2_ONLY -MD -MT src/acceleration/opencl/CMakeFiles/opencl.dir/Transpose.cpp.o -MF src/acceleration/opencl/CMakeFiles/opencl.dir/Transpose.cpp.o.d -o src/acceleration/opencl/CMakeFiles/opencl.dir/Transpose.cpp.o -c /Users/komron/fun/scantailor-experimental/src/acceleration/opencl/Transpose.cpp
In file included from /Users/komron/fun/scantailor-experimental/src/acceleration/opencl/Transpose.cpp:19:
In file included from /Users/komron/fun/scantailor-experimental/src/acceleration/opencl/Transpose.h:22:
/Users/komron/fun/scantailor-experimental/src/acceleration/opencl/OpenCLGrid.h:25:10: fatal error: 'CL/cl.h' file not found
   25 | #include <CL/cl.h>
      |          ^~~~~~~~~
1 error generated.
[359/492] Building CXX object src/acceleratio...eFiles/opencl.dir/OpenCLAffineTransform.cpp.o
FAILED: src/acceleration/opencl/CMakeFiles/opencl.dir/OpenCLAffineTransform.cpp.o
/usr/bin/c++ -DBOOST_MULTI_INDEX_DISABLE_SERIALIZATION -DBOOST_TEST_DYN_LINK -DCL_HPP_ENABLE_EXCEPTIONS -DCL_HPP_MINIMUM_OPENCL_VERSION=110 -DCL_HPP_TARGET_OPENCL_VERSION=110 -DCL_TARGET_OPENCL_VERSION=120 -DCL_USE_DEPRECATED_OPENCL_1_1_APIS -DEIGEN_DONT_ALIGN_STATICALLY -DQT_CORE_LIB -DQT_GUI_LIB -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_XML_LIB -I/Users/komron/fun/scantailor-experimental/build/src/acceleration/opencl/opencl_autogen/include -I/Users/komron/fun/scantailor-experimental/src -I/Users/komron/fun/scantailor-experimental/src/foundation -I/Users/komron/fun/scantailor-experimental/src/math -I/Users/komron/fun/scantailor-experimental/src/interaction -I/Users/komron/fun/scantailor-experimental/src/zones -I/Users/komron/fun/scantailor-experimental/build -I/Users/komron/fun/scantailor-experimental/build/src -I/Users/komron/fun/scantailor-experimental/build/src/ui -I/Users/komron/fun/scantailor-experimental/src/acceleration/. -isystem /opt/homebrew/include/eigen3 -isystem /opt/homebrew/include -isystem /opt/homebrew/Cellar/boost/1.88.0/include -F/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks -isystem /opt/homebrew/opt/qt/lib/QtGui.framework/Headers -iframework /opt/homebrew/opt/qt/lib -isystem /opt/homebrew/opt/qt/lib/QtCore.framework/Headers -isystem /opt/homebrew/opt/qt/share/qt/mkspecs/macx-clang -isystem /opt/homebrew/opt/qt/include -isystem /opt/homebrew/opt/qt/lib/QtXml.framework/Headers -isystem /opt/homebrew/opt/qt/lib/QtWidgets.framework/Headers -O3 -DNDEBUG -std=gnu++17 -arch arm64 -DEIGEN_MPL2_ONLY -MD -MT src/acceleration/opencl/CMakeFiles/opencl.dir/OpenCLAffineTransform.cpp.o -MF src/acceleration/opencl/CMakeFiles/opencl.dir/OpenCLAffineTransform.cpp.o.d -o src/acceleration/opencl/CMakeFiles/opencl.dir/OpenCLAffineTransform.cpp.o -c /Users/komron/fun/scantailor-experimental/src/acceleration/opencl/OpenCLAffineTransform.cpp
In file included from /Users/komron/fun/scantailor-experimental/src/acceleration/opencl/OpenCLAffineTransform.cpp:19:
/Users/komron/fun/scantailor-experimental/src/acceleration/opencl/OpenCLAffineTransform.h:28:10: fatal error: 'CL/cl.h' file not found
   28 | #include <CL/cl.h>
      |          ^~~~~~~~~
1 error generated.
[360/492] Building CXX object src/acceleratio...l/CMakeFiles/opencl.dir/OpenCLGaussBlur.cpp.o
FAILED: src/acceleration/opencl/CMakeFiles/opencl.dir/OpenCLGaussBlur.cpp.o
/usr/bin/c++ -DBOOST_MULTI_INDEX_DISABLE_SERIALIZATION -DBOOST_TEST_DYN_LINK -DCL_HPP_ENABLE_EXCEPTIONS -DCL_HPP_MINIMUM_OPENCL_VERSION=110 -DCL_HPP_TARGET_OPENCL_VERSION=110 -DCL_TARGET_OPENCL_VERSION=120 -DCL_USE_DEPRECATED_OPENCL_1_1_APIS -DEIGEN_DONT_ALIGN_STATICALLY -DQT_CORE_LIB -DQT_GUI_LIB -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_XML_LIB -I/Users/komron/fun/scantailor-experimental/build/src/acceleration/opencl/opencl_autogen/include -I/Users/komron/fun/scantailor-experimental/src -I/Users/komron/fun/scantailor-experimental/src/foundation -I/Users/komron/fun/scantailor-experimental/src/math -I/Users/komron/fun/scantailor-experimental/src/interaction -I/Users/komron/fun/scantailor-experimental/src/zones -I/Users/komron/fun/scantailor-experimental/build -I/Users/komron/fun/scantailor-experimental/build/src -I/Users/komron/fun/scantailor-experimental/build/src/ui -I/Users/komron/fun/scantailor-experimental/src/acceleration/. -isystem /opt/homebrew/include/eigen3 -isystem /opt/homebrew/include -isystem /opt/homebrew/Cellar/boost/1.88.0/include -F/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks -isystem /opt/homebrew/opt/qt/lib/QtGui.framework/Headers -iframework /opt/homebrew/opt/qt/lib -isystem /opt/homebrew/opt/qt/lib/QtCore.framework/Headers -isystem /opt/homebrew/opt/qt/share/qt/mkspecs/macx-clang -isystem /opt/homebrew/opt/qt/include -isystem /opt/homebrew/opt/qt/lib/QtXml.framework/Headers -isystem /opt/homebrew/opt/qt/lib/QtWidgets.framework/Headers -O3 -DNDEBUG -std=gnu++17 -arch arm64 -DEIGEN_MPL2_ONLY -MD -MT src/acceleration/opencl/CMakeFiles/opencl.dir/OpenCLGaussBlur.cpp.o -MF src/acceleration/opencl/CMakeFiles/opencl.dir/OpenCLGaussBlur.cpp.o.d -o src/acceleration/opencl/CMakeFiles/opencl.dir/OpenCLGaussBlur.cpp.o -c /Users/komron/fun/scantailor-experimental/src/acceleration/opencl/OpenCLGaussBlur.cpp
In file included from /Users/komron/fun/scantailor-experimental/src/acceleration/opencl/OpenCLGaussBlur.cpp:19:
In file included from /Users/komron/fun/scantailor-experimental/src/acceleration/opencl/OpenCLGaussBlur.h:22:
/Users/komron/fun/scantailor-experimental/src/acceleration/opencl/OpenCLGrid.h:25:10: fatal error: 'CL/cl.h' file not found
   25 | #include <CL/cl.h>
      |          ^~~~~~~~~
1 error generated.
[361/492] Building CXX object src/acceleratio...keFiles/opencl.dir/OpenCLTextFilterBank.cpp.o
FAILED: src/acceleration/opencl/CMakeFiles/opencl.dir/OpenCLTextFilterBank.cpp.o
/usr/bin/c++ -DBOOST_MULTI_INDEX_DISABLE_SERIALIZATION -DBOOST_TEST_DYN_LINK -DCL_HPP_ENABLE_EXCEPTIONS -DCL_HPP_MINIMUM_OPENCL_VERSION=110 -DCL_HPP_TARGET_OPENCL_VERSION=110 -DCL_TARGET_OPENCL_VERSION=120 -DCL_USE_DEPRECATED_OPENCL_1_1_APIS -DEIGEN_DONT_ALIGN_STATICALLY -DQT_CORE_LIB -DQT_GUI_LIB -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_XML_LIB -I/Users/komron/fun/scantailor-experimental/build/src/acceleration/opencl/opencl_autogen/include -I/Users/komron/fun/scantailor-experimental/src -I/Users/komron/fun/scantailor-experimental/src/foundation -I/Users/komron/fun/scantailor-experimental/src/math -I/Users/komron/fun/scantailor-experimental/src/interaction -I/Users/komron/fun/scantailor-experimental/src/zones -I/Users/komron/fun/scantailor-experimental/build -I/Users/komron/fun/scantailor-experimental/build/src -I/Users/komron/fun/scantailor-experimental/build/src/ui -I/Users/komron/fun/scantailor-experimental/src/acceleration/. -isystem /opt/homebrew/include/eigen3 -isystem /opt/homebrew/include -isystem /opt/homebrew/Cellar/boost/1.88.0/include -F/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks -isystem /opt/homebrew/opt/qt/lib/QtGui.framework/Headers -iframework /opt/homebrew/opt/qt/lib -isystem /opt/homebrew/opt/qt/lib/QtCore.framework/Headers -isystem /opt/homebrew/opt/qt/share/qt/mkspecs/macx-clang -isystem /opt/homebrew/opt/qt/include -isystem /opt/homebrew/opt/qt/lib/QtXml.framework/Headers -isystem /opt/homebrew/opt/qt/lib/QtWidgets.framework/Headers -O3 -DNDEBUG -std=gnu++17 -arch arm64 -DEIGEN_MPL2_ONLY -MD -MT src/acceleration/opencl/CMakeFiles/opencl.dir/OpenCLTextFilterBank.cpp.o -MF src/acceleration/opencl/CMakeFiles/opencl.dir/OpenCLTextFilterBank.cpp.o.d -o src/acceleration/opencl/CMakeFiles/opencl.dir/OpenCLTextFilterBank.cpp.o -c /Users/komron/fun/scantailor-experimental/src/acceleration/opencl/OpenCLTextFilterBank.cpp
In file included from /Users/komron/fun/scantailor-experimental/src/acceleration/opencl/OpenCLTextFilterBank.cpp:19:
In file included from /Users/komron/fun/scantailor-experimental/src/acceleration/opencl/OpenCLTextFilterBank.h:22:
/Users/komron/fun/scantailor-experimental/src/acceleration/opencl/OpenCLGrid.h:25:10: fatal error: 'CL/cl.h' file not found
   25 | #include <CL/cl.h>
      |          ^~~~~~~~~
1 error generated.
[362/492] Building CXX object src/acceleratio...MakeFiles/opencl.dir/OpenCLSavGolFilter.cpp.o
FAILED: src/acceleration/opencl/CMakeFiles/opencl.dir/OpenCLSavGolFilter.cpp.o
/usr/bin/c++ -DBOOST_MULTI_INDEX_DISABLE_SERIALIZATION -DBOOST_TEST_DYN_LINK -DCL_HPP_ENABLE_EXCEPTIONS -DCL_HPP_MINIMUM_OPENCL_VERSION=110 -DCL_HPP_TARGET_OPENCL_VERSION=110 -DCL_TARGET_OPENCL_VERSION=120 -DCL_USE_DEPRECATED_OPENCL_1_1_APIS -DEIGEN_DONT_ALIGN_STATICALLY -DQT_CORE_LIB -DQT_GUI_LIB -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_XML_LIB -I/Users/komron/fun/scantailor-experimental/build/src/acceleration/opencl/opencl_autogen/include -I/Users/komron/fun/scantailor-experimental/src -I/Users/komron/fun/scantailor-experimental/src/foundation -I/Users/komron/fun/scantailor-experimental/src/math -I/Users/komron/fun/scantailor-experimental/src/interaction -I/Users/komron/fun/scantailor-experimental/src/zones -I/Users/komron/fun/scantailor-experimental/build -I/Users/komron/fun/scantailor-experimental/build/src -I/Users/komron/fun/scantailor-experimental/build/src/ui -I/Users/komron/fun/scantailor-experimental/src/acceleration/. -isystem /opt/homebrew/include/eigen3 -isystem /opt/homebrew/include -isystem /opt/homebrew/Cellar/boost/1.88.0/include -F/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks -isystem /opt/homebrew/opt/qt/lib/QtGui.framework/Headers -iframework /opt/homebrew/opt/qt/lib -isystem /opt/homebrew/opt/qt/lib/QtCore.framework/Headers -isystem /opt/homebrew/opt/qt/share/qt/mkspecs/macx-clang -isystem /opt/homebrew/opt/qt/include -isystem /opt/homebrew/opt/qt/lib/QtXml.framework/Headers -isystem /opt/homebrew/opt/qt/lib/QtWidgets.framework/Headers -O3 -DNDEBUG -std=gnu++17 -arch arm64 -DEIGEN_MPL2_ONLY -MD -MT src/acceleration/opencl/CMakeFiles/opencl.dir/OpenCLSavGolFilter.cpp.o -MF src/acceleration/opencl/CMakeFiles/opencl.dir/OpenCLSavGolFilter.cpp.o.d -o src/acceleration/opencl/CMakeFiles/opencl.dir/OpenCLSavGolFilter.cpp.o -c /Users/komron/fun/scantailor-experimental/src/acceleration/opencl/OpenCLSavGolFilter.cpp
In file included from /Users/komron/fun/scantailor-experimental/src/acceleration/opencl/OpenCLSavGolFilter.cpp:19:
/Users/komron/fun/scantailor-experimental/src/acceleration/opencl/OpenCLSavGolFilter.h:23:10: fatal error: 'CL/cl.h' file not found
   23 | #include <CL/cl.h>
      |          ^~~~~~~~~
1 error generated.
[363/492] Building CXX object src/acceleration/opencl/CMakeFiles/opencl.dir/Copy.cpp.o
FAILED: src/acceleration/opencl/CMakeFiles/opencl.dir/Copy.cpp.o
/usr/bin/c++ -DBOOST_MULTI_INDEX_DISABLE_SERIALIZATION -DBOOST_TEST_DYN_LINK -DCL_HPP_ENABLE_EXCEPTIONS -DCL_HPP_MINIMUM_OPENCL_VERSION=110 -DCL_HPP_TARGET_OPENCL_VERSION=110 -DCL_TARGET_OPENCL_VERSION=120 -DCL_USE_DEPRECATED_OPENCL_1_1_APIS -DEIGEN_DONT_ALIGN_STATICALLY -DQT_CORE_LIB -DQT_GUI_LIB -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_XML_LIB -I/Users/komron/fun/scantailor-experimental/build/src/acceleration/opencl/opencl_autogen/include -I/Users/komron/fun/scantailor-experimental/src -I/Users/komron/fun/scantailor-experimental/src/foundation -I/Users/komron/fun/scantailor-experimental/src/math -I/Users/komron/fun/scantailor-experimental/src/interaction -I/Users/komron/fun/scantailor-experimental/src/zones -I/Users/komron/fun/scantailor-experimental/build -I/Users/komron/fun/scantailor-experimental/build/src -I/Users/komron/fun/scantailor-experimental/build/src/ui -I/Users/komron/fun/scantailor-experimental/src/acceleration/. -isystem /opt/homebrew/include/eigen3 -isystem /opt/homebrew/include -isystem /opt/homebrew/Cellar/boost/1.88.0/include -F/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks -isystem /opt/homebrew/opt/qt/lib/QtGui.framework/Headers -iframework /opt/homebrew/opt/qt/lib -isystem /opt/homebrew/opt/qt/lib/QtCore.framework/Headers -isystem /opt/homebrew/opt/qt/share/qt/mkspecs/macx-clang -isystem /opt/homebrew/opt/qt/include -isystem /opt/homebrew/opt/qt/lib/QtXml.framework/Headers -isystem /opt/homebrew/opt/qt/lib/QtWidgets.framework/Headers -O3 -DNDEBUG -std=gnu++17 -arch arm64 -DEIGEN_MPL2_ONLY -MD -MT src/acceleration/opencl/CMakeFiles/opencl.dir/Copy.cpp.o -MF src/acceleration/opencl/CMakeFiles/opencl.dir/Copy.cpp.o.d -o src/acceleration/opencl/CMakeFiles/opencl.dir/Copy.cpp.o -c /Users/komron/fun/scantailor-experimental/src/acceleration/opencl/Copy.cpp
In file included from /Users/komron/fun/scantailor-experimental/src/acceleration/opencl/Copy.cpp:19:
In file included from /Users/komron/fun/scantailor-experimental/src/acceleration/opencl/Copy.h:22:
/Users/komron/fun/scantailor-experimental/src/acceleration/opencl/OpenCLGrid.h:25:10: fatal error: 'CL/cl.h' file not found
   25 | #include <CL/cl.h>
      |          ^~~~~~~~~
1 error generated.
[364/492] Building CXX object src/acceleration/opencl/CMakeFiles/opencl.dir/OpenCLDewarp.cpp.o
FAILED: src/acceleration/opencl/CMakeFiles/opencl.dir/OpenCLDewarp.cpp.o
/usr/bin/c++ -DBOOST_MULTI_INDEX_DISABLE_SERIALIZATION -DBOOST_TEST_DYN_LINK -DCL_HPP_ENABLE_EXCEPTIONS -DCL_HPP_MINIMUM_OPENCL_VERSION=110 -DCL_HPP_TARGET_OPENCL_VERSION=110 -DCL_TARGET_OPENCL_VERSION=120 -DCL_USE_DEPRECATED_OPENCL_1_1_APIS -DEIGEN_DONT_ALIGN_STATICALLY -DQT_CORE_LIB -DQT_GUI_LIB -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_XML_LIB -I/Users/komron/fun/scantailor-experimental/build/src/acceleration/opencl/opencl_autogen/include -I/Users/komron/fun/scantailor-experimental/src -I/Users/komron/fun/scantailor-experimental/src/foundation -I/Users/komron/fun/scantailor-experimental/src/math -I/Users/komron/fun/scantailor-experimental/src/interaction -I/Users/komron/fun/scantailor-experimental/src/zones -I/Users/komron/fun/scantailor-experimental/build -I/Users/komron/fun/scantailor-experimental/build/src -I/Users/komron/fun/scantailor-experimental/build/src/ui -I/Users/komron/fun/scantailor-experimental/src/acceleration/. -isystem /opt/homebrew/include/eigen3 -isystem /opt/homebrew/include -isystem /opt/homebrew/Cellar/boost/1.88.0/include -F/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks -isystem /opt/homebrew/opt/qt/lib/QtGui.framework/Headers -iframework /opt/homebrew/opt/qt/lib -isystem /opt/homebrew/opt/qt/lib/QtCore.framework/Headers -isystem /opt/homebrew/opt/qt/share/qt/mkspecs/macx-clang -isystem /opt/homebrew/opt/qt/include -isystem /opt/homebrew/opt/qt/lib/QtXml.framework/Headers -isystem /opt/homebrew/opt/qt/lib/QtWidgets.framework/Headers -O3 -DNDEBUG -std=gnu++17 -arch arm64 -DEIGEN_MPL2_ONLY -MD -MT src/acceleration/opencl/CMakeFiles/opencl.dir/OpenCLDewarp.cpp.o -MF src/acceleration/opencl/CMakeFiles/opencl.dir/OpenCLDewarp.cpp.o.d -o src/acceleration/opencl/CMakeFiles/opencl.dir/OpenCLDewarp.cpp.o -c /Users/komron/fun/scantailor-experimental/src/acceleration/opencl/OpenCLDewarp.cpp
In file included from /Users/komron/fun/scantailor-experimental/src/acceleration/opencl/OpenCLDewarp.cpp:19:
/Users/komron/fun/scantailor-experimental/src/acceleration/opencl/OpenCLDewarp.h:28:10: fatal error: 'CL/cl.h' file not found
   28 | #include <CL/cl.h>
      |          ^~~~~~~~~
1 error generated.
[365/492] Building CXX object src/acceleratio.../CMakeFiles/opencl.dir/HitMissTransform.cpp.o
FAILED: src/acceleration/opencl/CMakeFiles/opencl.dir/HitMissTransform.cpp.o
/usr/bin/c++ -DBOOST_MULTI_INDEX_DISABLE_SERIALIZATION -DBOOST_TEST_DYN_LINK -DCL_HPP_ENABLE_EXCEPTIONS -DCL_HPP_MINIMUM_OPENCL_VERSION=110 -DCL_HPP_TARGET_OPENCL_VERSION=110 -DCL_TARGET_OPENCL_VERSION=120 -DCL_USE_DEPRECATED_OPENCL_1_1_APIS -DEIGEN_DONT_ALIGN_STATICALLY -DQT_CORE_LIB -DQT_GUI_LIB -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_XML_LIB -I/Users/komron/fun/scantailor-experimental/build/src/acceleration/opencl/opencl_autogen/include -I/Users/komron/fun/scantailor-experimental/src -I/Users/komron/fun/scantailor-experimental/src/foundation -I/Users/komron/fun/scantailor-experimental/src/math -I/Users/komron/fun/scantailor-experimental/src/interaction -I/Users/komron/fun/scantailor-experimental/src/zones -I/Users/komron/fun/scantailor-experimental/build -I/Users/komron/fun/scantailor-experimental/build/src -I/Users/komron/fun/scantailor-experimental/build/src/ui -I/Users/komron/fun/scantailor-experimental/src/acceleration/. -isystem /opt/homebrew/include/eigen3 -isystem /opt/homebrew/include -isystem /opt/homebrew/Cellar/boost/1.88.0/include -F/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks -isystem /opt/homebrew/opt/qt/lib/QtGui.framework/Headers -iframework /opt/homebrew/opt/qt/lib -isystem /opt/homebrew/opt/qt/lib/QtCore.framework/Headers -isystem /opt/homebrew/opt/qt/share/qt/mkspecs/macx-clang -isystem /opt/homebrew/opt/qt/include -isystem /opt/homebrew/opt/qt/lib/QtXml.framework/Headers -isystem /opt/homebrew/opt/qt/lib/QtWidgets.framework/Headers -O3 -DNDEBUG -std=gnu++17 -arch arm64 -DEIGEN_MPL2_ONLY -MD -MT src/acceleration/opencl/CMakeFiles/opencl.dir/HitMissTransform.cpp.o -MF src/acceleration/opencl/CMakeFiles/opencl.dir/HitMissTransform.cpp.o.d -o src/acceleration/opencl/CMakeFiles/opencl.dir/HitMissTransform.cpp.o -c /Users/komron/fun/scantailor-experimental/src/acceleration/opencl/HitMissTransform.cpp
In file included from /Users/komron/fun/scantailor-experimental/src/acceleration/opencl/HitMissTransform.cpp:19:
In file included from /Users/komron/fun/scantailor-experimental/src/acceleration/opencl/HitMissTransform.h:22:
/Users/komron/fun/scantailor-experimental/src/acceleration/opencl/OpenCLGrid.h:25:10: fatal error: 'CL/cl.h' file not found
   25 | #include <CL/cl.h>
      |          ^~~~~~~~~
1 error generated.
[366/492] Building CXX object src/acceleration/opencl/CMakeFiles/opencl.dir/BinaryFill.cpp.o
FAILED: src/acceleration/opencl/CMakeFiles/opencl.dir/BinaryFill.cpp.o
/usr/bin/c++ -DBOOST_MULTI_INDEX_DISABLE_SERIALIZATION -DBOOST_TEST_DYN_LINK -DCL_HPP_ENABLE_EXCEPTIONS -DCL_HPP_MINIMUM_OPENCL_VERSION=110 -DCL_HPP_TARGET_OPENCL_VERSION=110 -DCL_TARGET_OPENCL_VERSION=120 -DCL_USE_DEPRECATED_OPENCL_1_1_APIS -DEIGEN_DONT_ALIGN_STATICALLY -DQT_CORE_LIB -DQT_GUI_LIB -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_XML_LIB -I/Users/komron/fun/scantailor-experimental/build/src/acceleration/opencl/opencl_autogen/include -I/Users/komron/fun/scantailor-experimental/src -I/Users/komron/fun/scantailor-experimental/src/foundation -I/Users/komron/fun/scantailor-experimental/src/math -I/Users/komron/fun/scantailor-experimental/src/interaction -I/Users/komron/fun/scantailor-experimental/src/zones -I/Users/komron/fun/scantailor-experimental/build -I/Users/komron/fun/scantailor-experimental/build/src -I/Users/komron/fun/scantailor-experimental/build/src/ui -I/Users/komron/fun/scantailor-experimental/src/acceleration/. -isystem /opt/homebrew/include/eigen3 -isystem /opt/homebrew/include -isystem /opt/homebrew/Cellar/boost/1.88.0/include -F/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks -isystem /opt/homebrew/opt/qt/lib/QtGui.framework/Headers -iframework /opt/homebrew/opt/qt/lib -isystem /opt/homebrew/opt/qt/lib/QtCore.framework/Headers -isystem /opt/homebrew/opt/qt/share/qt/mkspecs/macx-clang -isystem /opt/homebrew/opt/qt/include -isystem /opt/homebrew/opt/qt/lib/QtXml.framework/Headers -isystem /opt/homebrew/opt/qt/lib/QtWidgets.framework/Headers -O3 -DNDEBUG -std=gnu++17 -arch arm64 -DEIGEN_MPL2_ONLY -MD -MT src/acceleration/opencl/CMakeFiles/opencl.dir/BinaryFill.cpp.o -MF src/acceleration/opencl/CMakeFiles/opencl.dir/BinaryFill.cpp.o.d -o src/acceleration/opencl/CMakeFiles/opencl.dir/BinaryFill.cpp.o -c /Users/komron/fun/scantailor-experimental/src/acceleration/opencl/BinaryFill.cpp
In file included from /Users/komron/fun/scantailor-experimental/src/acceleration/opencl/BinaryFill.cpp:19:
In file included from /Users/komron/fun/scantailor-experimental/src/acceleration/opencl/BinaryFill.h:22:
/Users/komron/fun/scantailor-experimental/src/acceleration/opencl/OpenCLGrid.h:25:10: fatal error: 'CL/cl.h' file not found
   25 | #include <CL/cl.h>
      |          ^~~~~~~~~
1 error generated.
[367/492] Building CXX object src/acceleratio...cl/CMakeFiles/opencl.dir/BinaryRasterOp.cpp.o
FAILED: src/acceleration/opencl/CMakeFiles/opencl.dir/BinaryRasterOp.cpp.o
/usr/bin/c++ -DBOOST_MULTI_INDEX_DISABLE_SERIALIZATION -DBOOST_TEST_DYN_LINK -DCL_HPP_ENABLE_EXCEPTIONS -DCL_HPP_MINIMUM_OPENCL_VERSION=110 -DCL_HPP_TARGET_OPENCL_VERSION=110 -DCL_TARGET_OPENCL_VERSION=120 -DCL_USE_DEPRECATED_OPENCL_1_1_APIS -DEIGEN_DONT_ALIGN_STATICALLY -DQT_CORE_LIB -DQT_GUI_LIB -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_XML_LIB -I/Users/komron/fun/scantailor-experimental/build/src/acceleration/opencl/opencl_autogen/include -I/Users/komron/fun/scantailor-experimental/src -I/Users/komron/fun/scantailor-experimental/src/foundation -I/Users/komron/fun/scantailor-experimental/src/math -I/Users/komron/fun/scantailor-experimental/src/interaction -I/Users/komron/fun/scantailor-experimental/src/zones -I/Users/komron/fun/scantailor-experimental/build -I/Users/komron/fun/scantailor-experimental/build/src -I/Users/komron/fun/scantailor-experimental/build/src/ui -I/Users/komron/fun/scantailor-experimental/src/acceleration/. -isystem /opt/homebrew/include/eigen3 -isystem /opt/homebrew/include -isystem /opt/homebrew/Cellar/boost/1.88.0/include -F/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks -isystem /opt/homebrew/opt/qt/lib/QtGui.framework/Headers -iframework /opt/homebrew/opt/qt/lib -isystem /opt/homebrew/opt/qt/lib/QtCore.framework/Headers -isystem /opt/homebrew/opt/qt/share/qt/mkspecs/macx-clang -isystem /opt/homebrew/opt/qt/include -isystem /opt/homebrew/opt/qt/lib/QtXml.framework/Headers -isystem /opt/homebrew/opt/qt/lib/QtWidgets.framework/Headers -O3 -DNDEBUG -std=gnu++17 -arch arm64 -DEIGEN_MPL2_ONLY -MD -MT src/acceleration/opencl/CMakeFiles/opencl.dir/BinaryRasterOp.cpp.o -MF src/acceleration/opencl/CMakeFiles/opencl.dir/BinaryRasterOp.cpp.o.d -o src/acceleration/opencl/CMakeFiles/opencl.dir/BinaryRasterOp.cpp.o -c /Users/komron/fun/scantailor-experimental/src/acceleration/opencl/BinaryRasterOp.cpp
In file included from /Users/komron/fun/scantailor-experimental/src/acceleration/opencl/BinaryRasterOp.cpp:19:
In file included from /Users/komron/fun/scantailor-experimental/src/acceleration/opencl/BinaryRasterOp.h:22:
/Users/komron/fun/scantailor-experimental/src/acceleration/opencl/OpenCLGrid.h:25:10: fatal error: 'CL/cl.h' file not found
   25 | #include <CL/cl.h>
      |          ^~~~~~~~~
1 error generated.
[368/492] Building CXX object src/acceleratio...iles/opencl.dir/RenderPolynomialSurface.cpp.o
FAILED: src/acceleration/opencl/CMakeFiles/opencl.dir/RenderPolynomialSurface.cpp.o
/usr/bin/c++ -DBOOST_MULTI_INDEX_DISABLE_SERIALIZATION -DBOOST_TEST_DYN_LINK -DCL_HPP_ENABLE_EXCEPTIONS -DCL_HPP_MINIMUM_OPENCL_VERSION=110 -DCL_HPP_TARGET_OPENCL_VERSION=110 -DCL_TARGET_OPENCL_VERSION=120 -DCL_USE_DEPRECATED_OPENCL_1_1_APIS -DEIGEN_DONT_ALIGN_STATICALLY -DQT_CORE_LIB -DQT_GUI_LIB -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_XML_LIB -I/Users/komron/fun/scantailor-experimental/build/src/acceleration/opencl/opencl_autogen/include -I/Users/komron/fun/scantailor-experimental/src -I/Users/komron/fun/scantailor-experimental/src/foundation -I/Users/komron/fun/scantailor-experimental/src/math -I/Users/komron/fun/scantailor-experimental/src/interaction -I/Users/komron/fun/scantailor-experimental/src/zones -I/Users/komron/fun/scantailor-experimental/build -I/Users/komron/fun/scantailor-experimental/build/src -I/Users/komron/fun/scantailor-experimental/build/src/ui -I/Users/komron/fun/scantailor-experimental/src/acceleration/. -isystem /opt/homebrew/include/eigen3 -isystem /opt/homebrew/include -isystem /opt/homebrew/Cellar/boost/1.88.0/include -F/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks -isystem /opt/homebrew/opt/qt/lib/QtGui.framework/Headers -iframework /opt/homebrew/opt/qt/lib -isystem /opt/homebrew/opt/qt/lib/QtCore.framework/Headers -isystem /opt/homebrew/opt/qt/share/qt/mkspecs/macx-clang -isystem /opt/homebrew/opt/qt/include -isystem /opt/homebrew/opt/qt/lib/QtXml.framework/Headers -isystem /opt/homebrew/opt/qt/lib/QtWidgets.framework/Headers -O3 -DNDEBUG -std=gnu++17 -arch arm64 -DEIGEN_MPL2_ONLY -MD -MT src/acceleration/opencl/CMakeFiles/opencl.dir/RenderPolynomialSurface.cpp.o -MF src/acceleration/opencl/CMakeFiles/opencl.dir/RenderPolynomialSurface.cpp.o.d -o src/acceleration/opencl/CMakeFiles/opencl.dir/RenderPolynomialSurface.cpp.o -c /Users/komron/fun/scantailor-experimental/src/acceleration/opencl/RenderPolynomialSurface.cpp
In file included from /Users/komron/fun/scantailor-experimental/src/acceleration/opencl/RenderPolynomialSurface.cpp:19:
/Users/komron/fun/scantailor-experimental/src/acceleration/opencl/RenderPolynomialSurface.h:24:10: fatal error: 'CL/cl.h' file not found
   24 | #include <CL/cl.h>
      |          ^~~~~~~~~
1 error generated.
ninja: build stopped: subcommand failed.
-- Install configuration: "Release"
CMake Error at build/src/acceleration/opencl/cmake_install.cmake:41 (file):
  file INSTALL cannot find
  "/Users/komron/fun/scantailor-experimental/build/libopencl_plugin.so": No
  such file or directory.
Call Stack (most recent call first):
  build/src/acceleration/cmake_install.cmake:42 (include)
  build/src/cmake_install.cmake:82 (include)
  build/cmake_install.cmake:42 (include)


CPack: Create package using DragNDrop
CPack: Install projects
CPack: - Install project: Scan Tailor Experimental []
CMake Error at /Users/komron/fun/scantailor-experimental/build/src/acceleration/opencl/cmake_install.cmake:41 (file):
  file INSTALL cannot find
  "/Users/komron/fun/scantailor-experimental/build/libopencl_plugin.so": No
  such file or directory.
Call Stack (most recent call first):
  /Users/komron/fun/scantailor-experimental/build/src/acceleration/cmake_install.cmake:42 (include)
  /Users/komron/fun/scantailor-experimental/build/src/cmake_install.cmake:82 (include)
  /Users/komron/fun/scantailor-experimental/build/cmake_install.cmake:42 (include)


CMake Error at /Users/komron/fun/scantailor-experimental/build/cmake_install.cmake:56 (file):
  file INSTALL cannot find
  "/Users/komron/fun/scantailor-experimental/build/scantailor-experimental-cli":
  No such file or directory.


CMake Error at /Users/komron/fun/scantailor-experimental/build/cmake_install.cmake:69 (file):
  file INSTALL cannot find
  "/Users/komron/fun/scantailor-experimental/build/scantailor-experimental_bg.qm":
  No such file or directory.


CMake Error at /Users/komron/fun/scantailor-experimental/build/cmake_install.cmake:98 (file):
  file Failed to run otool on:

    /Users/komron/fun/scantailor-experimental/build/scantailor-experimental.app/Contents/MacOS/scantailor-experimental


CPack Error: Error when generating package: scantailor-experimental

@noobie-iv
Copy link
Member Author

@karipov

Try to add the path to OpenCL at configuration stage explicitly:

cmake -S . -B build\
 -D OpenCL_INCLUDE_DIR=/????????????/OpenCL-2024.10.24/include\
 -D OpenCL_LIBRARY=/????????????/OpenCL-2024.10.24/lib/libOpenCL.dylib\
 ...

Xcode contains its own OpenCL framework, but outdated and incomplete. But for some reason cmake finds and uses it, if you don’t specify other paths during configuration. I don't know where homebrew keeps it, because only old macOS versions run on a virtual computer, and nomebrew does not support them. I compiled all the libraries manually, so replace the question marks with the correct path.

@karipov
Copy link

karipov commented Apr 30, 2025

Okay @noobie-iv (maybe @gasparschott for the future). Here are all the steps I took to get the installation to work with Qt 6. I'm using fish as my shell and running an M2 Pro machine on Sequoia 15.3.2 (24D81). I also use homebrew.

0. Install prerequisites (one-time)

brew install cmake ninja boost eigen libjpeg-turbo libtiff qt \
             opencl-headers opencl-clhpp-headers opencl-icd-loader

1. Get the macOS-fixes branch

git clone --branch macos_build \
  https://github.com/ImageProcessing-ElectronicPublications/scantailor-experimental.git
cd scantailor-experimental

2. Configure the build

rm -rf build                                 # clean slate
set BREW /opt/homebrew/opt

cmake -S . -B build -G Ninja \
  -D ST_USE_QT6=ON                          \
  -D ENABLE_OPENCL=ON -D ENABLE_OPENGL=ON   \
  -D OpenCL_LIBRARY="$BREW/opencl-icd-loader/lib/libOpenCL.dylib" \
  -D CMAKE_PREFIX_PATH="$BREW/qt;$BREW/boost;$BREW/eigen;$BREW/libjpeg-turbo;$BREW/libtiff" \
  -D CMAKE_CXX_FLAGS="-isystem $BREW/opencl-headers/include -isystem $BREW/opencl-clhpp-headers/include" \
  -D CMAKE_C_FLAGS="-isystem $BREW/opencl-headers/include"

This adds both keg-only OpenCL header directories so every source sees <CL/cl.h> and <CL/opencl.hpp>.

3. Compile

cmake --build build --parallel

4. Fix Homebrew’s Qt plugin layout (one-time)

set QT_PREFIX (brew --prefix qt)      # /opt/homebrew/opt/qt
rm -rf  $QT_PREFIX/plugins            # remove any partial attempts
ln -sfn $QT_PREFIX/share/qt/plugins  $QT_PREFIX/plugins

For some reason I kept getting the following error, and the above lines fixed it:

CMake Error at build/cmake_install.cmake:138 (file):
  file INSTALL cannot find
  "/opt/homebrew/opt/qt/plugins/styles/libqmacstyle.dylib": No such file or
  directory.

5. Add Linux-style alias for the OpenCL plugin

Not sure if you need this, but saw it somewhere as to be included

ln -sfn build/src/acceleration/opencl/libopencl_plugin.dylib \
         build/src/acceleration/opencl/libopencl_plugin.so

6. And last, stage the app bundle:

cmake --install build --prefix (pwd)/install

The resulting file is in install/scantailor-experimental.app

@karipov
Copy link

karipov commented Apr 30, 2025

After all this, unfortunately, I don't see OpenCL-capable devices:

Image

Maybe my configuration was incorrect, in which case I would appreciate any tips! I'm not 100% sure how to compile each of the libraries from source but I can give it a go as well and see if that changes things. Would that be helpful?

Also, in general, I think this project deserves a lot more attention. If you cleaned up the README, and advertised it on something like diybookscanner.org/forum, there would be a lot of interest.

@noobie-iv
Copy link
Member Author

Maybe the plugin libopencl_plugin.so can't load the libOpenCL.dylib library. We should try to copy it to scantailor-experimental.app/Contents/Frameworks. In my system the link from the plugin looks like this: @rpath/libOpenCL.1.dylib, so the path must be: scantailor-experimental.app/Contents/Frameworks/libOpenCL.1.dylib

@karipov
Copy link

karipov commented Apr 30, 2025

@noobie-iv

Hm, okay so I copied it over to the app like so:

set APP install/scantailor-experimental.app
cp (brew --prefix opencl-icd-loader)/lib/libOpenCL.* $APP/Contents/Frameworks/

Doing a quick test, I see that everything is there:

ls -l $APP/Contents/Frameworks/libOpenCL*

> -r--r--r--@ 1 komron  staff  101520 Apr 30 00:57 scantailor-experimental.app/Contents/Frameworks/libOpenCL.1.0.0.dylib
> -r--r--r--@ 1 komron  staff  101520 Apr 30 00:57 scantailor-experimental.app/Contents/Frameworks/libOpenCL.1.dylib
> -r--r--r--@ 1 komron  staff  101520 Apr 30 00:57 scantailor-experimental.app/Contents/Frameworks/libOpenCL.dylib

Relaunching the app, unfortunately the acceleration is still greyed-out. I think it would be worth trying to build all the libraries manually and redo the compilation, but that will take a second. Still, I'm super grateful you're taking the time to make macOS builds even possible.

Have you by any chance looked at Github-hosted runners? It seems like they provide apple-silicon macos machines for which you can write actions to compile binaries.

@noobie-iv
Copy link
Member Author

If I launch ST from terminal and go to settings, an error message appears in the terminal:

OpenCL error:  clGetPlatformIDs

But if the OpenCL library is not available (not copied to Frameworks folder, and the original folder /Users/user/Lib/OpenCL-2024.10.24/lib/ is renamed, so that the library is definitely not detected), then the error message changes:

OpenCL plugin failed to load: Library not loaded: @rpath/libOpenCL.1.dylib

This means that the plugin finds the library in the Frameworks folder. But I can't fix broken OpenCL from under a virtual machine. Apparently, only a macOS programmer can fix it. All I can do is merge the branch to build the program without OpenCL.

@zvezdochiot
Copy link
Member

zvezdochiot commented Apr 30, 2025

@noobie-iv , объединяй. Близится релиз 1.2025.05.05. Не стоит тянуть как с предыдущим.

PS: Обрати внимание на порог N.I.C.K. Его реализация практически идентична Niblack, только зазор между "средним" и "пороговой картой" определяется не стандартным отклонением, а круговой составляющей из стандартного отклонения и среднего (double const circle = sqrt(variance + mean * mean); double threshold = mean - k * circle;). Оттого и коэффициент (масштаб зазора) в разы меньше чем у Niblack (0.05 против 0.20), а результат значительно чище. При этом характер порога похож на Niblack. Возможно в STD тебе зайдёт (ваять особо ничего не надо (копи-паста binarizeNiblackMap), а результат по соотношению чистота/контуры вполне).

PS2: Либо можешь вообще в binarizeNiblackMap опциональный коэффициент scale добавить (по умолчанию == 0.0). Тогда вообще круть получишь: double const stddev = sqrt(fabs(variance + scale * mean * mean)); (а виджет и опции скопи-пастить с Gatos).

@zvezdochiot
Copy link
Member

zvezdochiot commented Apr 30, 2025

Date: Wed Apr 30 21:44:02 2025 +1000: 84d80e2 by @noobie-iv .

PS: А +10 - это Владивосток? Круто. 👍

@karipov
Copy link

karipov commented Apr 30, 2025

@zvezdochiot @noobie-iv as I understand you've merged this branch. I am happy to keep testing what needs to be tested, and in the meantime try to create some sort of build system for macOS. I already have a .dmg of this branch's .app file, but can also make one happen for the next release, even if without OpenCL acceleration.

Once again, thank you guys for the amazing work on this project so far!

@karipov
Copy link

karipov commented Apr 30, 2025

@noobie-iv I was able to fix the issue!

Image

Looks like the root issue is that the pure Khronos loader is just a stub with no real drivers, so clGetPlatformIDs finds no platforms. Apple’s OpenCL.framework bundles both the loader and the Metal-backed ICD needed for GPU acceleration on macOS. Linking with -framework OpenCL pulls in that system framework correctly instead of treating it as a missing build target. So, we have to use Apple's OpenCL even if it's outdated...

The current cmakelists treats OpenCL as a regular .dylib, but we must instead link to Apple's framework with -framework flag. Here's a quick and dirty way I got it working:

set BREW /opt/homebrew/opt

cmake -S . -B build -G Ninja \
  -D ST_USE_QT6=ON \
  -D ENABLE_OPENCL=ON \
  -D ENABLE_OPENGL=ON \
  -D CMAKE_C_FLAGS="-I/System/Library/Frameworks/OpenCL.framework/Headers -isystem $BREW/opencl-headers/include" \
  -D CMAKE_CXX_FLAGS="-I/System/Library/Frameworks/OpenCL.framework/Headers -isystem $BREW/opencl-headers/include -isystem $BREW/opencl-clhpp-headers/include" \
  -D CMAKE_EXE_LINKER_FLAGS="-framework OpenCL" \
  -D CMAKE_SHARED_LINKER_FLAGS="-framework OpenCL" \
  -D CMAKE_PREFIX_PATH="$BREW/qt;$BREW/boost;$BREW/eigen;$BREW/libjpeg-turbo;$BREW/libtiff"

But ideally, we hook it into CMakeLists. I'm not super familar with cpp or cmakelists, but I think something like this might work:

if(ENABLE_OPENCL AND APPLE)
  # force linking the framework instead of a raw library path
  set(CMAKE_C_FLAGS   "${CMAKE_C_FLAGS}   -I/System/Library/Frameworks/OpenCL.framework/Headers")
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I/System/Library/Frameworks/OpenCL.framework/Headers")
  set(CMAKE_EXE_LINKER_FLAGS   "${CMAKE_EXE_LINKER_FLAGS}   -framework OpenCL")
  set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -framework OpenCL")
endif()

@noobie-iv
Copy link
Member Author

@karipov:

CMAKE_CXX_FLAGS

I feel like this is wrong, but I can't prove it 😄. It's strange that you need to connect some headers and use others. Also cmake sees that it linked with the framework, it is strange to add this to the command line parameters manually. It seems that in macos the headers are simply not installed, but everything else is. So, it is enough to specify the path to the headers (OpenCL_INCLUDE_DIR):

export CMAKE_PREFIX_PATH=\
/Users/user/Lib/boost-1.87.0:\
/Users/user/Lib/eigen-3.4.0:\
/Users/user/Lib/libjpeg-turbo-3.1.0:\
/Users/user/Lib/libtiff-4.7.0:\
/Users/user/Lib/Qt-5.12.12

# Configure
cmake\
 -S ./src\
 -B ./build\
 -G Ninja\
 -D CPACK_GENETATOR=DragNDrop\
 -D OpenCL_INCLUDE_DIR:PATH=/Users/user/Lib/OpenCL-2024.10.24/include\
 -D ST_USE_QT6=ON\
 -D ENABLE_OPENCL:BOOL=ON\
 -D ENABLE_OPENGL:BOOL=ON\
 -D ST_USE_QT6:BOOL=OFF\
 -D ST_NO_TESTS=OFF

# Build
cmake\
 --build ./build\
 --parallel

# Install
cmake\
 --install ./build\
 --prefix=$(pwd)/install

# Pack
cpack\
 -B ./pkg\
 --config ./build/CPackConfig.cmake

VitrtualBox OpenCL:

Image

Super Quick Exit with OpenCL 😄:

Image

@karipov
Copy link

karipov commented May 1, 2025

@noobie-iv is there anything else left to do from my end? дай знать если я могу с чем нибудь помочь

@noobie-iv
Copy link
Member Author

@karipov

If OpenCL works, all that's left is to build the release (on the virtual machine OpenCL crashes and I can't test if it works on real hardware).

Ideally, the installer still needs to be cleaned. Now it includes extra headers:

scantailor-experimental.app/Contents/Frameworks/QtCore.framework/Headers/*.h
scantailor-experimental.app/Contents/Frameworks/QtGui.framework/Headers/*.h
...

It's because of the line (in CMakeLists.txt):

INSTALL(RUNTIME_DEPENDENCY_SET runtime ...

Because of this, the installer is overweight. We need to leave dylib's only and delete headers. But without this line, you will have to search and copy all the files manually (this is how the Windows build is currently designed). I'm not a macos programmer and I have no idea how to fix this. For example, I don't know where the original files might be located when copying manually. It was just the first solution I found on Google.

P.S.
Maybe we'll set up auto-build and not ask anyone else to help. But @zvezdochiot is a Linux user, and I am a Windows user. We cannot test the functionality of the build.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants