【发布时间】:2020-04-18 12:28:14
【问题描述】:
我正在学习 OpenGL 和 GLFW,我决定使用 premake5,因为它看起来易于使用和维护。我的项目位于一个名为 LearningOpenGL 的文件夹中。我在 MAC 上。
项目结构。
- 学习OpenGL
- 源
- Application.cc
- 供应商
- GLFW
- 包括
- GLFW
- glfw3.h
- glfw3native.h
- GLFW
- lib-macos
- libglfw3.a
- 包括
- GLFW
- 源
- premake5.lua
- 供应商
- 斌
- 预制
- 预制5
- 预制
- 斌
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
从终端它给了我这个我无法解决的错误。
==== 构建学习OpenGL(调试)==== 链接学习OpenGL ld:找不到 -llibglfw3.a 的库 clang:错误:链接器命令失败,退出代码为 1(使用 -v 查看调用) make[1]: * [bin/Debug-macosx/LearningOpenGL/LearningOpenGL] 错误 1 make: * [LearningOpenGL] 错误2
另外,我可以使用其他易于使用的项目管理器来代替 premake 吗?
【问题讨论】:
标签: c++ opengl glfw static-linking premake