为什么Clang在OSX上构建时不会为这个Qt项目生成TARGET目录? [英] Why doesn't Clang generate the TARGET directory for this Qt project when building on OSX?

查看:318
本文介绍了为什么Clang在OSX上构建时不会为这个Qt项目生成TARGET目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用以下工具链的项目(此处的完整代码):

I have a project (full code here) that uses the following toolchain:


  • OSX 10.10.5(Yosemite)

  • C ++ 11(似乎仍然比C + +14)

  • Qt 5.5.0(跨平台GUI库)

  • Qt Creator 3.5.0(与Qt紧密集成的IDE)

  • QMake(与Qt紧密集成的构建工具)

  • Clang 6.0 64位(在OSX上使用Qt Creator时默认编译器) li>
  • Xcode 6.1.1(另一个用于OSX的IDE,Clang似乎与其捆绑在一起)

  • OSX 10.10.5 (Yosemite)
  • C++11 (still seems to have better compiler support than C++14)
  • Qt 5.5.0 (cross-platform GUI library)
  • Qt Creator 3.5.0 (IDE which is tightly integrated with Qt)
  • QMake (build tool which is tightly integrated with Qt)
  • Clang 6.0 64-bit (default compiler when using Qt Creator on OSX)
  • Xcode 6.1.1 (another IDE for OSX which Clang appears to be bundled with)

问题发生时,我试图建立项目。值得注意的是,当我使用Windows 7而不是OSX和MingW / GCC而不是Xcode / Clang时,完全相同的代码和项目文件编译和链接没有任何错误或警告。还值得注意的是,这个完全相同的工具集在我最后一次在我的OSX机器上开发时,正在做一些提交。如果我不得不猜测,我会说,添加CONFIG + = c ++ 11行到我的项目文件是什么触发的问题(无法删除这个现在不会导致其他问题)。下面是一个输出示例:

The problem occurs when I attempt to build the project. It's worth noting that the exact same code and project file compile and link without any errors or warnings when I use Windows 7 instead of OSX and MingW/GCC instead of Xcode/Clang. It's also worth noting that this exact same toolset was working a few commits ago when I was last developing on my OSX machine. If I had to guess, I'd say adding the "CONFIG += c++11" line to my project file is what triggered the issue (unable to remove this now without causing other issues). Here is an example of the output:

09:06:44: Running steps for project AISweeper...
09:06:44: Starting: "/usr/bin/make" clean
rm -f qrc_sweeper_resources.cpp
rm -f moc_player_abstract.cpp moc_player_human.cpp moc_player_machine_learning_ai.cpp moc_player_probability_based_ai.cpp moc_player_random_action_ai.cpp moc_sweeper_batch_manager.cpp moc_sweeper_batch_settings.cpp moc_sweeper_batch_status.cpp moc_sweeper_control_window.cpp moc_sweeper_game.cpp moc_sweeper_widget.cpp
rm -f ui_sweeper_control_window.h
rm -f player_abstract.o player_human.o player_machine_learning_ai.o player_probability_based_ai.o player_random_action_ai.o sweeper_batch_manager.o sweeper_batch_settings.o sweeper_batch_status.o sweeper_common_functions.o sweeper_control_window.o sweeper_game.o sweeper_main.o sweeper_model.o sweeper_node.o sweeper_widget.o qrc_sweeper_resources.o moc_player_abstract.o moc_player_human.o moc_player_machine_learning_ai.o moc_player_probability_based_ai.o moc_player_random_action_ai.o moc_sweeper_batch_manager.o moc_sweeper_batch_settings.o moc_sweeper_batch_status.o moc_sweeper_control_window.o moc_sweeper_game.o moc_sweeper_widget.o
rm -f *~ core *.core
09:06:44: The process "/usr/bin/make" exited normally.
09:06:44: Configuration unchanged, skipping qmake step.
09:06:44: Starting: "/usr/bin/make"
/Users/alexjohnson/Qt/5.5/clang_64/bin/uic ../AISweeper/ui/sweeper_control_window.ui -o ui_sweeper_control_window.h
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -c -pipe -g -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk -std=c++11 -stdlib=libc++ -mmacosx-version-min=10.7 -Wall -W -fPIC -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../AISweeper -I. -I../../../Qt/5.5/clang_64/lib/QtWidgets.framework/Headers -I../../../Qt/5.5/clang_64/lib/QtGui.framework/Headers -I../../../Qt/5.5/clang_64/lib/QtCore.framework/Headers -I. -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/OpenGL.framework/Headers -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/AGL.framework/Headers -I. -I../../../Qt/5.5/clang_64/mkspecs/macx-clang -F/Users/alexjohnson/Qt/5.5/clang_64/lib -o player_abstract.o ../AISweeper/src/players/player_abstract.cpp
   *snip*
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -c -pipe -g -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk -std=c++11 -stdlib=libc++ -mmacosx-version-min=10.7 -Wall -W -fPIC -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../AISweeper -I. -I../../../Qt/5.5/clang_64/lib/QtWidgets.framework/Headers -I../../../Qt/5.5/clang_64/lib/QtGui.framework/Headers -I../../../Qt/5.5/clang_64/lib/QtCore.framework/Headers -I. -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/OpenGL.framework/Headers -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/AGL.framework/Headers -I. -I../../../Qt/5.5/clang_64/mkspecs/macx-clang -F/Users/alexjohnson/Qt/5.5/clang_64/lib -o moc_sweeper_game.o moc_sweeper_game.cpp
/Users/alexjohnson/Qt/5.5/clang_64/bin/moc -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -D__APPLE__ -D__GNUC__=4 -D__APPLE_CC__ -I/Users/alexjohnson/Qt/5.5/clang_64/mkspecs/macx-clang -I/Users/alexjohnson/WORKSPACE_ASJ/GitHub/AISweeper -I/Users/alexjohnson/Qt/5.5/clang_64/lib/QtWidgets.framework/Headers -I/Users/alexjohnson/Qt/5.5/clang_64/lib/QtGui.framework/Headers -I/Users/alexjohnson/Qt/5.5/clang_64/lib/QtCore.framework/Headers -I. -F/Users/alexjohnson/Qt/5.5/clang_64/lib ../AISweeper/inc/sweeper_widget.h -o moc_sweeper_widget.cpp
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -c -pipe -g -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk -std=c++11 -stdlib=libc++ -mmacosx-version-min=10.7 -Wall -W -fPIC -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../AISweeper -I. -I../../../Qt/5.5/clang_64/lib/QtWidgets.framework/Headers -I../../../Qt/5.5/clang_64/lib/QtGui.framework/Headers -I../../../Qt/5.5/clang_64/lib/QtCore.framework/Headers -I. -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/OpenGL.framework/Headers -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/AGL.framework/Headers -I. -I../../../Qt/5.5/clang_64/mkspecs/macx-clang -F/Users/alexjohnson/Qt/5.5/clang_64/lib -o moc_sweeper_widget.o moc_sweeper_widget.cpp
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -headerpad_max_install_names -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk -stdlib=libc++ -mmacosx-version-min=10.7 -Wl,-rpath,/Users/alexjohnson/Qt/5.5/clang_64/lib -o AISweeper.app/Contents/MacOS/AISweeper AISweeper player_abstract.o player_human.o player_machine_learning_ai.o player_probability_based_ai.o player_random_action_ai.o sweeper_batch_manager.o sweeper_batch_settings.o sweeper_batch_status.o sweeper_common_functions.o sweeper_control_window.o sweeper_game.o sweeper_main.o sweeper_model.o sweeper_node.o sweeper_widget.o qrc_sweeper_resources.o moc_player_abstract.o moc_player_human.o moc_player_machine_learning_ai.o moc_player_probability_based_ai.o moc_player_random_action_ai.o moc_sweeper_batch_manager.o moc_sweeper_batch_settings.o moc_sweeper_batch_status.o moc_sweeper_control_window.o moc_sweeper_game.o moc_sweeper_widget.o   -F/Users/alexjohnson/Qt/5.5/clang_64/lib -stdlib=libc++ -framework QtWidgets -framework QtGui -framework QtCore -framework DiskArbitration -framework IOKit -framework OpenGL -framework AGL
clang: error: no such file or directory: 'AISweeper'
make: *** [AISweeper.app/Contents/MacOS/AISweeper] Error 1
09:07:03: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project AISweeper (kit: Desktop Qt 5.5.0 clang 64bit)
When executing step "Make"
09:07:03: Elapsed time: 00:19.

我很难解释所有这些,但我相信这意味着Clang没能在生成的应用程序中链接(因此所有的.o文件)时找到'AISweeper'目录。这似乎是由QMake项目文件中的TARGET变量控制的。如果我将此变量从'AISweeper'更改为'Foo',那么它无法找到'Foo'目录。手动检查生成的应用程序后,我可以确认/Users/alexjohnson/WORKSPACE_ASJ/GitHub/build-AISweeper-Desktop_Qt_5_5_0_clang_64bit-Debug/AISweeper.app/Contents/MacOS/存在,但在其中没有AISweeper目录它。我不知道如何确保它作为构建过程的一部分存在。我也试过放弃Clang和切换到GCC,但这导致C ++ 11,OSX和Qt之间的不兼容问题。我试过Googling的问题,但大多数时候,这个错误似乎发生时,Clang找不到第三方库。在我的情况下,它似乎找不到我的项目目录本身。我确实看到一些提到在Xcode中打开项目,并修改一些设置,但我无法直接用Xcode打开我的项目或找到任何提到的设置。这里是我的QMake项目文件(AISweeper.pro)的内容,如果有其他我应该尝试修改在这里:

I'm having a hard time interpreting all of this, but I believe this means Clang is failing to find the 'AISweeper' directory inside the generated app while linking (hence all the .o files mentioned). This seems to be controlled by the TARGET variable in the QMake project file. If I change this variable from 'AISweeper' to 'Foo' then it fails to find the 'Foo' directory. After manually checking the generated app I can confirm that "/Users/alexjohnson/WORKSPACE_ASJ/GitHub/build-AISweeper-Desktop_Qt_5_5_0_clang_64bit-Debug/AISweeper.app/Contents/MacOS/" exists, but that there is no 'AISweeper' directory inside of it. I'm not sure how to ensure it exists as part of the build process. I've also tried abandoning Clang and switching to GCC, but this led to incompatibility issues between C++11, OSX, and Qt. I've tried Googling the issue, but most of the time this error seems to occur when Clang can't find third party libraries. In my case it can't seem to find my project directory itself. I did see some mention of opening the project in Xcode and modifying some settings there, but I couldn't open my project directly with Xcode or find any of the settings mentioned. Here are the contents of my QMake project file (AISweeper.pro) in case there's something else I should try modifying in here:

CONFIG += \
c++11

FORMS += \
ui/sweeper_control_window.ui

HEADERS += \
inc/players/player_abstract.h \
inc/players/player_human.h \
inc/players/player_machine_learning_ai.h \
inc/players/player_probability_based_ai.h \
inc/players/player_random_action_ai.h \
inc/sweeper_batch_manager.h \
inc/sweeper_batch_settings.h \
inc/sweeper_batch_status.h \
inc/sweeper_common_functions.h \
inc/sweeper_control_window.h \
inc/sweeper_game.h \
inc/sweeper_model.h \
inc/sweeper_node.h \
inc/sweeper_widget.h

QT += \
core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

LIBS += \
-stdlib=libc++

RESOURCES += \
rsc/sweeper_resources.qrc

SOURCES += \
src/players/player_abstract.cpp \
src/players/player_human.cpp \
src/players/player_machine_learning_ai.cpp \
src/players/player_probability_based_ai.cpp \
src/players/player_random_action_ai.cpp \
src/sweeper_batch_manager.cpp \
src/sweeper_batch_settings.cpp \
src/sweeper_batch_status.cpp \
src/sweeper_common_functions.cpp \
src/sweeper_control_window.cpp \
src/sweeper_game.cpp \
src/sweeper_main.cpp \
src/sweeper_model.cpp \
src/sweeper_node.cpp \
src/sweeper_widget.cpp

TARGET += \
AISweeper

TEMPLATE += \
app

我还能做些什么来解决这个问题?我只想让这些工具相互之间和我的项目建立起来很好,我可以回到编码!

What else can I try doing to resolve this? I just want these tools to play nice with each other and my project to build so I can get back to coding!

推荐答案

通过在我的项目文件中将TARGET + =更改为TARGET =来解决这个问题。这似乎很奇怪,我重新包括'+'字符,清理,并重建项目,以确保'+'字符真的导致了问题。它再次开始失败。我第二次取出它,清洗,并重新重建。它已经开始工作了。

I solved this by changing "TARGET +=" to "TARGET =" in my project file. This seemed so strange that I re-included the '+' character, cleaned, and rebuilt the project to make sure that the '+' character had really caused the issue. It started failing again. I removed it a second time, cleaned, and rebuilt again. It started working again.

正如我在问题中提到的,这在我的Windows机器上没有任何变化(包括'+'字符)。

As I mentioned in the question this has been working on my Windows machine without any changes ('+' character included).

我不完全理解QMake进程,但似乎在某些时候Clang必须试图解析项目文件本身,并以GCC不这样做的方式失败。人们会认为项目文件中的所有变量都会以同样的方式处理(IE:你可以使用+ =添加,即使只有一个条目),但似乎有一些奇怪的方式TARGET变量被具体处理。这可能是Clang或Qt Creator中的错误,但我不能确定,因此我不会报告任何内容。

I don't fully understand the QMake process, but it seems that at some point Clang must be trying to parse the project file itself and fails in a way that GCC does not. One would think that all of the variables in the project file would be treated the same way (IE: you can use += to add to them, even if there's only a single entry), but there appears to be something strange in the way the TARGET variable is treated specifically. This may be a bug in either Clang or Qt Creator, but I can't be certain, so I'm not going to report anything yet.

我会非常感兴趣听到这种行为的更深层次的解释!

I'd be quite interested in hearing a deeper explanation for this behavior!

这篇关于为什么Clang在OSX上构建时不会为这个Qt项目生成TARGET目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆