我正在学习OpenGL和GLFW,因此决定使用premake5,因为它易于使用和维护。我的项目位于一个名为 LearningOpenGL 的文件夹中。我在使用MAC。


  • 学习OpenGL
  • src
  • Application.cc
  • 供应商
  • GLFW
  • 包括
  • GLFW
  • glfw3.h
  • glfw3native.h
  • lib-macos
  • libglfw3.a
  • premake5.lua
  • 供应商
  • bin
  • 预制棒
  • premake5

  • Application.cpp
    #include <GLFW/glfw3.h>
    #include <iostream>
    
    int main(void)
    {
    GLFWwindow* window;
    
    /* Initialize the library */
    if (!glfwInit())
        return -1;
    
    /* Create a windowed mode window and its OpenGL context */
    window = glfwCreateWindow(640, 480, "Hello World", NULL, NULL);
    if (!window)
    {
        glfwTerminate();
        return -1;
    }
    
    /* Make the window's context current */
    glfwMakeContextCurrent(window);
    
    /* Loop until the user closes the window */
    while (!glfwWindowShouldClose(window))
    {
        /* Render here */
        glClear(GL_COLOR_BUFFER_BIT);
    
        /* Swap front and back buffers */
        glfwSwapBuffers(window);
    
        /* Poll for and process events */
        glfwPollEvents();
    }
    
    glfwTerminate();
    return 0;
    }
    

    premake5.lua
    workspace "LearningOpenGL"
        configurations { "Debug", "Release" }
    
    outputdir = "%{cfg.buildcfg}-%{cfg.system}"
    
    project "LearningOpenGL"
        kind "ConsoleApp"
        language "C++"
        targetdir ("bin/" .. outputdir .. "/%{prj.name}")
        objdir ("bin-int/" .. outputdir .. "/%{prj.name}")
    
        files {
            "%{prj.name}/src/**.h",
            "%{prj.name}/src/**.cc"
        }
    
        -- including GLFW headers
        includedirs "%{prj.name}/vender/GLFW/include"
    
        -- linking with GLFW
        libdirs "LearningOpenGL/vender/GLFW/lib-macos"
        links "libglfw3.a"
    
    
        filter "configurations:Debug"
            defines { "DEBUG" }
            symbols "On"
    
        filter "configurations:Release"
            defines { "NDEBUG" }
            optimize "On"
    

    当我做
    vender/bin/premake/premake5 gmake
    



    然后
    make
    

    从终端它给我这个错误,我无法解决。



    此外,还有其他易于使用的项目经理可以代替预制吗?

    最佳答案

    它应该是:

    links "glfw3"
    

    要么
    linkoptions "-llibglfw3.a"
    

    关于c++ - 我无法使用premake5添加其他库,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/59519311/

    10-08 22:30