我不能用 premake5 添加额外的库
I cannot add additional libraries with premake5
我正在学习OpenGL和GLFW,我决定使用premake5,因为它看起来易于使用和维护。我的项目位于名为 LearningOpenGL 的文件夹中。我在 MAC.
Project structure.
- 学习OpenGL
- 来源
- Application.cc
- 供应商
- GLFW
- 包括
- GLFW
- glfw3.h
- glfw3native.h
- lib-macos
- libglfw3.a
- premake5.lua
- 供应商
- 箱
- 预制
- 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
Building configurations...
Running action 'gmake'...
Generated LearningOpenGL.make...
Done (36ms).
然后
make
从终端给我这个错误,我无法解决。
==== Building LearningOpenGL (debug) ====
Linking LearningOpenGL
ld: library not found for -llibglfw3.a
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: * [bin/Debug-macosx/LearningOpenGL/LearningOpenGL] Error 1
make: * [LearningOpenGL] Error 2
此外,还有其他易于使用的项目管理器可以代替 premake 吗?
应该是:
links "glfw3"
或
linkoptions "-llibglfw3.a"
我正在学习OpenGL和GLFW,我决定使用premake5,因为它看起来易于使用和维护。我的项目位于名为 LearningOpenGL 的文件夹中。我在 MAC.
Project structure.
- 学习OpenGL
- 来源
- Application.cc
- 供应商
- GLFW
- 包括
- GLFW
- glfw3.h
- glfw3native.h
- GLFW
- lib-macos
- libglfw3.a
- 包括
- GLFW
- 来源
- premake5.lua
- 供应商
- 箱
- 预制
- 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
Building configurations... Running action 'gmake'... Generated LearningOpenGL.make... Done (36ms).
然后
make
从终端给我这个错误,我无法解决。
==== Building LearningOpenGL (debug) ==== Linking LearningOpenGL ld: library not found for -llibglfw3.a clang: error: linker command failed with exit code 1 (use -v to see invocation) make[1]: * [bin/Debug-macosx/LearningOpenGL/LearningOpenGL] Error 1 make: * [LearningOpenGL] Error 2
此外,还有其他易于使用的项目管理器可以代替 premake 吗?
应该是:
links "glfw3"
或
linkoptions "-llibglfw3.a"