首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用premake和vs2019与glfw连接时出现问题

使用premake和vs2019与glfw连接时出现问题
EN

Stack Overflow用户
提问于 2021-12-02 12:10:56
回答 1查看 969关注 0票数 0

我正在尝试使用premake5构建一个简单的项目。在win10上使用VisualStudio2019。Premake对我来说是新的,但我开始很简单:唯一的依赖项是glm ( headers library)、GLAD和GLFW。我把高兴和GLFW作为子项目包括在我的预制作文件中。项目生成很好。

glm是正确的和可用的。

构建时:高兴和GLFW正确地构建了各自的.lib文件,但是“核心”应用程序失败了,出现了以下链接器错误:

代码语言:javascript
复制
3>GLFW.lib(init.obj) : error LNK2019: unresolved external symbol _glfwSelectPlatform referenced in function glfwInit
3>GLFW.lib(vulkan.obj) : error LNK2019: unresolved external symbol _glfwPlatformLoadModule referenced in function _glfwInitVulkan
3>GLFW.lib(vulkan.obj) : error LNK2019: unresolved external symbol _glfwPlatformFreeModule referenced in function _glfwInitVulkan
3>GLFW.lib(vulkan.obj) : error LNK2019: unresolved external symbol _glfwPlatformGetModuleSymbol referenced in function _glfwInitVulkan

在构建glfw时,我肯定缺少了一个配置选项。

以下是预制作的lua脚本,负责构建GLFW:

代码语言:javascript
复制
project "GLFW"
kind "StaticLib"
language "C"

targetdir ("bin/" .. outputdir .. "/%{prj.name}")
objdir ("bin-int/" .. outputdir .. "/%{prj.name}")

files
{
    "include/GLFW/glfw3.h",
    "include/GLFW/glfw3native.h",
    "src/glfw_config.h",
    "src/context.c",
    "src/init.c",
    "src/input.c",
    "src/monitor.c",
    "src/vulkan.c",
    "src/window.c"
}
filter "system:linux"
    pic "On"

    systemversion "latest"
    staticruntime "On"

    files
    {
        "src/x11_init.c",
        "src/x11_monitor.c",
        "src/x11_window.c",
        "src/xkb_unicode.c",
        "src/posix_time.c",
        "src/posix_thread.c",
        "src/glx_context.c",
        "src/egl_context.c",
        "src/osmesa_context.c",
        "src/linux_joystick.c"
    }

    defines
    {
        "_GLFW_X11"
        
    }

filter "system:windows"
    systemversion "latest"
    staticruntime "On"
    
    -- buildoptions{
    --     "/MT"
    -- }

    files
    {
        "src/win32_init.c",
        "src/win32_joystick.c",
        "src/win32_monitor.c",
        "src/win32_time.c",
        "src/win32_thread.c",
        "src/win32_window.c",
        "src/wgl_context.c",
        "src/egl_context.c",
        "src/osmesa_context.c"
    }

    defines 
    { 
        "_GLFW_WIN32",
        "_CRT_SECURE_NO_WARNINGS"

    }

filter "configurations:Debug"
    runtime "Debug"
    symbols "On"

filter "configurations:Release"
    runtime "Release"
    optimize "On"
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-12-02 13:36:36

感谢“Botje”的评论,我意识到预制作脚本中有一堆丢失的文件。(我从另一个项目得到了这个文件,错误地认为它是正确的)

在查看glfw项目源目录中的CMakeLists.txt时,我发现了丢失的文件。

下面是glfw项目的新lua预制作脚本:

代码语言:javascript
复制
project "GLFW"
kind "StaticLib"
language "C"

targetdir ("bin/" .. outputdir .. "/%{prj.name}")
objdir ("bin-int/" .. outputdir .. "/%{prj.name}")

files
{
    "include/GLFW/glfw3.h",
    "include/GLFW/glfw3native.h",
    "src/internal.h",
    "src/platform.h",
    "src/mappings.h",
    "src/context.c",
    "src/init.c",
    "src/input.c",
    "src/monitor.c",
    "src/platform.c",
    "src/vulkan.c",
    "src/window.c",
    "src/egl_context.c",
    "src/osmesa_context.c",
    "src/null_platform.h",
    "src/null_joystick.h",
    "src/null_init.c",

    "src/null_monitor.c",
    "src/null_window.c",
    "src/null_joystick.c",

}
filter "system:linux"
    pic "On"

    systemversion "latest"
    staticruntime "On"

    files
    {
        "src/x11_init.c",
        "src/x11_monitor.c",
        "src/x11_window.c",
        "src/xkb_unicode.c",
        "src/posix_time.c",
        "src/posix_thread.c",
        "src/glx_context.c",
        "src/egl_context.c",
        "src/osmesa_context.c",
        "src/linux_joystick.c"
    }

    defines
    {
        "_GLFW_X11"
        
    }

filter "system:windows"
    systemversion "latest"
    staticruntime "On"
    
    -- buildoptions{
    --     "/MT"
    -- }

    files
    {
        "src/win32_init.c",
        "src/win32_module.c",
        "src/win32_joystick.c",
        "src/win32_monitor.c",
        "src/win32_time.h",
        "src/win32_time.c",
        "src/win32_thread.h",
        "src/win32_thread.c",
        "src/win32_window.c",
        "src/wgl_context.c",
        "src/egl_context.c",
        "src/osmesa_context.c"
    }

    defines 
    { 
        "_GLFW_WIN32",
        "_CRT_SECURE_NO_WARNINGS"

    }

filter "configurations:Debug"
    runtime "Debug"
    symbols "On"

filter "configurations:Release"
    runtime "Release"
    optimize "On"
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70199224

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档