Martin Jocqueviel Martin Jocqueviel - 1 year ago 128
C++ Question

Igl error : undefined symbols for architecture x86_64

I am starting to use the igl library for 3d in C++, on my mac. As I followed the tutorial, an error appeared. The first exemple, basically just reading an OFF file, works fine. But the second one, using igl::viewer doesn't. Here is the code :

#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("/", V, F);

// Plot the mesh
igl::viewer::Viewer viewer;, F);

and I just enter in the terminal :

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

where path_to_libraries is a personal folder in which my libraries (igl, eigen, glfw) remain.

And the terminal returns dozens of errors like :

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

I also downloaded Eigen and glfw. All I did is a cmake in the glfw source folder.

Finalement, I should add that when I tried with Xcode, adding in the project the framework OpenGL (something I found on the internet) removed half of the errors (the one concerning igl::viewer::OpenGL) but some igl::viewer::Viewer ones remain.

Does anyone have any clue?

Answer Source

You most likely need to link in a few of OS X's frameworks, according to GLFW's docs, adding

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

should fix your problem.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download