即使设置了包含路径(OpenGL),g ++也找不到glad.h

时间:2018-09-28 01:32:36

标签: opengl header linker g++

嗨,我正在用g ++编译器的glad.h头文件进行图形编程。这是我的代码。我将展示包含关系。

这是Animation.cpp中包含文件的列表

#include <glad/glad.h>
#include <GLFW/glfw3.h>
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>
#include "Shader.h"
#include "Camera.h"
#include "Bone.h"

这是Bone.h中包含的文件的列表

#include <glad/glad.h>
#include <GLFW/glfw3.h>
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>
#include "Shader.h"
#include "Camera.h"

(Animation.cpp,Bone.h,Shader.h,Camera.h都在同一目录中)

我再次检查了我的glad.h头文件是否在目录/ usr / local / include / glad中,并且确实存在。然后,我使用命令添加了环境变量

export CPLUS_INCLUDE_PATH=/usr/local/include

最后,我尝试使用以下命令执行代码

g++ Animation.cpp -o Animation -framework OpenGl -lglfw.3

但是,显示以下错误代码。

Undefined symbols for architecture x86_64:
  "_gladLoadGLLoader", referenced from:
      _main in Animation-a6af7a.o
  "_glad_glAttachShader", referenced from:
      Shader::Shader(char const*, char const*, char const*) in Animation-a6af7a.o
  "_glad_glBindBuffer", referenced from:
      Bone::setVAO(float*, float*) in Animation-a6af7a.o
  "_glad_glBindVertexArray", referenced from:
      Bone::setVAO(float*, float*) in Animation-a6af7a.o
      drawBones(Shader&, Bone*, glm::mat<4, 4, float, (glm::qualifier)0>) in Animation-a6af7a.o
  "_glad_glBufferData", referenced from:
      Bone::setVAO(float*, float*) in Animation-a6af7a.o
  "_glad_glBufferSubData", referenced from:
      Bone::setVAO(float*, float*) in Animation-a6af7a.o
  "_glad_glClear", referenced from:
      _main in Animation-a6af7a.o
  "_glad_glClearColor", referenced from:
      _main in Animation-a6af7a.o
  "_glad_glCompileShader", referenced from:
      Shader::Shader(char const*, char const*, char const*) in Animation-a6af7a.o
  "_glad_glCreateProgram", referenced from:
      Shader::Shader(char const*, char const*, char const*) in Animation-a6af7a.o
  "_glad_glCreateShader", referenced from:
      Shader::Shader(char const*, char const*, char const*) in Animation-a6af7a.o
  "_glad_glDeleteShader", referenced from:
      Shader::Shader(char const*, char const*, char const*) in Animation-a6af7a.o
  "_glad_glDrawArrays", referenced from:
      drawBones(Shader&, Bone*, glm::mat<4, 4, float, (glm::qualifier)0>) in Animation-a6af7a.o
  "_glad_glEnable", referenced from:
      _main in Animation-a6af7a.o
  "_glad_glEnableVertexAttribArray", referenced from:
      Bone::setVAO(float*, float*) in Animation-a6af7a.o
  "_glad_glGenBuffers", referenced from:
      Bone::setVAO(float*, float*) in Animation-a6af7a.o
  "_glad_glGenVertexArrays", referenced from:
      Bone::setVAO(float*, float*) in Animation-a6af7a.o
  "_glad_glGetProgramInfoLog", referenced from:
      Shader::checkCompileErrors(unsigned int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >) in Animation-a6af7a.o
  "_glad_glGetProgramiv", referenced from:
      Shader::checkCompileErrors(unsigned int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >) in Animation-a6af7a.o
  "_glad_glGetShaderInfoLog", referenced from:
      Shader::checkCompileErrors(unsigned int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >) in Animation-a6af7a.o
  "_glad_glGetShaderiv", referenced from:
      Shader::checkCompileErrors(unsigned int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >) in Animation-a6af7a.o
  "_glad_glGetUniformLocation", referenced from:
      Shader::setVec3(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, float, float, float) const in Animation-a6af7a.o
      Shader::setVec3(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, glm::vec<3, float, (glm::qualifier)0> const&) const in Animation-a6af7a.o
      Shader::setFloat(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, float) const in Animation-a6af7a.o
      Shader::setMat4(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, glm::mat<4, 4, float, (glm::qualifier)0> const&) const in Animation-a6af7a.o
  "_glad_glLinkProgram", referenced from:
      Shader::Shader(char const*, char const*, char const*) in Animation-a6af7a.o
  "_glad_glShaderSource", referenced from:
      Shader::Shader(char const*, char const*, char const*) in Animation-a6af7a.o
  "_glad_glUniform1f", referenced from:
      Shader::setFloat(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, float) const in Animation-a6af7a.o
  "_glad_glUniform3f", referenced from:
      Shader::setVec3(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, float, float, float) const in Animation-a6af7a.o
  "_glad_glUniform3fv", referenced from:
      Shader::setVec3(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, glm::vec<3, float, (glm::qualifier)0> const&) const in Animation-a6af7a.o
  "_glad_glUniformMatrix4fv", referenced from:
      Shader::setMat4(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, glm::mat<4, 4, float, (glm::qualifier)0> const&) const in Animation-a6af7a.o
  "_glad_glUseProgram", referenced from:
      Shader::use() in Animation-a6af7a.o
  "_glad_glVertexAttribPointer", referenced from:
      Bone::setVAO(float*, float*) in Animation-a6af7a.o
  "_glad_glViewport", referenced from:
      framebuffer_size_callback(GLFWwindow*, int, int) in Animation-a6af7a.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

显然,链接器似乎找不到我通过CPLUS_INCLUDE_PATH变量指定其路径的glad.h文件。任何帮助将不胜感激如何解决这个问题。预先感谢!

0 个答案:

没有答案