premake 中的库问题
Problems with libraries in premake
我在 premake4 脚本中使用库时遇到了一些问题。
1) 使用 premake4 脚本在 Windows10 上创建共享库 (.dll) 时,它创建的 dll 很好,但它也创建了一个小尺寸 (2K) 的静态库。
就我而言,我使用 premake4 脚本创建了一个名为 MathLib.dll 的共享库。它正确地做到了这一点,但它也创建了一个名为 libMathLib.a 的文件,大小为 2K。 (可能是空的。)
我不明白为什么需要 premake4 生成的 Makefile 来创建 libMathLib.a,而实际上 objective 是创建一个 .dll 文件。我认为这可能是一个 premake4 错误,我已经在 github.
的 premake4 问题跟踪器上提出了它
premake4 lua脚本如下:
-- Dir : Files > C > SW > Applications > Samples >
-- premakeSamples > premake-sharedlib-create
--#!lua
-- A solution contains projects,
-- and defines the available configurations
solution "MathLib"
configurations { "Debug", "Release" }
-- A project defines one build target
project "MathLib"
kind "SharedLib"
language "C++"
files { "**.h", "**.cpp" }
includedirs {"../../../ProgramLibraries/Headers/"}
-- Create target library in Files > C > SW >
-- Applications > ProgramLibraries
targetdir "../../../ProgramLibraries/"
configuration "Debug"
defines { "DEBUG" }
flags { "Symbols" }
configuration "Release"
defines { "NDEBUG" }
flags { "Optimize" }
-- Register the "runmakefile" action.
newaction
{
trigger = "runmakefile",
description = "run the generated makefile to create the executable using the default ('debug' config)",
execute = function()
os.execute("make")
end
}
-- Register the "runmakefilerelease" action.
newaction
{
trigger = "runmakefilerelease",
description = "run the generated makefile to create the executable using the 'release' config)",
execute = function()
os.execute("make config=release")
end
}
2) 上面的问题比听起来更严重。假设我已经使用单独的 premake4 脚本在 Libraries 目录中创建了一个名为 libMathLib.a 的真正静态库。随后,如果我还在与静态库相同的目录中创建一个名为 MathLib.dll 的共享库,则会创建一个虚拟静态库(可能是空的)并替换早期的真正静态库。
3) -- 编辑 -- :我曾将这一点(使用静态库)报告为一个问题,但它现在已经开始工作了。我不知道原因,但据我所知,唯一的区别是我关闭并重新启动了我的 PC(因此我的 MSYS 会话在 Windows 10)。因此我要删除这一点。
如何解决以上2个问题?
那就是 import library。您可以使用 Premake 的 NoImportLib
标志将其关闭。
flags { "NoImportLib" }
我在 premake4 脚本中使用库时遇到了一些问题。
1) 使用 premake4 脚本在 Windows10 上创建共享库 (.dll) 时,它创建的 dll 很好,但它也创建了一个小尺寸 (2K) 的静态库。
就我而言,我使用 premake4 脚本创建了一个名为 MathLib.dll 的共享库。它正确地做到了这一点,但它也创建了一个名为 libMathLib.a 的文件,大小为 2K。 (可能是空的。)
我不明白为什么需要 premake4 生成的 Makefile 来创建 libMathLib.a,而实际上 objective 是创建一个 .dll 文件。我认为这可能是一个 premake4 错误,我已经在 github.
的 premake4 问题跟踪器上提出了它premake4 lua脚本如下:
-- Dir : Files > C > SW > Applications > Samples >
-- premakeSamples > premake-sharedlib-create
--#!lua
-- A solution contains projects,
-- and defines the available configurations
solution "MathLib"
configurations { "Debug", "Release" }
-- A project defines one build target
project "MathLib"
kind "SharedLib"
language "C++"
files { "**.h", "**.cpp" }
includedirs {"../../../ProgramLibraries/Headers/"}
-- Create target library in Files > C > SW >
-- Applications > ProgramLibraries
targetdir "../../../ProgramLibraries/"
configuration "Debug"
defines { "DEBUG" }
flags { "Symbols" }
configuration "Release"
defines { "NDEBUG" }
flags { "Optimize" }
-- Register the "runmakefile" action.
newaction
{
trigger = "runmakefile",
description = "run the generated makefile to create the executable using the default ('debug' config)",
execute = function()
os.execute("make")
end
}
-- Register the "runmakefilerelease" action.
newaction
{
trigger = "runmakefilerelease",
description = "run the generated makefile to create the executable using the 'release' config)",
execute = function()
os.execute("make config=release")
end
}
2) 上面的问题比听起来更严重。假设我已经使用单独的 premake4 脚本在 Libraries 目录中创建了一个名为 libMathLib.a 的真正静态库。随后,如果我还在与静态库相同的目录中创建一个名为 MathLib.dll 的共享库,则会创建一个虚拟静态库(可能是空的)并替换早期的真正静态库。
3) -- 编辑 -- :我曾将这一点(使用静态库)报告为一个问题,但它现在已经开始工作了。我不知道原因,但据我所知,唯一的区别是我关闭并重新启动了我的 PC(因此我的 MSYS 会话在 Windows 10)。因此我要删除这一点。
如何解决以上2个问题?
那就是 import library。您可以使用 Premake 的 NoImportLib
标志将其关闭。
flags { "NoImportLib" }