c++ - IGL错误: undefined symbols for architecture x86_64

标签 c++ opengl glfw libigl

我开始在我的 Mac 上使用 C++ 中的 igl 3d 库。当我按照教程进行操作时,出现了错误。第一个示例基本上只是读取 OFF 文件,效果很好。但第二个使用 igl::viewer 则不然。这是代码:

#include <igl/readOFF.h>
#include <igl/viewer/Viewer.h>

Eigen::MatrixXd V;
Eigen::MatrixXi F;

int main(int argc, char *argv[])
{
    // Load a mesh in OFF format
    igl::readOFF("/bunny.off", V, F);

    // Plot the mesh
    igl::viewer::Viewer viewer;
    viewer.data.set_mesh(V, F);
    viewer.launch();
}

我只需在终端中输入:

g++ -std=c++11 -I path_to_librairies/eigen-eigen-07105f7124f9/ -I path_to_librairies/libigl/include/ -I path_to_libraries/glfw-3.1.2/include/ main.cpp -o Test

其中path_to_libraries是我的库(igl、eigen、glfw)保留在其中的个人文件夹。

终端返回数十个错误,例如:

Undefined symbols for architecture x86_64:
  "_glActiveTexture", referenced from:
      igl::viewer::OpenGL_state::bind_mesh() in main-805320.o

我还下载了 Eigen 和 glfw。我所做的只是在 glfw 源文件夹中进行 cmake。

最后,我应该补充一点,当我尝试使用 Xcode 时,在项目中添加框架 OpenGL(我在互联网上找到的东西)消除了一半的错误(有关 igl::viewer::OpenGL 的错误),但一些 igl::viewer::Viewer 保留。

有人知道吗?

最佳答案

根据GLFW's docs,您很可能需要链接一些 OS X 的框架。 ,添加

-lglfw -framework Cocoa -framework OpenGL -framework IOKit -framework CoreVideo

应该可以解决您的问题。

关于c++ - IGL错误: undefined symbols for architecture x86_64,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36430358/

相关文章:

c++ - 运行时黑屏,没有错误

c++ - glewInit() 失败和 OpenGL 错误 1282

c++ - 使用 %c 扫描整数,使用 %d 扫描字符 : unexpected results

C++ 跳转钩子(Hook) [Windows]

c++ - ShellExecute 崩溃

c++ - OpenGL不喜欢OpenCV调整大小

c++ - 将鼠标坐标转换为世界空间坐标

c++ - 自动生成动态加载.so库的导入模块

python - 用 OpenGL 制作太阳系

c - OpenGL - 从模型 View 矩阵获取翻译参数