Shiboken2 qobject.h:46:10: fatal: 'QtCore/qobjectdefs.h' file not found

407 views Asked by At

I'm trying to create a Python binding for a Qt C++ class with Shiboken2. As far as I can tell, there's no official example on how to do so (the only example on the Qt Blog deals with a generic C++ class https://www.qt.io/blog/2018/05/31/write-python-bindings). So I'm following this blog post instead: https://blog.basyskom.com/2019/using-shiboken2-to-create-python-bindings-for-a-qt-library/

The example works on Linux, but Shiboken2 fails to build on a Mac with the error qobject.h:46:10: fatal: 'QtCore/qobjectdefs.h' file not found

This is a log of what happens:

(pyside2build) MacBook-Pro-i7:build andreac$ cmake ..
-- The C compiler identification is AppleClang 11.0.0.11000033
-- The CXX compiler identification is AppleClang 11.0.0.11000033
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- QtCore include folders: /Users/andreac/Qt/5.12.6/clang_64/lib/QtCore.framework;/Users/andreac/Qt/5.12.6/clang_64/lib/QtCore.framework/Headers;/Users/andreac/Qt/5.12.6/clang_64/.//mkspecs/macx-clang
-- Using python interpreter: /Users/andreac/pyside2build/bin/python
-- Found Python3: /Users/andreac/pyside2build/bin/python3.7 (found version "3.7.5") found components:  Interpreter Development 
-- Using PySide2 installation: /Users/andreac/pyside2build/lib/python3.7/site-packages/PySide2
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/andreac/pyside2build/src/binding-example/build
(pyside2build) MacBook-Pro-i7:build andreac$ make
Scanning dependencies of target libexamplebinding_autogen
[  9%] Automatic MOC for target libexamplebinding
[  9%] Built target libexamplebinding_autogen
Scanning dependencies of target libexamplebinding
[ 18%] Building CXX object CMakeFiles/libexamplebinding.dir/libexamplebinding_autogen/mocs_compilation.cpp.o
[ 27%] Building CXX object CMakeFiles/libexamplebinding.dir/qobjectwithenum.cpp.o
[ 36%] Linking CXX shared library libexamplebinding.dylib
[ 36%] Built target libexamplebinding
Scanning dependencies of target Shiboken2QtExample_autogen
[ 45%] Running generator for /Users/andreac/pyside2build/src/binding-example/bindings.xml.
(bindings) clang_parseTranslationUnit2(0x0, cmd[17]=-nostdinc -isystem/opt/X11/include -isystem/usr/local/include -isystem/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1 -isystem/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/11.0.0/include -isystem/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include -isystem/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -iframework/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks -fPIC -Wno-expansion-to-defined -Wno-constant-logical-operand -std=c++14 -I/Users/andreac/Qt/5.12.6/clang_64/lib/QtCore.framework -I/Users/andreac/Qt/5.12.6/clang_64/lib/QtCore.framework/Headers -I/Users/andreac/Qt/5.12.6/clang_64/mkspecs/macx-clang -I/Users/andreac/pyside2build/src/binding-example /private/var/folders/8v/8h2g7jz573g9rlwyp4zh87qm0000gn/T/bindings_eyZJOr.hpp)
/Users/andreac/Qt/5.12.6/clang_64/lib/QtCore.framework/Headers/qobject.h:46:10: fatal error: 'QtCore/qobjectdefs.h' file not found
(bindings) Errors in /private/var/folders/8v/8h2g7jz573g9rlwyp4zh87qm0000gn/T/bindings_eyZJOr.hpp:
/Users/andreac/Qt/5.12.6/clang_64/lib/QtCore.framework/Headers/qobject.h:46:10: fatal: 'QtCore/qobjectdefs.h' file not found
   /private/var/folders/8v/8h2g7jz573g9rlwyp4zh87qm0000gn/T/bindings_eyZJOr.hpp:1:10: note: in file included from /private/var/folders/8v/8h2g7jz573g9rlwyp4zh87qm0000gn/T/bindings_eyZJOr.hpp:1:
   /Users/andreac/pyside2build/src/binding-example/bindings.h:3:10: note: in file included from /Users/andreac/pyside2build/src/binding-example/bindings.h:3:
   /Users/andreac/pyside2build/src/binding-example/qobjectwithenum.h:2:10: note: in file included from /Users/andreac/pyside2build/src/binding-example/qobjectwithenum.h:2:
   /Users/andreac/Qt/5.12.6/clang_64/lib/QtCore.framework/Headers/QObject:1:10: note: in file included from /Users/andreac/Qt/5.12.6/clang_64/lib/QtCore.framework/Headers/QObject:1:


(bindings) Clang: 1 diagnostic messages:
  /Users/andreac/Qt/5.12.6/clang_64/lib/QtCore.framework/Headers/qobject.h:46:10: fatal: 'QtCore/qobjectdefs.h' file not found
   /private/var/folders/8v/8h2g7jz573g9rlwyp4zh87qm0000gn/T/bindings_eyZJOr.hpp:1:10: note: in file included from /private/var/folders/8v/8h2g7jz573g9rlwyp4zh87qm0000gn/T/bindings_eyZJOr.hpp:1:
   /Users/andreac/pyside2build/src/binding-example/bindings.h:3:10: note: in file included from /Users/andreac/pyside2build/src/binding-example/bindings.h:3:
   /Users/andreac/pyside2build/src/binding-example/qobjectwithenum.h:2:10: note: in file included from /Users/andreac/pyside2build/src/binding-example/qobjectwithenum.h:2:
   /Users/andreac/Qt/5.12.6/clang_64/lib/QtCore.framework/Headers/QObject:1:10: note: in file included from /Users/andreac/Qt/5.12.6/clang_64/lib/QtCore.framework/Headers/QObject:1:


Keeping temporary file: /private/var/folders/8v/8h2g7jz573g9rlwyp4zh87qm0000gn/T/bindings_eyZJOr.hpp
shiboken: Error running ApiExtractor.
Command line: --generator-set=shiboken --enable-parent-ctor-heuristic --enable-return-value-heuristic --use-isnull-as-nb_nonzero --avoid-protected-hack -I/Users/andreac/Qt/5.12.6/clang_64/lib/QtCore.framework -I/Users/andreac/Qt/5.12.6/clang_64/lib/QtCore.framework/Headers -I/Users/andreac/Qt/5.12.6/clang_64/.//mkspecs/macx-clang -T/Users/andreac/Qt/5.12.6/clang_64/lib/QtCore.framework -T/Users/andreac/Qt/5.12.6/clang_64/lib/QtCore.framework/Headers -T/Users/andreac/Qt/5.12.6/clang_64/.//mkspecs/macx-clang -I/Users/andreac/pyside2build/src/binding-example -T/Users/andreac/pyside2build/src/binding-example --output-directory=/Users/andreac/pyside2build/src/binding-example/build /Users/andreac/pyside2build/src/binding-example/bindings.h /Users/andreac/pyside2build/src/binding-example/bindings.xml
make[2]: *** [Shiboken2QtExample/qobjectwithenum_wrapper.cpp] Error 1
make[1]: *** [CMakeFiles/Shiboken2QtExample_autogen.dir/all] Error 2
make: *** [all] Error 2

Any ideas on how to fix the problem?

1

There are 1 answers

0
Wolfy On

It looks like I need to use the -F option for Shiboken2 to specify the location of a Framework. Adding the following to the invocation command solves the issue:

-F/Users/andreac/Qt/5.12.6/clang_64/lib/