问题
while I am compiling my opengl code I am facing this error.how to remove this?
all: sample2D
sample2D: Sample_GL3_2D.cpp glad.c
g++ -o sample2D Sample_GL3_2D.cpp glad.c -lGL -lglfw -ldl -std=c++11
clean:
rm sample2D
this is my contents of Makefile and my code for rendering the font
const char* fontfile = "Monaco.ttf";
GL3Font.font = new FTExtrudeFont(fontfile); // 3D extrude style rendering
if(GL3Font.font->Error())
{
cout << "Error: Could not load font `" << fontfile << "'" << endl;
glfwTerminate();
exit(EXIT_FAILURE);
}
// Create and compile our GLSL program from the font shaders
fontProgramID = LoadShaders( "fontrender.vert", "fontrender.frag" );
GLint fontVertexCoordAttrib, fontVertexNormalAttrib, fontVertexOffsetUniform;
fontVertexCoordAttrib = glGetAttribLocation(fontProgramID, "vertexPosition");
fontVertexNormalAttrib = glGetAttribLocation(fontProgramID, "vertexNormal");
fontVertexOffsetUniform = glGetUniformLocation(fontProgramID, "pen");
GL3Font.fontMatrixID = glGetUniformLocation(fontProgramID, "MVP");
GL3Font.fontColorID = glGetUniformLocation(fontProgramID, "fontColor");
GL3Font.font->ShaderLocations(fontVertexCoordAttrib, fontVertexNormalAttrib, fontVertexOffsetUniform);
GL3Font.font->FaceSize(1);
GL3Font.font->Depth(0);
GL3Font.font->Outset(0, 0);
GL3Font.font->CharMap(ft_encoding_unicode);
回答1:
Looking up FTExtrudeFont it seems to be a function in the ftgl library http://ftgl.sourceforge.net/docs/html/classFTExtrudeFont.html however you are not linking that library. So you probably need -lftgl (assuming that is the named of the library).
Depending on where the library is installed (or if you have just built it yourself) then you may also need to tell the linker where to look for the library using the -L flag i.e. your compile line will be something like
g++ -o sample2D Sample_GL3_2D.cpp glad.c -L <path-to-dir-with-ftgl-library> -lftgl -lglfw -lGL -ldl -std=c++11
来源:https://stackoverflow.com/questions/41647415/error-undefined-reference-to-ftextrudefontftextrudefontchar-const