命令行编译项目时make找不到Qt头文件

发布于 2024-12-25 06:46:59 字数 1138 浏览 3 评论 0原文

我正在尝试在命令行上编译 Qt Creator 项目。这就是我所做的。

$ qmake
$ make
g++ -c -m64 -pipe -O2 -Wall -W -D_REENTRANT -DALLOWSYNCING -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I/usr/share/qt4/mkspecs/linux-g++-64 -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -o main.o main.cpp
In file included from ./model/videostream.h:4:0,
                 from ./model/videostreamersession.h:4,
                 from view/videoplayerwindow.h:4,
                 from main.cpp:3:
./model/videoframe.h:5:18: fatal error: QImage: No such file or directory
compilation terminated.
make: *** [main.o] Error 1

看起来 make 找不到 Qt 相关类的头文件。如何使用附加参数或环境变量告诉 make 在哪里可以找到它们?我注意到默认情况下包含一些搜索路径,但在我的环境中,它们位于 /opt/QtSDK/Desktop/Qt/474/gcc/include/ 中。


根据要求,我的 PRO 文件。它最初是由 Qt Creator 生成的,所以没什么特别的。

QT += core gui

TARGET = output
TEMPLATE = app

SOURCES += # Trimmed for brevity
HEADERS += # Trimmed for brevity

# Special build flags
DEFINES += ALLOWSYNCING

# These libraries are required for the program to operate
LIBS += -ljrtp -ljthread

I'm trying to compile a Qt Creator project on the command line. Here's what I did.

$ qmake
$ make
g++ -c -m64 -pipe -O2 -Wall -W -D_REENTRANT -DALLOWSYNCING -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I/usr/share/qt4/mkspecs/linux-g++-64 -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -o main.o main.cpp
In file included from ./model/videostream.h:4:0,
                 from ./model/videostreamersession.h:4,
                 from view/videoplayerwindow.h:4,
                 from main.cpp:3:
./model/videoframe.h:5:18: fatal error: QImage: No such file or directory
compilation terminated.
make: *** [main.o] Error 1

It looks like make can't find the header files for Qt-related classes. How do I tell make where it can find them using an additional parameter or environment variable? I noticed some search paths are included by default, but in my environment they're located in /opt/QtSDK/Desktop/Qt/474/gcc/include/.


As requested, my PRO file. It was initially generated by Qt Creator so it's nothing out of the ordinary.

QT += core gui

TARGET = output
TEMPLATE = app

SOURCES += # Trimmed for brevity
HEADERS += # Trimmed for brevity

# Special build flags
DEFINES += ALLOWSYNCING

# These libraries are required for the program to operate
LIBS += -ljrtp -ljthread

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

温柔一刀 2025-01-01 06:46:59

CXXFLAGS="-I/opt/QtSDK/Desktop/Qt/474/gcc/include/" CFLAGS="-I/opt/QtSDK/Desktop/Qt/474/gcc/include/" LDFLAGS="/opt/QtSDK/ Desktop/Qt/474/gcc/lib" make

但是,我猜你可能使用的是 mac。在这种情况下你应该导出QT_DIR=/opt/QtSDK/Desktop/Qt/474/,并将 /opt/QtSDK/Desktop/Qt/474/bin 添加到您的 PATH 中,一旦 qmake 运行,所有内容都将就位。

CXXFLAGS="-I/opt/QtSDK/Desktop/Qt/474/gcc/include/" CFLAGS="-I/opt/QtSDK/Desktop/Qt/474/gcc/include/" LDFLAGS="/opt/QtSDK/Desktop/Qt/474/gcc/lib" make

However, you're probably on a mac I'm guessing.. In which case you should just export QT_DIR=/opt/QtSDK/Desktop/Qt/474/, and add /opt/QtSDK/Desktop/Qt/474/bin to your PATH and that should jiggle everything into place once qmake runs.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文