2

I need to combine several static libraries (built from C++ code) for windows on an Azure (Microsoft-hosted) build agent. Locally, I can do this with lib.exe (part of the MSVC build tools).

I'm trying to run lib.exe in a script task, but the executable is not found. I've thought about manually adding the path for MSVC in the script and try like this, but that seems like a very fragile solution.

Can anybody give me a hint as to how to achieve this?

Sidelobe
  • 433
  • 7
  • 13
  • I'm afraid you may not be able to do it unless you set up your private agent. You could try using Linux agent/commands for same purpose which may have the preinstalled CLI tools. But that's not very promising as well. – levangode May 05 '23 at 01:59
  • 2
    Not an answer, but there is an [open issue with a workaround](https://github.com/microsoft/azure-pipelines-tasks/issues/9737). If it works for you you should post it as an answer. – Botje May 05 '23 at 07:32
  • @levangode: can I merge static libs built on windows with MSVC with e.g. `libtool` on Linux? I don't know enough about object formats – Sidelobe May 05 '23 at 08:49
  • Thanks @Botje - I'm going to try that workaround. Another idea I had was try to declare an additional Cmake library target and use `target_link_libraries` – Sidelobe May 05 '23 at 08:51
  • @Sidelobe I meant Linux might have its own tools for achieving whatever you are doing with `lib.exe` – levangode May 05 '23 at 16:12

1 Answers1

1

Using the commands described in this workaround, I was able to get it up and running.

I added this to the beginning of my script step (on windows agent):

pushd "C:\Program Files (x86)\Microsoft Visual Studio\Installer\"
for /f "delims=" %%x in ('.\vswhere.exe -latest -property InstallationPath') do set VSPATH=%%x
popd
call "%VSPATH%\VC\Auxiliary\Build\vcvarsall.bat" x64

After this, I can call e.g. lib.exe. What's great about this is that it's not tied to a specific VS version/path.

Thanks go out @Botje for posting the link in their comment above - much appreciated!

Sidelobe
  • 433
  • 7
  • 13