summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2021-09-16 20:55:57 +0800
committerGitHub <[email protected]>2021-09-16 20:55:57 +0800
commit388ee60e90ade5ff712314d96036bbb3e789a3ea (patch)
tree9ffed2624f209252129bb6052abea753941120ed
parent646b616d40835ef4c882f15df1f15574af2cfe58 (diff)
parent8e41cd06d4f77d7a3f8544be7d719ea399412d93 (diff)
Merge pull request #1675 from xmake-io/mingw
improve mingw implib
-rw-r--r--tests/projects/package/toolchain_muslcc/xmake-requires.lock246
-rw-r--r--xmake/core/project/target.lua21
-rw-r--r--xmake/core/sandbox/modules/import/core/project/target.lua8
-rw-r--r--xmake/core/sandbox/modules/import/lib/detect/find_library.lua26
-rw-r--r--xmake/modules/core/tools/gcc.lua2
-rw-r--r--xmake/modules/core/tools/nvcc.lua4
-rw-r--r--xmake/modules/package/manager/apt/find_package.lua2
-rw-r--r--xmake/modules/package/manager/brew/find_package.lua4
-rw-r--r--xmake/modules/package/manager/conda/find_package.lua2
-rw-r--r--xmake/modules/package/manager/dub/find_package.lua2
-rw-r--r--xmake/modules/package/manager/pkgconfig/find_package.lua1
-rw-r--r--xmake/modules/package/manager/system/find_package.lua2
-rw-r--r--xmake/modules/package/manager/vcpkg/find_package.lua3
-rw-r--r--xmake/modules/package/manager/xmake/find_package.lua8
-rw-r--r--xmake/modules/target/action/install/windows.lua2
-rw-r--r--xmake/modules/target/action/uninstall/windows.lua2
-rw-r--r--xmake/platforms/mingw/xmake.lua4
17 files changed, 191 insertions, 148 deletions
diff --git a/tests/projects/package/toolchain_muslcc/xmake-requires.lock b/tests/projects/package/toolchain_muslcc/xmake-requires.lock
index 4adae3fbb..9b6e40634 100644
--- a/tests/projects/package/toolchain_muslcc/xmake-requires.lock
+++ b/tests/projects/package/toolchain_muslcc/xmake-requires.lock
@@ -1,103 +1,145 @@
-{
- __meta__ = {
- version = "1.0"
- },
- ["macosx|x86_64"] = {
- ["autoconf#31fecfc4"] = {
- repo = {
- branch = "master",
- commit = "4498f11267de5112199152ab030ed139c985ad5a",
- url = "https://gitee.com/tboox/xmake-repo.git"
- },
- version = "2.71"
- },
- ["automake#31fecfc4"] = {
- repo = {
- branch = "master",
- commit = "eda7adee81bac151f87c507030cc0dd8ab299462",
- url = "https://gitee.com/tboox/xmake-repo.git"
- },
- version = "1.16.4"
- },
- ["cmake#31fecfc4"] = {
- repo = {
- branch = "master",
- commit = "4498f11267de5112199152ab030ed139c985ad5a",
- url = "https://gitee.com/tboox/xmake-repo.git"
- },
- version = "3.21.0"
- },
- ["gmp#31fecfc4"] = {
- repo = {
- branch = "master",
- commit = "c1b4838c9b1e7a2c52d9bf1a9beafeaee7305e30",
- url = "https://gitee.com/tboox/xmake-repo.git"
- },
- version = "6.2.1"
- },
- ["libisl 0.22#67114504"] = {
- repo = {
- branch = "master",
- commit = "eda7adee81bac151f87c507030cc0dd8ab299462",
- url = "https://gitee.com/tboox/xmake-repo.git"
- },
- version = "0.22"
- },
- ["libogg#31fecfc4"] = {
- repo = {
- branch = "master",
- commit = "eda7adee81bac151f87c507030cc0dd8ab299462",
- url = "https://gitee.com/tboox/xmake-repo.git"
- },
- version = "v1.3.4"
- },
- ["libplist#31fecfc4"] = {
- repo = {
- branch = "master",
- commit = "eda7adee81bac151f87c507030cc0dd8ab299462",
- url = "https://gitee.com/tboox/xmake-repo.git"
- },
- version = "2.2.0"
- },
- ["libtool#31fecfc4"] = {
- repo = {
- branch = "master",
- commit = "eda7adee81bac151f87c507030cc0dd8ab299462",
- url = "https://gitee.com/tboox/xmake-repo.git"
- },
- version = "2.4.6"
- },
- ["m4#31fecfc4"] = {
- repo = {
- branch = "master",
- commit = "c1b4838c9b1e7a2c52d9bf1a9beafeaee7305e30",
- url = "https://gitee.com/tboox/xmake-repo.git"
- },
- version = "1.4.19"
- },
- ["muslcc#31fecfc4"] = {
- repo = {
- branch = "master",
- commit = "eda7adee81bac151f87c507030cc0dd8ab299462",
- url = "https://gitee.com/tboox/xmake-repo.git"
- },
- version = "20210202"
- },
- ["pkg-config#31fecfc4"] = {
- repo = {
- branch = "master",
- commit = "c1b4838c9b1e7a2c52d9bf1a9beafeaee7305e30",
- url = "https://gitee.com/tboox/xmake-repo.git"
- },
- version = "0.29.2"
- },
- ["zlib#31fecfc4"] = {
- repo = {
- branch = "master",
- commit = "eda7adee81bac151f87c507030cc0dd8ab299462",
- url = "https://gitee.com/tboox/xmake-repo.git"
- },
- version = "1.2.11"
- }
- }
+{
+ __meta__ = {
+ version = "1.0"
+ },
+ ["macosx|x86_64"] = {
+ ["autoconf#31fecfc4"] = {
+ repo = {
+ branch = "master",
+ commit = "4498f11267de5112199152ab030ed139c985ad5a",
+ url = "https://gitee.com/tboox/xmake-repo.git"
+ },
+ version = "2.71"
+ },
+ ["automake#31fecfc4"] = {
+ repo = {
+ branch = "master",
+ commit = "eda7adee81bac151f87c507030cc0dd8ab299462",
+ url = "https://gitee.com/tboox/xmake-repo.git"
+ },
+ version = "1.16.4"
+ },
+ ["cmake#31fecfc4"] = {
+ repo = {
+ branch = "master",
+ commit = "4498f11267de5112199152ab030ed139c985ad5a",
+ url = "https://gitee.com/tboox/xmake-repo.git"
+ },
+ version = "3.21.0"
+ },
+ ["gmp#31fecfc4"] = {
+ repo = {
+ branch = "master",
+ commit = "c1b4838c9b1e7a2c52d9bf1a9beafeaee7305e30",
+ url = "https://gitee.com/tboox/xmake-repo.git"
+ },
+ version = "6.2.1"
+ },
+ ["libisl 0.22#67114504"] = {
+ repo = {
+ branch = "master",
+ commit = "eda7adee81bac151f87c507030cc0dd8ab299462",
+ url = "https://gitee.com/tboox/xmake-repo.git"
+ },
+ version = "0.22"
+ },
+ ["libogg#31fecfc4"] = {
+ repo = {
+ branch = "master",
+ commit = "eda7adee81bac151f87c507030cc0dd8ab299462",
+ url = "https://gitee.com/tboox/xmake-repo.git"
+ },
+ version = "v1.3.4"
+ },
+ ["libplist#31fecfc4"] = {
+ repo = {
+ branch = "master",
+ commit = "eda7adee81bac151f87c507030cc0dd8ab299462",
+ url = "https://gitee.com/tboox/xmake-repo.git"
+ },
+ version = "2.2.0"
+ },
+ ["libtool#31fecfc4"] = {
+ repo = {
+ branch = "master",
+ commit = "eda7adee81bac151f87c507030cc0dd8ab299462",
+ url = "https://gitee.com/tboox/xmake-repo.git"
+ },
+ version = "2.4.6"
+ },
+ ["m4#31fecfc4"] = {
+ repo = {
+ branch = "master",
+ commit = "c1b4838c9b1e7a2c52d9bf1a9beafeaee7305e30",
+ url = "https://gitee.com/tboox/xmake-repo.git"
+ },
+ version = "1.4.19"
+ },
+ ["muslcc#31fecfc4"] = {
+ repo = {
+ branch = "master",
+ commit = "eda7adee81bac151f87c507030cc0dd8ab299462",
+ url = "https://gitee.com/tboox/xmake-repo.git"
+ },
+ version = "20210202"
+ },
+ ["pkg-config#31fecfc4"] = {
+ repo = {
+ branch = "master",
+ commit = "c1b4838c9b1e7a2c52d9bf1a9beafeaee7305e30",
+ url = "https://gitee.com/tboox/xmake-repo.git"
+ },
+ version = "0.29.2"
+ },
+ ["zlib#31fecfc4"] = {
+ repo = {
+ branch = "master",
+ commit = "eda7adee81bac151f87c507030cc0dd8ab299462",
+ url = "https://gitee.com/tboox/xmake-repo.git"
+ },
+ version = "1.2.11"
+ }
+ },
+ ["windows|x64"] = {
+ ["cmake#31fecfc4"] = {
+ repo = {
+ branch = "master",
+ commit = "8e8c5e4d1c7e8b047b23333594d23b4b85163aed",
+ url = "https://gitee.com/tboox/xmake-repo.git"
+ },
+ version = "3.21.0"
+ },
+ ["libogg#31fecfc4"] = {
+ repo = {
+ branch = "master",
+ commit = "2b1cb74b289ae3221241985db4401a495c42fde3",
+ url = "https://gitee.com/tboox/xmake-repo.git"
+ },
+ version = "v1.3.4"
+ },
+ ["make#31fecfc4"] = {
+ repo = {
+ branch = "master",
+ commit = "2b1cb74b289ae3221241985db4401a495c42fde3",
+ url = "https://gitee.com/tboox/xmake-repo.git"
+ },
+ version = "4.3"
+ },
+ ["muslcc#31fecfc4"] = {
+ repo = {
+ branch = "master",
+ commit = "2b1cb74b289ae3221241985db4401a495c42fde3",
+ url = "https://gitee.com/tboox/xmake-repo.git"
+ },
+ version = "20210202"
+ },
+ ["zlib#31fecfc4"] = {
+ repo = {
+ branch = "master",
+ commit = "2b1cb74b289ae3221241985db4401a495c42fde3",
+ url = "https://gitee.com/tboox/xmake-repo.git"
+ },
+ version = "1.2.11"
+ }
+ }
} \ No newline at end of file
diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua
index 8cfbf0a12..7b0ce47d9 100644
--- a/xmake/core/project/target.lua
+++ b/xmake/core/project/target.lua
@@ -2058,18 +2058,19 @@ function target.filename(targetname, targetkind, opt)
end
-- get the link name of the target file
-function target.linkname(filename)
- local linkname, count = filename:gsub(target.filename("__pattern__", "static"):gsub("%.", "%%."):gsub("__pattern__", "(.+)") .. "$", "%1")
- if count == 0 then
- linkname, count = filename:gsub(target.filename("__pattern__", "shared"):gsub("%.", "%%."):gsub("__pattern__", "(.+)") .. "$", "%1")
+function target.linkname(filename, opt)
+ -- for implib/mingw, e.g. libxxx.dll.a
+ opt = opt or {}
+ if filename:startswith("lib") and filename:endswith(".dll.a") then
+ return filename:sub(4, #filename - 6)
end
+ local linkname, count = filename:gsub(target.filename("__pattern__", "static", {plat = opt.plat}):gsub("%.", "%%."):gsub("__pattern__", "(.+)") .. "$", "%1")
if count == 0 then
- -- for the mingw/cross platform, it is compatible with the libxxx.a and xxx.lib
- local formats = {static = "lib$(name).a", shared = "lib$(name).so"}
- linkname, count = filename:gsub(target.filename("__pattern__", "static", {format = formats["static"]}):gsub("%.", "%%."):gsub("__pattern__", "(.+)") .. "$", "%1")
- if count == 0 then
- linkname, count = filename:gsub(target.filename("__pattern__", "shared", {format = formats["shared"]}):gsub("%.", "%%."):gsub("__pattern__", "(.+)") .. "$", "%1")
- end
+ linkname, count = filename:gsub(target.filename("__pattern__", "shared", {plat = opt.plat}):gsub("%.", "%%."):gsub("__pattern__", "(.+)") .. "$", "%1")
+ end
+ -- in order to be compatible with mingw/windows library with .lib
+ if count == 0 and opt.plat == "mingw" then
+ linkname, count = filename:gsub(target.filename("__pattern__", "static", {plat = "windows"}):gsub("%.", "%%."):gsub("__pattern__", "(.+)") .. "$", "%1")
end
return count > 0 and linkname or nil
end
diff --git a/xmake/core/sandbox/modules/import/core/project/target.lua b/xmake/core/sandbox/modules/import/core/project/target.lua
index 205d15d61..07424cad3 100644
--- a/xmake/core/sandbox/modules/import/core/project/target.lua
+++ b/xmake/core/sandbox/modules/import/core/project/target.lua
@@ -26,13 +26,13 @@ local target = require("project/target")
local raise = require("sandbox/modules/raise")
-- get the filename from the given name and kind
-function sandbox_core_project_target.filename(name, kind)
- return target.filename(name, kind)
+function sandbox_core_project_target.filename(name, kind, opt)
+ return target.filename(name, kind, opt)
end
-- get the link name of the target file
-function sandbox_core_project_target.linkname(filename)
- return target.linkname(filename)
+function sandbox_core_project_target.linkname(filename, opt)
+ return target.linkname(filename, opt)
end
-- return module
diff --git a/xmake/core/sandbox/modules/import/lib/detect/find_library.lua b/xmake/core/sandbox/modules/import/lib/detect/find_library.lua
index bfb2315a5..4fb2618d3 100644
--- a/xmake/core/sandbox/modules/import/lib/detect/find_library.lua
+++ b/xmake/core/sandbox/modules/import/lib/detect/find_library.lua
@@ -38,7 +38,7 @@ local find_file = import("lib.detect.find_file")
-- @param paths the search paths
-- @param opt the options, e.g. {kind = "static/shared", suffixes = {"/aa", "/bb"}}
--
--- @return {kind = "static", link = "crypto", linkdir = "/usr/local/lib", filename = "libcrypto.a"}
+-- @return {kind = "static", link = "crypto", linkdir = "/usr/local/lib", filename = "libcrypto.a", plat = ..}
--
-- @code
--
@@ -54,24 +54,26 @@ function sandbox_lib_detect_find_library.main(names, paths, opt)
return
end
- -- init options
+ -- find library file from the given paths
opt = opt or {}
-
- -- init kinds
local kinds = opt.kind or {"static", "shared"}
-
- -- find library file from the given paths
for _, name in ipairs(table.wrap(names)) do
for _, kind in ipairs(table.wrap(kinds)) do
- local filepath = find_file(target.filename(name, kind), paths, opt)
- if not filepath then
- -- for the mingw/cross platform, it is compatible with the libxxx.a and xxx.lib
- local formats = {static = "lib$(name).a", shared = "lib$(name).so"}
- filepath = find_file(target.filename(name, kind, {format = formats[kind]}), paths, opt)
+ local filepath = find_file(target.filename(name, kind, {plat = opt.plat}), paths, opt)
+ if opt.plat == "mingw" then
+ if not filepath and kind == "shared" then
+ -- for implib/mingw, e.g. libxxx.dll.a
+ filepath = find_file(target.filename(name, kind, {plat = opt.plat}) .. ".a", paths, opt)
+ end
+ if not filepath then
+ -- in order to be compatible with mingw/windows library with .lib
+ filepath = find_file(target.filename(name, kind, {plat = "windows"}), paths, opt)
+ end
end
if filepath then
local filename = path.filename(filepath)
- return {kind = kind, filename = filename, linkdir = path.directory(filepath), link = target.linkname(filename)}
+ local linkname = target.linkname(filename, {plat = opt.plat})
+ return {kind = kind, filename = filename, linkdir = path.directory(filepath), link = linkname}
end
end
end
diff --git a/xmake/modules/core/tools/gcc.lua b/xmake/modules/core/tools/gcc.lua
index 89b732ec9..713cd80aa 100644
--- a/xmake/modules/core/tools/gcc.lua
+++ b/xmake/modules/core/tools/gcc.lua
@@ -334,7 +334,7 @@ function linkargv(self, objectfiles, targetkind, targetfile, flags, opt)
-- add `-Wl,--out-implib,outputdir/libxxx.a` for xxx.dll on mingw/gcc
if targetkind == "shared" and is_plat("mingw") then
- table.insert(flags_extra, "-Wl,--out-implib," .. path.join(path.directory(targetfile), path.basename(targetfile) .. ".lib"))
+ table.insert(flags_extra, "-Wl,--out-implib," .. path.join(path.directory(targetfile), path.basename(targetfile) .. ".dll.a"))
end
-- init arguments
diff --git a/xmake/modules/core/tools/nvcc.lua b/xmake/modules/core/tools/nvcc.lua
index 1ca09401e..41093c502 100644
--- a/xmake/modules/core/tools/nvcc.lua
+++ b/xmake/modules/core/tools/nvcc.lua
@@ -259,9 +259,9 @@ function linkargv(self, objectfiles, targetkind, targetfile, flags)
end
-- add `-Wl,--out-implib,outputdir/libxxx.a` for xxx.dll on mingw/gcc
- if targetkind == "shared" and config.plat() == "mingw" then
+ if targetkind == "shared" and is_plat("mingw") then
table.insert(flags_extra, "-Xlinker")
- table.insert(flags_extra, "-Wl,--out-implib," .. path.join(path.directory(targetfile), path.basename(targetfile) .. ".lib"))
+ table.insert(flags_extra, "-Wl,--out-implib," .. path.join(path.directory(targetfile), path.basename(targetfile) .. ".dll.a"))
end
-- make link args
diff --git a/xmake/modules/package/manager/apt/find_package.lua b/xmake/modules/package/manager/apt/find_package.lua
index f27968c0e..3fee1034f 100644
--- a/xmake/modules/package/manager/apt/find_package.lua
+++ b/xmake/modules/package/manager/apt/find_package.lua
@@ -67,7 +67,7 @@ function main(name, opt)
result.linkdirs = result.linkdirs or {}
result.libfiles = result.libfiles or {}
table.insert(result.linkdirs, path.directory(line))
- table.insert(result.links, target.linkname(path.filename(line)))
+ table.insert(result.links, target.linkname(path.filename(line), {plat = opt.plat}))
table.insert(result.libfiles, path.join(path.directory(line), path.filename(line)))
end
end
diff --git a/xmake/modules/package/manager/brew/find_package.lua b/xmake/modules/package/manager/brew/find_package.lua
index 49db5a464..d5f679f7a 100644
--- a/xmake/modules/package/manager/brew/find_package.lua
+++ b/xmake/modules/package/manager/brew/find_package.lua
@@ -97,11 +97,11 @@ function main(name, opt)
if pkgdir then
local links = {}
for _, libfile in ipairs(os.files(path.join(pkgdir, "lib", "*.a"))) do
- table.insert(links, target.linkname(path.filename(libfile)))
+ table.insert(links, target.linkname(path.filename(libfile), {plat = opt.plat}))
end
for _, libfile in ipairs(os.files(path.join(pkgdir, "lib", opt.plat == "macosx" and "*.dylib" or "*.so"))) do
if not os.islink(libfile) then
- table.insert(links, target.linkname(path.filename(libfile)))
+ table.insert(links, target.linkname(path.filename(libfile), {plat = opt.plat}))
end
end
opt.links = links
diff --git a/xmake/modules/package/manager/conda/find_package.lua b/xmake/modules/package/manager/conda/find_package.lua
index 5d2634d63..747e1bc9b 100644
--- a/xmake/modules/package/manager/conda/find_package.lua
+++ b/xmake/modules/package/manager/conda/find_package.lua
@@ -124,7 +124,7 @@ function main(name, opt)
result.linkdirs = result.linkdirs or {}
result.libfiles = result.libfiles or {}
table.insert(result.linkdirs, path.join(packagedir, path.directory(line)))
- table.insert(result.links, target.linkname(path.filename(line)))
+ table.insert(result.links, target.linkname(path.filename(line), {plat = opt.plat}))
table.insert(result.libfiles, path.join(packagedir, path.directory(line), path.filename(line)))
end
diff --git a/xmake/modules/package/manager/dub/find_package.lua b/xmake/modules/package/manager/dub/find_package.lua
index 55ad2d6ef..8543a8bfb 100644
--- a/xmake/modules/package/manager/dub/find_package.lua
+++ b/xmake/modules/package/manager/dub/find_package.lua
@@ -67,7 +67,7 @@ function main(name, opt)
if pkgdir then
local links = {}
for _, libraryfile in ipairs(os.files(path.join(pkgdir, libpattern))) do
- table.insert(links, target.linkname(path.filename(libraryfile)))
+ table.insert(links, target.linkname(path.filename(libraryfile), {plat = opt.plat}))
end
local includedirs = {}
local dubjson = path.join(pkgdir, "dub.json")
diff --git a/xmake/modules/package/manager/pkgconfig/find_package.lua b/xmake/modules/package/manager/pkgconfig/find_package.lua
index a7dbf377a..ddc7efeb4 100644
--- a/xmake/modules/package/manager/pkgconfig/find_package.lua
+++ b/xmake/modules/package/manager/pkgconfig/find_package.lua
@@ -20,7 +20,6 @@
-- imports
import("lib.detect.pkgconfig")
-import("lib.detect.find_library")
import("package.manager.system.find_package", {alias = "find_package_from_system"})
-- find package from the pkg-config package manager
diff --git a/xmake/modules/package/manager/system/find_package.lua b/xmake/modules/package/manager/system/find_package.lua
index 9bb04566d..692241309 100644
--- a/xmake/modules/package/manager/system/find_package.lua
+++ b/xmake/modules/package/manager/system/find_package.lua
@@ -60,7 +60,7 @@ function _find_package_from_unixdirs(name, links, opt)
-- find library
local result = nil
for _, link in ipairs(links) do
- local libinfo = find_library(link, linkdirs)
+ local libinfo = find_library(link, linkdirs, {plat = opt.plat})
if libinfo then
result = result or {}
result.links = table.join(result.links or {}, libinfo.link)
diff --git a/xmake/modules/package/manager/vcpkg/find_package.lua b/xmake/modules/package/manager/vcpkg/find_package.lua
index e965ace73..8bb4de8e8 100644
--- a/xmake/modules/package/manager/vcpkg/find_package.lua
+++ b/xmake/modules/package/manager/vcpkg/find_package.lua
@@ -20,7 +20,6 @@
-- imports
import("lib.detect.find_file")
-import("lib.detect.find_library")
import("lib.detect.find_tool")
import("core.base.option")
import("core.project.config")
@@ -117,7 +116,7 @@ function main(name, opt)
result.linkdirs = result.linkdirs or {}
result.libfiles = result.libfiles or {}
table.insert(result.linkdirs, path.join(installdir, path.directory(line)))
- table.insert(result.links, target.linkname(path.filename(line)))
+ table.insert(result.links, target.linkname(path.filename(line), {plat = plat}))
table.insert(result.libfiles, path.join(installdir, path.directory(line), path.filename(line)))
end
end
diff --git a/xmake/modules/package/manager/xmake/find_package.lua b/xmake/modules/package/manager/xmake/find_package.lua
index 0b043cc2f..c594c8135 100644
--- a/xmake/modules/package/manager/xmake/find_package.lua
+++ b/xmake/modules/package/manager/xmake/find_package.lua
@@ -82,14 +82,14 @@ function _find_package_from_repo(name, opt)
for _, file in ipairs(os.files(path.join(installdir, libdir, "*"))) do
if file:endswith(".lib") or file:endswith(".a") then
found = true
- table.insert(links, target.linkname(path.filename(file)))
+ table.insert(links, target.linkname(path.filename(file), {plat = opt.plat}))
table.insert(libfiles, file)
end
end
if not found then
for _, file in ipairs(os.files(path.join(installdir, "lib", "*"))) do
if file:endswith(".so") or file:match(".+%.so%..+$") or file:endswith(".dylib") then -- maybe symlink to libxxx.so.1
- table.insert(links, target.linkname(path.filename(file)))
+ table.insert(links, target.linkname(path.filename(file), {plat = opt.plat}))
table.insert(libfiles, file)
end
end
@@ -124,7 +124,7 @@ function _find_package_from_repo(name, opt)
-- find library
for _, link in ipairs(links) do
- local libinfo = find_library(link, linkdirs)
+ local libinfo = find_library(link, linkdirs, {plat = opt.plat})
if libinfo then
if libinfo.kind == "shared" then
result.shared = true
@@ -241,7 +241,7 @@ function _find_package_from_packagedirs(name, opt)
-- find library
local result = nil
for _, link in ipairs(packageinfo:get("links")) do
- local libinfo = find_library(link, linkdirs)
+ local libinfo = find_library(link, linkdirs, {plat = opt.plat})
if libinfo then
result = result or {}
result.links = table.join(result.links or {}, libinfo.link)
diff --git a/xmake/modules/target/action/install/windows.lua b/xmake/modules/target/action/install/windows.lua
index 609e87389..87a7413ca 100644
--- a/xmake/modules/target/action/install/windows.lua
+++ b/xmake/modules/target/action/install/windows.lua
@@ -110,7 +110,7 @@ function install_shared(target, opt)
-- @see https://github.com/xmake-io/xmake/issues/714
local targetfile = target:targetfile()
local librarydir = path.join(target:installdir(), opt and opt.libdir or "lib")
- local targetfile_lib = path.join(path.directory(targetfile), path.basename(targetfile) .. ".lib")
+ local targetfile_lib = path.join(path.directory(targetfile), path.basename(targetfile) .. (target:is_plat("mingw") and ".dll.a" or ".lib"))
if os.isfile(targetfile_lib) then
os.mkdir(librarydir)
os.vcp(targetfile_lib, librarydir)
diff --git a/xmake/modules/target/action/uninstall/windows.lua b/xmake/modules/target/action/uninstall/windows.lua
index 236b045e3..2915966db 100644
--- a/xmake/modules/target/action/uninstall/windows.lua
+++ b/xmake/modules/target/action/uninstall/windows.lua
@@ -81,7 +81,7 @@ function uninstall_shared(target, opt)
-- @see https://github.com/xmake-io/xmake/issues/714
local targetfile = target:targetfile()
local librarydir = path.join(target:installdir(), opt and opt.libdir or "lib")
- os.vrm(path.join(librarydir, path.basename(targetfile) .. ".lib"))
+ os.vrm(path.join(librarydir, path.basename(targetfile) .. (target:is_plat("mingw") and ".dll.a" or ".lib")))
-- remove headers from the include directory
_uninstall_headers(target, opt)
diff --git a/xmake/platforms/mingw/xmake.lua b/xmake/platforms/mingw/xmake.lua
index b856cf876..b86786a0f 100644
--- a/xmake/platforms/mingw/xmake.lua
+++ b/xmake/platforms/mingw/xmake.lua
@@ -31,9 +31,9 @@ platform("mingw")
set_archs("i386", "x86_64", "arm", "arm64")
-- set formats
- set_formats("static", "$(name).lib")
+ set_formats("static", "lib$(name).a")
set_formats("object", "$(name).obj")
- set_formats("shared", "$(name).dll")
+ set_formats("shared", "lib$(name).dll")
set_formats("binary", "$(name).exe")
set_formats("symbol", "$(name).pdb")