1

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);
vanquishers
  • 358
  • 1
  • 3
  • 18

1 Answers1

0

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
Tam Toucan
  • 137
  • 10
  • thankyou but now I am facing an error `symbol lookup error: /usr/local/lib/libftgl.so.2: undefined symbol: glad_glGenTextures` – vanquishers Jan 14 '17 at 12:04
  • Do you understand the concepts of symbols, libs and how they are resolved? If not then I suggest reading up on it. Symbols for a lib must be resolved by code linked after it e.g. glfw uses GL so must be linked appear before it. The g++ line you have is actually 2 stages; compile the source code, and then link the object files. TBH I've never tried resolving a lib dependency with a source file so I would follow the standard pattern of compiling glad.c to a library and then linking it after ftgl. – Tam Toucan Jan 14 '17 at 15:47