1

我正在使用 premake5 和 VS2013 在 C# 中创建一个 SharedLib。在列出我的项目之前,我在解决方案级别运行以下命令:

configurations { "Debug", "Release" }
platforms { "Win32", "Win64" }

    filter "configurations:Debug"
        defines { "DEBUG" }
        flags { "Symbols" }

    filter "configurations:Release"
        defines { "NDEBUG" }
        optimize "On"

    filter "platforms:Win32"
        system "Windows"
        architecture "x32"

    filter "platforms:Win64"
        system "Windows"
        architecture "x64"

这会生成一个解决方案文件以及项目文件。但是,在 VS2013 中打开解决方案并将构建平台设置为 Win64 后,我注意到它没有构建。检查配置管理器后,我注意到我的项目针对 Win32 和 Win64 都设置为 x86。它们甚至没有设置为 Release 或 Debug Win64 版本。然而,它们被设置为在任一 Win32 中构建。我很想发布截图,但我的声誉太低了。

看起来我只是没有正确地将其设置为 64 位。“x64”是要使用的正确字符串吗?预制件只是有一个错误吗?我应该注意,我可以手动将 Win64 设置为 x64,并在打开解决方案后检查配置管理器中的“构建”框。

编辑:我确认问题出在解决方案文件的生成中。GlobalSection(ProjectConfigurationPlatforms) = postSolution 条目的编写如下:

GlobalSection(ProjectConfigurationPlatforms) = postSolution
        {25F339C1-1195-6497-FA4F-78EBE690EBE7}.Debug|Win64.ActiveCfg = Debug Win64|x64
        {25F339C1-1195-6497-FA4F-78EBE690EBE7}.Debug|Win64.Build.0 = Debug Win64|x64
        {25F339C1-1195-6497-FA4F-78EBE690EBE7}.Debug|x86.ActiveCfg = Debug|x86
        {25F339C1-1195-6497-FA4F-78EBE690EBE7}.Debug|x86.Build.0 = Debug|x86
        {25F339C1-1195-6497-FA4F-78EBE690EBE7}.Release|Win64.ActiveCfg = Release Win64|x64
        {25F339C1-1195-6497-FA4F-78EBE690EBE7}.Release|Win64.Build.0 = Release Win64|x64
        {25F339C1-1195-6497-FA4F-78EBE690EBE7}.Release|x86.ActiveCfg = Release|x86
        {25F339C1-1195-6497-FA4F-78EBE690EBE7}.Release|x86.Build.0 = Release|x86
        {01747461-6D34-F097-366F-3915A2EE3474}.Debug|Win64.ActiveCfg = Debug Win64|x64
        {01747461-6D34-F097-366F-3915A2EE3474}.Debug|Win64.Build.0 = Debug Win64|x64
        {01747461-6D34-F097-366F-3915A2EE3474}.Debug|x86.ActiveCfg = Debug|x86
        {01747461-6D34-F097-366F-3915A2EE3474}.Debug|x86.Build.0 = Debug|x86
        {01747461-6D34-F097-366F-3915A2EE3474}.Release|Win64.ActiveCfg = Release Win64|x64
        {01747461-6D34-F097-366F-3915A2EE3474}.Release|Win64.Build.0 = Release Win64|x64
        {01747461-6D34-F097-366F-3915A2EE3474}.Release|x86.ActiveCfg = Release|x86
        {01747461-6D34-F097-366F-3915A2EE3474}.Release|x86.Build.0 = Release|x86
    EndGlobalSection

当它们应该写成:

GlobalSection(ProjectConfigurationPlatforms) = postSolution
        {25F339C1-1195-6497-FA4F-78EBE690EBE7}.Debug|Win64.ActiveCfg = Debug|x64
        {25F339C1-1195-6497-FA4F-78EBE690EBE7}.Debug|Win64.Build.0 = Debug|x64
        {25F339C1-1195-6497-FA4F-78EBE690EBE7}.Debug|x86.ActiveCfg = Debug|x86
        {25F339C1-1195-6497-FA4F-78EBE690EBE7}.Debug|x86.Build.0 = Debug|x86
        {25F339C1-1195-6497-FA4F-78EBE690EBE7}.Release|Win64.ActiveCfg = Release|x64
        {25F339C1-1195-6497-FA4F-78EBE690EBE7}.Release|Win64.Build.0 = Release|x64
        {25F339C1-1195-6497-FA4F-78EBE690EBE7}.Release|x86.ActiveCfg = Release|x86
        {25F339C1-1195-6497-FA4F-78EBE690EBE7}.Release|x86.Build.0 = Release|x86
        {01747461-6D34-F097-366F-3915A2EE3474}.Debug|Win64.ActiveCfg = Debug|x64
        {01747461-6D34-F097-366F-3915A2EE3474}.Debug|Win64.Build.0 = Debug|x64
        {01747461-6D34-F097-366F-3915A2EE3474}.Debug|x86.ActiveCfg = Debug|x86
        {01747461-6D34-F097-366F-3915A2EE3474}.Debug|x86.Build.0 = Debug|x86
        {01747461-6D34-F097-366F-3915A2EE3474}.Release|Win64.ActiveCfg = Release|x64
        {01747461-6D34-F097-366F-3915A2EE3474}.Release|Win64.Build.0 = Release|x64
        {01747461-6D34-F097-366F-3915A2EE3474}.Release|x86.ActiveCfg = Release|x86
        {01747461-6D34-F097-366F-3915A2EE3474}.Release|x86.Build.0 = Release|x86
    EndGlobalSection
4

3 回答 3

1

你发现了一个错误!我已经向项目提交了一个拉取请求来修复它。同时,如此处所述,您可以通过将“Win64”平台重命名为“x86_64”来解决此问题。

此修复程序应在 Premake 5.0-alpha6 版本中发布。

于 2015-08-23T18:26:41.710 回答
1

所以,我也遇到了这个问题,设置了一个简单的 x86/64 项目。我发现这有效:

-- premake5.lua
workspace "Sample"
  configurations { "Debug", "Release" }
  platforms { "x86", "x86_64" }
  location "build"

project "Sample01"
  kind "ConsoleApp"
  language "C++"
  location "build/sample01"
  targetdir "bin/%{cfg.buildcfg}"

  files { "%{prj.name}/src/**.h", "%{prj.name}/src/**.cpp" }

  filter "configurations:Debug"
    defines { "DEBUG" }
    flags { "Symbols" }

  filter "configurations:Release"
    defines { "NDEBUG" }
    optimize "On"

    filter "platforms:x86"
        system "Windows"
        architecture "x86"

    filter "platforms:x86_64"
        system "Windows"
        architecture "x86_64"

我知道这个话题有点老了,但这可能会在以后为某人省去一些悲伤。

我的项目结构看起来像这样,顺便说一句:

- sample [folder]
  - sample01 [folder]
    - src [folder]
       main.cpp
  premake5.lua

这会生成一个 VS 2013 项目并编译没有错误。我也在 github 中分享了这个:https ://github.com/Nuclearfossil/sample

于 2015-08-18T19:37:41.520 回答
0

我通过在第 222 行对 vs2005_solution.lua 进行以下更改(并运行“premake5 embed”并重建解决方案)解决了这个问题:

--Change by Kpick, at least for vs2013, the format is different
if _ACTION < "vs2013" then
    _p(2,'{%s}.%s.ActiveCfg = %s|%s', prj.uuid, descriptor, platform, architecture)
else
    _p(2,'{%s}.%s.ActiveCfg = %s|%s', prj.uuid, descriptor, cfg.buildcfg, architecture)
end

-- Only output Build.0 entries for buildable configurations

if not excluded and prjCfg.kind ~= premake.NONE then
    --Change by Kpick, at least for vs2013, the format is different
    if _ACTION < "vs2013" then
        _p(2,'{%s}.%s.Build.0 = %s|%s', prj.uuid, descriptor, platform, architecture)
    else
        _p(2,'{%s}.%s.Build.0 = %s|%s', prj.uuid, descriptor, cfg.buildcfg, architecture)
    end
end

我应该注意,我还没有验证此更改仅适用于 vs2013,但我不想修改源代码。

于 2015-08-04T16:39:16.290 回答