]> git.tdb.fi Git - builder.git/commitdiff
Explicitly set import library name with MSVC linker
authorMikko Rasa <tdb@tdb.fi>
Mon, 2 Jan 2023 22:23:11 +0000 (00:23 +0200)
committerMikko Rasa <tdb@tdb.fi>
Mon, 2 Jan 2023 22:51:47 +0000 (00:51 +0200)
Also disable import library if one does not exist in the build.

plugins/msvc/msvclinker.cpp

index 19ee284e0b0a11fe3c0a9dae611e259e0a0e2f89..ca77a28edddfb14d6920f910fd85d57f5bb89c0e 100644 (file)
@@ -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<const SharedLibrary *>(&bin))
+       string imp_fn;
+       if(const SharedLibrary *shlib = dynamic_cast<const SharedLibrary *>(&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())
        {