Skip to content

utils.platform

This module is used for some platform-related auxiliary operation interfaces

utils.platform.gnu2mslib

  • Convert mingw's libxxxdll.a to msvc's xxx.lib library

This feature is particularly helpful for Fortran & C++ mixed projects, because VS does not provide the fortran compiler. You can only use MinGW's gfortran to compile the fortran part, and then link with the VS project. Often such projects also have some other libraries provided in the vs format, so pure MinGW compilation is not possible, you can only use this function to mix compilation.

And cmake also has a similar GNUtoMS.

For related issues, see: #1181

lua
import("utils.platform.gnu2mslib")

gnu2mslib("xxx.lib", "xxx.dll.a")
gnu2mslib("xxx.lib", "xxx.def")
gnu2mslib("xxx.lib", "xxx.dll.a", {dllname = "xxx.dll", arch = "x64"})

Support to generate xxx.lib from def, and also support to automatically export .def from xxx.dll.a, and then generate xxx.lib

If you don’t want to automatically generate def from dll.a, but want to borrow the def generated by gnu linker, then configure it yourself through add_shflags("-Wl,--output-def,xxx.def") to generate def, and then pass in def to this interface. .

{dllname = xxx, arch = "xxx"} These are optional, according to your needs.

You can also directly xmake l utils.platform.gnu2mslib xxx.lib xxx.dll.a quick test verification