[Qbs] Unwanted linkage of non-cpp product by MSVC

Christian Kandeler christian.kandeler at qt.io
Mon Oct 1 11:18:32 CEST 2018


On Sat, 22 Sep 2018 16:15:43 +0300
Павел Лысенко via Qbs <qbs at qt-project.org> wrote:

> I have a project with some cpp products.
> Also the project includes a non-cpp product.
> Non-cpp product depends on my custom module that creates a custom deployment package.
> Module can process both cpp and non-cpp products (so it have application input artifact). Also module use path to qt binaries from Qt.core module (so it have dependency on Qt.core module)
> 
> If I configure the project by QtCreator to use MinGW, all works fine, but if I use MSVC2017 (64 bit), it tries to link non-cpp product and fails with unresolved symbol mainCRTStartup.
> Here is the short snippet that fails to build:
> 
> Project {
>     Product{
>         Depends{name:"Qt.core"}
>         files:"main.txt"
>         type:"test_output"
>         Rule{
>             inputs:["some_input_tag","application"]
>             Artifact{
>                 filePath:"main.txt.output"
>                 fileTags:["test_output"]
>             }
>             prepare:{
>                 var cmd=new JavaScriptCommand();
>                 return [cmd];
>             }
>         }
>     }
> }
> 
> It looks like Qt.core have a dependency on cpp module, it tries to create an application artifact from 0 source files and fails on that. Is that a known issue?

That's because the module has the Qt5Core.lib file as a target artifact, and the linker rule takes such files as inputs even if no source files are present. 
Use a redirection to prevent the cpp module from getting pulled in:

Project {
    Product {
        name: "QtPathProvider"
        Depends { name:"Qt.core" }
        Export {
            property string qtBinPath: product.Qt.core.binPath
            // ...
        }
    }
    Product {
        Depends { name: "QtPathProvider" }
        // Use QtPathProvider.qtBinPath below
        // ...
    }
}


Christian



More information about the Qbs mailing list