title: Undefined reference to `OGRRegisterAll'
body: <p>I am trying to write a gdal program to read shapefiles but I don't seem to be able to get past registering the drivers. Here is the code, I'm not sure why the functions in the header files are not available my source file even after including it.</p>
  
  <pre><code>#include "/usr/include/gdal/ogrsf_frmts.h"
  int main()    
  {
     GDALAllRegister();
  }
  </code></pre>
  
  <p>If I run this: <code>g++ demo.cpp</code>, I get the following error:</p>
  
  <pre><code>demo.cpp: In function int main():
  demo.cpp:6:21: error: GDALAllRegister was not declared in this scope
   GDALAllRegister();
                   ^
  </code></pre>
  
  <p>If I try the c version, I'm getting this:</p>
  
  <pre><code>#include "/usr/include/gdal/ogr_api.h"
  int main()
  {
      OGRRegisterAll();
      return 0;
  }
  
  gcc create.c
  
  /tmp/cc3YB8sO.o: In function main:
  create.c:(.text+0x11): undefined reference to OGRRegisterAll
  collect2: error: ld returned 1 exit status
  </code></pre>
  
  <p><strong>UPDATE</strong>
  I am using Ubuntu 15.04 64bit
  I installed all the packages using the apt:</p>
  
  <pre><code>sudo apt-get install gdal-bin libgdal-dev build-essential
  </code></pre>
  
  <p>I also have the ubuntugis ppa added and I have qgis 2.10 installed which is from the qgis repo and not from the ubuntugis ppa.</p>