From 1a4337301632aa31dbc028d1c4260b5ff3052570 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Tue, 3 Jan 2023 00:23:11 +0200 Subject: [PATCH 1/1] Explicitly set import library name with MSVC linker Also disable import library if one does not exist in the build. --- plugins/msvc/msvclinker.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/plugins/msvc/msvclinker.cpp b/plugins/msvc/msvclinker.cpp index 19ee284..ca77a28 100644 --- a/plugins/msvc/msvclinker.cpp +++ b/plugins/msvc/msvclinker.cpp @@ -94,8 +94,13 @@ ExternalTask::Arguments MsvcLinker::_run(const Binary &bin, FS::Path &work_dir) argv.push_back(tool.get_executable()->get_path().str()); argv.push_back("/NOLOGO"); - if(dynamic_cast(&bin)) + string imp_fn; + if(const SharedLibrary *shlib = dynamic_cast(&bin)) + { argv.push_back("/DLL"); + if(const ImportLibrary *imp = shlib->get_import_library()) + imp_fn = relative(imp->get_path(), work_dir).str(); + } BuildInfo binfo; bin.collect_build_info(binfo); @@ -108,6 +113,10 @@ ExternalTask::Arguments MsvcLinker::_run(const Binary &bin, FS::Path &work_dir) argv.push_back("/DEBUG:FULL"); argv.push_back("/OUT:"+relative(bin.get_path(), work_dir).str()); + if(!imp_fn.empty()) + argv.push_back("/IMPLIB:"+imp_fn); + else + argv.push_back("/NOIMPLIB"); for(Target *d: bin.get_dependencies()) { -- 2.43.0