aboutsummaryrefslogtreecommitdiffstats
path: root/share
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@qt.io>2018-08-22 17:02:41 +0200
committerChristian Kandeler <christian.kandeler@qt.io>2018-09-04 07:11:56 +0000
commit909128d2647498b66f4dc6c1e948af6b47d0c42a (patch)
tree76a28ea633f5ab60f3079c470b793d153449d477 /share
parentbe637305226049fbe4d09a435292c1034ee66312 (diff)
MSVC: Give hint about possible reason for missing import lib
If an import lib is unexpectedly not present, the reason is usually that no symbols are exported from the DLL. This is not obvious at all, so catch this condition and explain what is happening. Task-number: QBS-1291 Change-Id: Ia2df8e1a27e0231e855413245703ffc05221722e Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'share')
-rw-r--r--share/qbs/modules/cpp/msvc.js27
1 files changed, 23 insertions, 4 deletions
diff --git a/share/qbs/modules/cpp/msvc.js b/share/qbs/modules/cpp/msvc.js
index 698f44398..2e2c28c49 100644
--- a/share/qbs/modules/cpp/msvc.js
+++ b/share/qbs/modules/cpp/msvc.js
@@ -262,8 +262,8 @@ function collectLibraryDependencies(product) {
var seen = {};
var result = [];
- function addFilePath(filePath, wholeArchive) {
- result.push({ filePath: filePath, wholeArchive: wholeArchive });
+ function addFilePath(filePath, wholeArchive, productName) {
+ result.push({ filePath: filePath, wholeArchive: wholeArchive, productName: productName });
}
function addArtifactFilePaths(dep, artifacts) {
@@ -271,8 +271,12 @@ function collectLibraryDependencies(product) {
return;
var artifactFilePaths = artifacts.map(function(a) { return a.filePath; });
var wholeArchive = dep.parameters.cpp && dep.parameters.cpp.linkWholeArchive;
- for (var i = 0; i < artifactFilePaths.length; ++i)
- addFilePath(artifactFilePaths[i], wholeArchive);
+ var artifactsAreImportLibs = artifacts.length > 0
+ && artifacts[0].fileTags.contains("dynamiclibrary_import");
+ for (var i = 0; i < artifactFilePaths.length; ++i) {
+ addFilePath(artifactFilePaths[i], wholeArchive,
+ artifactsAreImportLibs ? dep.name : undefined);
+ }
}
function addExternalLibs(obj) {
@@ -467,6 +471,21 @@ function prepareLinker(project, product, inputs, outputs, input, output) {
args = wrapperArgs.concat(args);
}
var commands = [];
+ var warningCmd = new JavaScriptCommand();
+ warningCmd.silent = true;
+ warningCmd.libDeps = libDeps;
+ warningCmd.sourceCode = function() {
+ for (var i = 0; i < libDeps.length; ++i) {
+ if (!libDeps[i].productName || File.exists(libDeps[i].filePath))
+ continue;
+ console.warn("Import library '" + FileInfo.toNativeSeparators(libDeps[i].filePath)
+ + "' does not exist. This typically happens when a DLL does not "
+ + "export any symbols. Please make sure the '" + libDeps[i].productName
+ + "' library exports symbols, or, if you do not intend to actually "
+ + "link against it, specify \"cpp.link: false\" in the Depends item.");
+ }
+ };
+ commands.push(warningCmd);
var cmd = new Command(linkerPath, args)
cmd.description = 'linking ' + primaryOutput.fileName;
cmd.highlight = 'linker';