我正在学习OpenGL和GLFW,我决定使用premake5,因为它易于使用和维护。我的项目位于名为 LearningOpenGL 的文件夹中。我在使用MAC。
项目结构。
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
构建配置... 正在执行动作“ gmake” ... 生成的LearningOpenGL.make ... 完成(36毫秒)。
然后
make
来自终端,它给了我我无法解决的错误。
====构建LearningOpenGL(调试)==== 链接LearningOpenGL ld:找不到-llibglfw3.a的库 clang:错误:链接器命令失败,退出代码为1(使用-v查看调用) make [1]: * [bin / Debug-macosx / LearningOpenGL / LearningOpenGL]错误1 make:* [LearningOpenGL]错误2
还可以使用其他易于使用的项目管理器代替预制吗?
答案 0 :(得分:2)
应该是:
links "glfw3"
或
linkoptions "-llibglfw3.a"