简体   繁体   English

C++/编译一个程序致命错误:QtGui/qwidget.h: No such file or directory

[英]C++ / compilation of a program fatal error: QtGui/qwidget.h: No such file or directory

I've downloaded a linux application which required qt4.我已经下载了一个需要 qt4 的 linux 应用程序。 I have it already on my computer.我的电脑上已经有了。

I have this following error when I want to compile the program using make in the terminal.当我想在终端中使用make编译程序时出现以下错误。

[  6%] Building CXX object CMakeFiles/util_convert.dir/moc_planeviewer.cxx.o
In file included from /usr/include/qt4/QtGui/QMainWindow:1:0,
             from /home/Desktop/plane/src/planeviewer.h:3,
             from /home/Desktop/plane/src/moc_planeviewer.cxx:9:
/usr/include/qt4/QtGui/qmainwindow.h:45:27: fatal error: QtGui/qwidget.h: No such file or directory
 #include <QtGui/qwidget.h>
                           ^
compilation terminated.
make[2]: *** [CMakeFiles/util_convert.dir/moc_planviewer.cxx.o] Error 1
make[1]: *** [CMakeFiles/util_convert.dir/all] Error 2
make: *** [all] Error 2

I don't understand because I checked already everything.我不明白,因为我已经检查了一切。 I have the following input for those different commands line:对于这些不同的命令行,我有以下输入:

qmake --version qmake --version

QMake version 2.01a
Using Qt version 4.8.6 in /usr/lib/x86_64-linux-gnu

locate qwidget.h找到 qwidget.h

/opt/qt/5.4/android_armv7/include/QtWidgets/qwidget.h
/opt/qt/5.4/gcc_64/include/QtWidgets/qwidget.h
/usr/include/qt4/Qt/qwidget.h
/usr/include/qt4/QtGui/qwidget.h

So the file already exists.所以文件已经存在。

The CmakeList in case CmakeList 以防万一

find_package(Boost 1.58 REQUIRED COMPONENTS serialization program_options python)
find_package(PythonLibs 2.6 REQUIRED)

set(QT_USE_QTSVG TRUE)
set(QT_USE_QTXML TRUE)
set(QT_USE_QTOPENGL TRUE)
find_package(OpenGL)
find_package( Qt4 REQUIRED )

INCLUDE_DIRECTORIES("${Boost_INCLUDE_DIRS}")
INCLUDE_DIRECTORIES("${PYTHON_INCLUDE_PATH}")
INCLUDE_DIRECTORIES(${QT_QTCORE_INCLUDE_DIR} ${QT_QTGUI_INCLUDE_DIR} ${QT_QTSVG_INCLUDE_DIR}
                    ${QT_QTXML_INCLUDE_DIR} ${QT_QTOPENGL_INCLUDE_DIR} ${OPENGL_INCLUDE_DIRS})

QT4_WRAP_UI(util_convert_FORMS planeviewer.ui)
QT4_WRAP_CPP(util_convert_MOCS planeviewer.h planewidget.h)
ADD_EXECUTABLE(util_convert ${util_convert_FORMS} ${util_convert_MOCS} plane.cpp util_convert.cpp planeviewer.cpp planewidget.cpp objects.cpp coordinates.cpp utils.cpp)
TARGET_LINK_LIBRARIES(util_convert ${Boost_LIBRARIES} ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTSVG_LIBRARY}
                                  ${QT_QTXML_LIBRARY} ${QT_QTOPENGL_LIBRARY} ${OPENGL_LIBRARIES})

How I compile :我如何编译

Go to src/ then do cmake .转到 src/ 然后执行cmake 。 and finally make .最后制作 The error happened at the make step.错误发生在 make 步骤。

Before posting this, I already searched on the internet but didn't find a solution yet.在发布之前,我已经在互联网上搜索过,但还没有找到解决方案。

Can someone helps me ?有人可以帮助我吗?

The problem is in INCLUDE_DIRECTORIES .问题出在INCLUDE_DIRECTORIES I think that in your example QT_QTGUI_INCLUDE_DIR variable has value /usr/include/qt4/QtGui , but you need add /usr/include/qt4 to INCLUDE_DIRECTORIES , because in code include statement useses path <QtGui/qwidget.h> :我认为在您的示例中QT_QTGUI_INCLUDE_DIR变量具有值/usr/include/qt4/QtGui ,但您需要将/usr/include/qt4INCLUDE_DIRECTORIES ,因为在代码中包含语句使用路径<QtGui/qwidget.h>

INCLUDE_DIRECTORIES("/usr/include/qt4")

Thanks to @gomons, I was able to compile it.感谢@gomons,我能够编译它。

I added in the CmakeList the following line:我在 CmakeList 中添加了以下行:

INCLUDE_DIRECTORIES("/usr/include/qt4/")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 致命错误:QtGui / QApplication:没有这样的文件或目录 - fatal error: QtGui/QApplication: No such file or directory 致命错误:QtGui / QApplication:没有这样的文件或目录| - fatal error: QtGui/QApplication: No such file or directory| 致命错误:cuda.h:c ++没有此类文件或目录 - fatal error: cuda.h: No such file or directory for c++ cpp/c++ 编译错误:combaseapi.h - 没有那个文件或目录 - cpp/c++ compilation error: combaseapi.h - No such file or directory C++ - 致命错误:circle.h:没有这样的文件或目录 - C++ - Fatal Error: circle.h: No such file or directory c++ 致命错误:glad/gl.h:没有这样的文件或目录 - c++ fatal error: glad/gl.h: No such file or directory 致命错误:opencv / cvtypes.h:没有终止此类文件或目录的编译 - fatal error: opencv/cvtypes.h: No such file or directory compilation terminated 致命错误mysql.h:编译期间没有这样的文件或目录 - fatal error mysql.h:No such file or directory during compilation C++ 编译期间出现“没有此类文件或目录”错误 - “No such file or directory” error during C++ compilation C ++ boost / multiprecision:致命错误:mpfr.h:没有这样的文件或目录 - C++ boost/multiprecision: fatal error: mpfr.h: No such file or directory
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM