Note that there are some explanatory texts on larger screens.

plurals
  1. POLinker error : undefined reference to symbol 'glOrtho'
    text
    copied!<p>I installed OpenGL packages in Ubuntu 13.04 ( <code>*mesa-common-dev freeglut3-dev*</code> ) and tried to run a sample program. </p> <pre><code>#include "GL/freeglut.h" #include "GL/gl.h" /* display function - code from: http://fly.cc.fer.hr/~unreal/theredbook/chapter01.html This is the actual usage of the OpenGL library. The following code is the same for any platform */ void renderFunction() { glClearColor(0.0, 0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT); glColor3f(1.0, 1.0, 1.0); glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0); glBegin(GL_POLYGON); glVertex2f(-0.5, -0.5); glVertex2f(-0.5, 0.5); glVertex2f(0.5, 0.5); glVertex2f(0.5, -0.5); glEnd(); glFlush(); } /* Main method - main entry point of application the freeglut library does the window creation work for us, regardless of the platform. */ int main(int argc, char** argv) { glutInit(&amp;argc, argv); glutInitDisplayMode(GLUT_SINGLE); glutInitWindowSize(500,500); glutInitWindowPosition(100,100); glutCreateWindow("OpenGL - First window demo"); glutDisplayFunc(renderFunction); glutMainLoop(); return 0; } </code></pre> <p>However, I encountered this error and don't know what to make of it.</p> <pre><code>ved@vedvals:~/Desktop/p1$ g++ p1.cpp -lglut /usr/bin/ld: /tmp/ccgGdeR2.o: undefined reference to symbol 'glOrtho' /usr/bin/ld: note: 'glOrtho' is defined in DSO /usr/lib/x86_64-linux-gnu/mesa/libGL.so.1 so try adding it to the linker command line /usr/lib/x86_64-linux-gnu/mesa/libGL.so.1: could not read symbols: Invalid operation collect2: error: ld returned 1 exit status </code></pre> <p>I had a look at<br> <a href="https://stackoverflow.com/questions/11475817/opengl-hello-c-fails-to-build-using-cmake">OpenGL hello.c fails to build using CMake</a><br> as the error is similar but I am not using CMake</p> <p>IS my code wrong or do I need to include/change/tweak some settings?</p> <p>I referred this site for installation and code :</p> <p><a href="http://www.codeproject.com/Articles/182109/Setting-up-an-OpenGL-development-environment-in-Ub" rel="nofollow noreferrer">Setting up an OpenGL development environment in Ubuntu Linux</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload