title: Freeglut program compiles but when run, shows the error: libglut.so.3: cannot open shared object file
body: <p>This is my program:</p>
  
  <pre><code>#include &lt;/usr/local/include/GL/glut.h&gt;
  
  int main(int argc, char **argv) 
  {
      glutInit(&amp;argc, argv);
      glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
      glutInitWindowPosition(100,100);
      glutInitWindowSize(320,320);
      glutCreateWindow("Lighthouse3D- GLUT Tutorial");
  }
  </code></pre>
  
  <p>Compiled with:</p>
  
  <blockquote>
    <p>g++ -lglut -L/usr/local/lib/ -o start
    start.cpp;./start</p>
  </blockquote>
  
  <p>Error shown:  </p>
  
  <blockquote>
    <p>./start: error while loading shared
    libraries: libglut.so.3: cannot open
    shared object file: No such file or
    directory</p>
  </blockquote>
  
  <p>The file is present.</p>
  
  <blockquote>
    <p>bashprompt> locate libglut.so.3<br>
    /usr/local/lib/libglut.so.3<br>
    /usr/local/lib/libglut.so.3.9.0  </p>
  </blockquote>
  
  <p>Had also tried:  </p>
  
  <blockquote>
    <p>LD_RUN_PATH="/usr/local/lib/"<br>
    g++ -lglut -LLIBDIR -o start start.cpp;./start
    with no luck.  </p>
  </blockquote>
  
  <p>These were the messages shown while installing (if this helps):  </p>
  
  <blockquote>
    <p>root@Nav:/home/Nav/freeglut-2.6.0#
    make install   Making install in src<br>
    make[1]: Entering directory
    <code>/home/Nav/freeglut-2.6.0/src'<br>
    make[2]: Entering directory
    </code>/home/Nav/freeglut-2.6.0/src'   test
    -z "/usr/local/lib" || /bin/mkdir -p "/usr/local/lib"    /bin/sh ../libtool
    --mode=install /usr/bin/install -c  'libglut.la'
    '/usr/local/lib/libglut.la'<br>
    /usr/bin/install -c
    .libs/libglut.so.3.9.0
    /usr/local/lib/libglut.so.3.9.0 (cd
    /usr/local/lib &amp;&amp; { ln -s -f
    libglut.so.3.9.0 libglut.so.3 || { rm
    -f libglut.so.3 &amp;&amp; ln -s libglut.so.3.9.0 libglut.so.3; }; })<br>
    (cd /usr/local/lib &amp;&amp; { ln -s -f
    libglut.so.3.9.0 libglut.so || { rm -f
    libglut.so &amp;&amp; ln -s libglut.so.3.9.0
    libglut.so; }; })   /usr/bin/install
    -c .libs/libglut.lai /usr/local/lib/libglut.la<br>
    /usr/bin/install -c .libs/libglut.a
    /usr/local/lib/libglut.a   chmod 644
    /usr/local/lib/libglut.a   ranlib
    /usr/local/lib/libglut.a<br>
    PATH="$PATH:/sbin" ldconfig -n
    /usr/local/lib<br>
    ----------------------------------------------------------------------   Libraries have been installed in:<br>
    /usr/local/lib      If you ever happen
    to want to link against installed
    libraries   in a given directory,
    LIBDIR, you must either use libtool,
    and   specify the full pathname of the
    library, or use the <code>-LLIBDIR'   flag
    during linking and do at least one of
    the following:<br>
       - add LIBDIR to the</code>LD_LIBRARY_PATH' environment variable
         during execution<br>
       - add LIBDIR to the <code>LD_RUN_PATH' environment variable
         during linking<br>
       - use the</code>-Wl,--rpath -Wl,LIBDIR' linker flag<br>
       - have your system administrator add LIBDIR to `/etc/ld.so.conf'<br>
    See any operating system documentation
    about shared libraries for   more
    information, such as the ld(1) and
    ld.so(8) manual pages.</p>
  </blockquote>