简体   繁体   English

Qt 不在 Linux 的调试/发布文件夹中创建输出文件

[英]Qt does not create output files in debug/release folders in Linux

When I build Qt applications on Ubuntu it puts the output files in the main solution folder as opposed to release/debug folders as it does on Windows.当我在 Ubuntu 上构建 Qt 应用程序时,它将输出文件放在主解决方案文件夹中,而不是像在 Windows 上那样放在发布/调试文件夹中。

This is problematic because sometimes the output files need to be run as part of the build process (for example to run unit tests).这是有问题的,因为有时输出文件需要作为构建过程的一部分运行(例如运行单元测试)。

I have an idea this has something to do with the qmake.conf files but I'm unsure what to do about it.我有一个想法,这与 qmake.conf 文件有关,但我不确定该怎么做。

So my questions are:所以我的问题是:

  1. Why does this difference exist (could it just be me?)为什么存在这种差异(可能只是我?)
  2. How should I go about making sure my applications will build correctly on both Windows and Ubuntu?我应该如何确保我的应用程序可以在 Windows 和 Ubuntu 上正确构建?

The CONFIG variable has debug_and_release and debug_and_release_target set on windows, but not on linux. CONFIG变量在 Windows 上设置了debug_and_releasedebug_and_release_target ,但在 linux 上没有。 So the following line will make sure that your build will be the same on linux and windows:因此,以下行将确保您的构建在 linux 和 windows 上相同:

CONFIG *= debug_and_release debug_and_release_target

The documentation shortly mentions it. 文档很快就提到了它。 The file /usr/share/qt4/mkspecs/win32-g++/qmake.conf adds it to CONFIG .文件/usr/share/qt4/mkspecs/win32-g++/qmake.conf将其添加到CONFIG

I assume you're using qmake to do the actual building.我假设您正在使用 qmake 进行实际构建。 You can edit the project files to put the output in different directories like this:您可以编辑项目文件以将输出放在不同的目录中,如下所示:

# only for unix:
unix {
    # in debug mode...
    CONFIG(debug, debug|release) {
        DESTDIR = debug
    }
    else {
        DESTDIR = release
    }
}

Obviously in order for this to work you need to be building both debug and release executables.显然,为了使其工作,您需要同时构建调试和发布可执行文件。 More information on this topic can be found here可以在此处找到有关此主题的更多信息

Cheers干杯

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM