qt moc error:usr/include/c++/10/bits/fs_fwd.:39: Parse error at "std"
-
my configuration is:
ubuntu 21.04 gcc 11 qt 5.15.2
and error message like this:
AutoMoc subprocess error ------------------------ The moc process failed to compile "SRC:/src/Layers/ViewLayer/Process/NearFieldProcessUtil.h" into "SRC:/build/MTESS_autogen/MLM4FWGUYC/moc_NearFieldProcessUtil.cpp" Command ------- /usr/lib/qt5/bin/moc -DJSON_DIAGNOSTICS=0 -DJSON_USE_IMPLICIT_CONVERSIONS=1 "-DvtkRenderingCore_AUTOINIT_INCLUDE=\"/home/alex/workspace/mtess/MTESS/build/CMakeFiles/vtkModuleAutoInit_be7301261a49b13d6a9b1d9e110eacd8.h\"" -I/home/alex/workspace/mtess/MTESS/src -I/home/alex/workspace/mtess/MTESS/vendor/ProjectStructure -I/home/alex/workspace/mtess/MTESS/vendor/imgui -I/home/alex/workspace/mtess/MTESS/vendor/imgui/imgui -I/usr/include/x86_64-linux-gnu/qt5 -I/usr/local/qwt-6.2.0/include -I/usr/local/include/opencascade -I/lib -I/usr/local/include -I/usr/include/vtk-9.0 -I/usr/include/c++/10 -I/usr/include -I/usr/include/c++/11 -I/usr/include/x86_64-linux-gnu/c++/11 -I/usr/include/c++/11/backward -I/usr/lib/llvm-14/lib/clang/14.0.0/include -I/usr/include/x86_64-linux-gnu --include /home/alex/workspace/mtess/MTESS/build/MTESS_autogen/moc_predefs.h --output-dep-file -o /home/alex/workspace/mtess/MTESS/build/MTESS_autogen/MLM4FWGUYC/moc_NearFieldProcessUtil.cpp /home/alex/workspace/mtess/MTESS/src/Layers/ViewLayer/Process/NearFieldProcessUtil.h Output ------ usr/include/c++/10/bits/fs_fwd.:39: Parse error at "std"
The same codebase compiled successfully in windows with qmake,and I am converting compilaltion approch to cmake,and it shouldn't be a code problem,but a cmake configuration or tool chain compatibility problem.My questions are:
-
How to let cmake use the only one includes of specific compiler?
As you can see,it seems like 3 includes of gcc-10,gcc-11,clang-14 are all being used.I have tried to uninstalled gcc-10 but clang-14 depends on it,and I have used update-alternatives to specify gcc,g++,clang and clang++.
-
How to debug this kind of standard library moc parsing problem?
I have met the similar MOC parsing problem before,not on usr/include/c++/10/bits/fs_fwd.:39,but another gcc header file,after some uninstalling/installing,that problem gone,but actually I don't know how is gone.This type of problem maybe kind of general,any method to troubleshoot them?
-
-
@Alex-Luya said in qt moc error:usr/include/c++/10/bits/fs_fwd.:39: Parse error at "std":
usr/include/c++/10/bits/fs_fwd.:39: Parse error at "std"
https://bugreports.qt.io/browse/QTBUG-73263
https://www.logikalsolutions.com/wordpress/information-technology/moc-parse-error-at-std/ -
@JoeCFD Thanks,I have all qmake.stash deleted,but the problem remains,and I noticed complete moc statement got printed out like this:
/usr/lib/qt5/bin/moc -DJSON_DIAGNOSTICS=0 -DJSON_USE_IMPLICIT_CONVERSIONS=1 "-DvtkRenderingCore_AUTOINIT_INCLUDE=\"/home/alex/workspace/MTESS/build/CMakeFiles/vtkModuleAutoInit_be7301261a49b13d6a9b1d9e110eacd8.h\"" -I/home/alex/workspace/MTESS/src -I/home/alex/workspace/MTESS/vendor/ProjectStructure -I/home/alex/workspace/MTESS/vendor/imgui -I/home/alex/workspace/MTESS/vendor/imgui/imgui -I/usr/include/x86_64-linux-gnu/qt5 -I/usr/local/qwt-6.2.0/include -I/usr/local/include/opencascade -I/lib -I/usr/local/include -I/usr/include/c++/11 -I/usr/include/x86_64-linux-gnu/c++/11 -I/usr/include/c++/11/backward -I/usr/lib/llvm-14/lib/clang/14.0.0/include -I/usr/include/x86_64-linux-gnu -I/usr/include --include /home/alex/workspace/MTESS/build/MTESS_autogen/moc_predefs.h --output-dep-file -o /home/alex/workspace/MTESS/build/MTESS_autogen/MLM4FWGUYC/moc_NearFieldProcessUtil.cpp /home/alex/workspace/MTESS/src/Layers/ViewLayer/Process/NearFieldProcessUtil.h
And copy this to run in bash,it will give:
usr/include/c++/11/bits/fs_fwd.:39: Parse error at "std"
If removing:
-I/usr/local/include -I/usr/include/c++/11 -I/usr/include/x86_64-linux-gnu/c++/11 -I/usr/include/c++/11/backward
Then run:
/usr/lib/qt5/bin/moc -DJSON_DIAGNOSTICS=0 -DJSON_USE_IMPLICIT_CONVERSIONS=1 "-DvtkRenderingCore_AUTOINIT_INCLUDE=\"/home/alex/workspace/MTESS/build/CMakeFiles/vtkModuleAutoInit_be7301261a49b13d6a9b1d9e110eacd8.h\"" -I/home/alex/workspace/MTESS/src -I/home/alex/workspace/MTESS/vendor/ProjectStructure -I/home/alex/workspace/MTESS/vendor/imgui -I/home/alex/workspace/MTESS/vendor/imgui/imgui -I/usr/include/x86_64-linux-gnu/qt5 -I/usr/local/qwt-6.2.0/include -I/usr/local/include/opencascade -I/lib -I/usr/lib/llvm-14/lib/clang/14.0.0/include -I/usr/include/x86_64-linux-gnu -I/usr/include --include /home/alex/workspace/MTESS/build/MTESS_autogen/moc_predefs.h --output-dep-file -o /home/alex/workspace/MTESS/build/MTESS_autogen/MLM4FWGUYC/moc_NearFieldProcessUtil.cpp /home/alex/workspace/MTESS/src/Layers/ViewLayer/Process/NearFieldProcessUtil.h
Expected file:
moc_NearFieldProcessUtil.cpp
got generated successfully,so question becomes:
How to tell MOC to exclude gcc related includes?