colmap icon indicating copy to clipboard operation
colmap copied to clipboard

QAction Error on M3 Mac during ninja build

Open houyongkuo opened this issue 10 months ago • 2 comments

Hello, I'm a Mac with an M3 chip. When I run "ninja", I encounter an error related to QAction:

In file included from /opt/homebrew/opt/qt@5/lib/QtWidgets.framework/Headers/qaction.h:46:
/opt/homebrew/include/QtWidgets/qwidget.h:577:26: error: incomplete type 'QAction' named in nested name specifier
  577 |         connect(result, &QAction::triggered, std::forward<Args>(args)...);
      |                          ^~~~~~~~~
/opt/homebrew/include/QtWidgets/qwidget.h:36:7: note: forward declaration of 'QAction'
   36 | class QAction;
      |       ^
/opt/homebrew/include/QtWidgets/qwidget.h:584:26: error: incomplete type 'QAction' named in nested name specifier
  584 |         connect(result, &QAction::triggered, std::forward<Args>(args)...);
      |                          ^~~~~~~~~
/opt/homebrew/include/QtWidgets/qwidget.h:36:7: note: forward declaration of 'QAction'
   36 | class QAction;
      |       ^
/opt/homebrew/include/QtWidgets/qwidget.h:602:26: error: incomplete type 'QAction' named in nested name specifier
  602 |         connect(result, &QAction::triggered, std::forward<Args>(args)...);
      |                          ^~~~~~~~~
/opt/homebrew/include/QtWidgets/qwidget.h:36:7: note: forward declaration of 'QAction'
   36 | class QAction;
      |       ^
/opt/homebrew/include/QtWidgets/qwidget.h:609:26: error: incomplete type 'QAction' named in nested name specifier
  609 |         connect(result, &QAction::triggered, std::forward<Args>(args)...);
      |                          ^~~~~~~~~
/opt/homebrew/include/QtWidgets/qwidget.h:36:7: note: forward declaration of 'QAction'
   36 | class QAction;
      |       ^
4 errors generated.
[10/53] Building CXX object src/colmap/exe/CMakeFiles/colmap_exe.dir/model.cc.o
ninja: build stopped: subcommand failed.

houyongkuo avatar Mar 08 '25 10:03 houyongkuo

After digging deeper I found out that it's due to the fact that other projects use PCL, opencv and other dependencies that have to use qt@6, which may conflict with colmap's dependency on qt@5.

houyongkuo avatar Mar 12 '25 03:03 houyongkuo

For anyone interested in how to solve: Make sure Qt 5 is installed:

brew install qt@5

Temporarily unlink any other Qt version and link Qt 5:

brew unlink qt        # this is Qt 6
brew link --overwrite --force qt@5

Start from a clean build directory and point CMake at Qt 5 explicitly: From app root dir:

rm -rf build && mkdir build && cd build
cmake .. -GNinja \
  -DCMAKE_PREFIX_PATH="$(brew --prefix qt@5)" \
  -DQt5_DIR="$(brew --prefix qt@5)/lib/cmake/Qt5"
ninja

Good luck

Galaxy83 avatar Aug 01 '25 09:08 Galaxy83