qbs.h 在 Mac 从源代码编译 Qt Creator 4.7.0 时未找到

qbs.h not found while compiling Qt Creator 4.7.0 from source on Mac

我正在尝试从以下存储库中的 MacOS 10.13 源代码编译 Qt Creator: https://github.com/qt-creator/qt-creator

我按照 README.md 中的说明进行操作,但没有成功。 很可能我错过了什么。

我完成的步骤:

从该目录 运行 以下命令:

export LLVM_INSTALL_DIR=/usr/local/opt/llvm
export QBS_INSTALL_DIR=/usr/local/opt/qbs

PATH=/usr/local/opt/qt/bin:/usr/local/opt/llvm/bin:$PATH

qmake -r /Users/username/builds/qtcreator_src/4.7 
    make

编译大约 40 分钟后,出现以下错误:

../../../../qtcreator_src/4.7/src/plugins/qbsprojectmanager/customqbspropertiesdialog.cpp:29:10: fatal error: 'qbs.h' file not found
#include <qbs.h>

(我检查过该文件存在于 /usr/local/opt/qbs/include/qbs 目录中)。

还有一个问题。如果我使用 make -j8,那会加快构建过程,但随后 我最终遇到以下晦涩的错误:

mv -f libDebugger.dylib ../../../bin/Qt\ Creator.app/Contents/PlugIns/ 
make[1]: *** [sub-plugins-make_first-ordered] Error 2

我在上面的控制台输出中找不到其他错误消息,也找不到 任何 error.log 个文件。

P.S。以下是来自 github README.md:

的原始构建说明
# Optional, needed for the Clang Code Model if llvm-config is not in PATH:
export LLVM_INSTALL_DIR=/path/to/llvm (or "set" on Windows)
# Optional, needed to let the QbsProjectManager plugin use system Qbs:
export QBS_INSTALL_DIR=/path/to/qbs
# Optional, needed for the Python enabled dumper on Windows
set PYTHON_INSTALL_DIR=C:\path\to\python

cd $SOURCE_DIRECTORY
qmake -r
make (or mingw32-make or nmake or jom, depending on your platform)

不需要安装("make install")。然而,使用

是可能的
make install INSTALL_ROOT=$INSTALL_DIRECTORY

更新 2: 从 PATH 中排除 Qt 后,我​​收到另一个错误:

In file included from ../../../../qtcreator_src/4.7/src/plugins/qbsprojectmanager/customqbspropertiesdialog.cpp:29:
/usr/local/Cellar/qbs/1.12.0/include/qbs/qbs.h:63:10: fatal error: 
      'tools/settingsrepresentation.h' file not found
#include "tools/settingsrepresentation.h"

更新 3:我设法使用从构建目录发出的以下命令构建了 Qt Creator:

export LLVM_INSTALL_DIR=/usr/local/opt/llvm
/usr/local/opt/qt/bin/qmake /Users/username/builds/qtcreator_src/4.7
make

但是即使构建过程没有错误地完成,应用程序也没有 运行:

Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:       EXC_I386_GPFLT
Exception Note:        EXC_CORPSE_NOTIFY

Termination Signal:    Segmentation fault: 11
Termination Reason:    Namespace SIGNAL, Code 0xb
Terminating Process:   exc handler [0]

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   libBookmarks.dylib              0x0000000115166cb0 Bookmarks::Internal::BookmarksPlugin::~BookmarksPlugin() + 32
1   libExtensionSystem.4.7.0.dylib  0x000000010b58b3eb ExtensionSystem::Internal::PluginSpecPrivate::kill() + 27
2   libExtensionSystem.4.7.0.dylib  0x000000010b576778 ExtensionSystem::Internal::PluginManagerPrivate::loadPlugins() + 888
3   org.qt-project.qtcreator        0x000000010b558159 main + 13353
4   libdyld.dylib                   0x00007fff7e352115 start + 1

Qt 肯定不应该在路径中——它是多余的。你可以有多个 Qt 版本共存,它们是通过调用各自的 qmake 来选择的。 LLVM 是否应该——不确定。 qmake 的 -r 选项是针对项目模式的,不需要。

cd build_dir
/qt/bin/qmake /path/to/sources
make

使用 qbs 的全部意义在于,您只需将 qmake+make 替换为 qbs。首先告诉 qbs 你想使用的 Qt 版本(只做一次):

qbs setup-qt /qt/bin/qmake myqt
qbs config defaultProfile myqt

当然myqt可以随心所欲。

然后构建创建者:

cd build_dir
qbs -f /path/to/sources