You are here:

C++/gcc errors


I started working with OpenGL in gcc - C++. I know glClear is a function in the gl.h header file. When I use this function (and the header file is included), when it links I get the error: "undefind reference ro 'glClear' ". When the header file isn't included I get the error: "'glClear' undeclared". So the compiler does need the header file for this function, but even with it, the function is "undefined". What can couse this problem, and what is the difrence between the two erros?
Thanks a lot for your time!

Hi Ofer,
 Header files are needed for the function prototypes. The function definition would be in a file (library in technical term that might be .a or .so where the former is for a static lib while the latter one is for dynamic one).

Please check if the GL installation procedure has installed the libs in standard path. If not then do include that path in LD_LIBRARY_PATH variable in your .profile or .bash_profile ( if you use bash) or .cshrc if you are using csh.

Or change the compilation method. Please read -l and -L  usage from gcc man page.

D Rai


All Answers

Answers by Expert:

Ask Experts


Dharmender Rai


I can answer general and system level C/C++ questions.


I have 5 years of experience in C++.

©2017 All rights reserved.

[an error occurred while processing this directive]