c++ - 无法在 MacOS10.14 上安装 OpenGL
问题描述
我尝试了很多安装OpenGL的方法,使用自制软件安装glfw和glew:
$ brew install glew glfw3
或者通过源码编译:
$ cd glfw && cmake . && make && sudo make install $ cd glew && make && sudo make install
Xcode 用于创建项目。Opengl.framework、glut.framework、libglfw3。A 和 libglew。A全部添加到项目中。头文件路径为/usr/local/include,库路径为/usr/local/lib。Main.cpp 源代码:
#include <iostream>
#include <GL/glew.h>
#include <GLFW/glfw3.h>
void Render(void)
{
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_TRIANGLES);
{
glColor3f(1.0,0.0,0.0);
glVertex2f(0, .5);
glColor3f(0.0,1.0,0.0);
glVertex2f(-.5,-.5);
glColor3f(0.0, 0.0, 1.0);
glVertex2f(.5, -.5);
}
glEnd();
}
int main(void) {
GLFWwindow* win;
if(!glfwInit()){
return -1;
}
win = glfwCreateWindow(640, 480, "OpenGL Base Project", NULL, NULL);
if(!win)
{
glfwTerminate();
exit(EXIT_FAILURE);
}
if(!glewInit())
{
return -1;
}
glfwMakeContextCurrent(win);
while(!glfwWindowShouldClose(win)){
Render();
glfwSwapBuffers(win);
glfwPollEvents();
}
glfwTerminate();
exit(EXIT_SUCCESS);
return 0;
}
编译错误:
Undefined symbols for architecture x86_64:
... (many can't find errors)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
谁能帮我?
解决方案
推荐阅读
- python - 如何在 python 中将原始 unicode 转换为 utf8-unicode?
- ruby-on-rails - Rails 6获取2个时间戳的差异并分配给查询中的一个新字段
- java - Spring Boot - 使用自定义 yml 标签扩展 yml 配置
- reactjs - 为什么扩展运算符会直接影响状态而有时不会?(反应)
- python - 合并具有不同索引频率的两个数据帧?(每周与每天)
- asp.net-core - 如何调试 ASP.NET Core 3 源代码?无源链接
- xml - 模糊搜索FIELD azure中的全局列表
- robotframework - 机器人框架:如何在运行时或变量中设置 Excel 文件名和工作表名称?
- c# - 您可以订购 X509Certificate2Collection 以使用最新证书吗?
- angular - 如何调试或修复 ng serve 给出 400 错误?