title: Undefined reference to 'dlsym' and 'dlopen'
body: <p>I am compiling using arm-linux-gnueabi-g++ version 4.7.3.</p>
  
  <p>I have the arm-linux-gnueabi libraries installed at location:</p>
  
  <blockquote>
    <p>/usr/arm-linux-gnueabi/lib, it contains libdl.a, libdl.so, libdl.so.2,
    and libdl-2.19.so.</p>
  </blockquote>
  
  <p>libdl.so links to libdl.so.2 which links to libdl-2.19.so.</p>
  
  <p>I am trying to link against the dl library (see command string below), but I always get the undefined reference errors.</p>
  
  <pre><code>arm-linux-gnueabi-g++ -I. -I../ -I../Comms/Linux  -Wall -DLINUX -fpic -o ../../work/MyProgram main.o
  -L../../work -L/usr/arm-linux-gnueabi/lib -lComms -lConsole -lUtilities -ldl
  ../../work/libUtilities.so: undefined reference to `dlsym'
  ../../work/libUtilities.so: undefined reference to `dlopen'
  collect2: error: ld returned 1 exit status
  </code></pre>
  
  <p>If I compile using g++ 4.8.2 using the following commend then my program compiles, links, and executes fine.</p>
  
  <pre><code>g++ -I. -I../ -I../Comms/Linux  -Wall -DLINUX -fpic -o ../../work/MyProgram main.o
  -L../../work -lComms -lConsole -lUtilities -ldl
  </code></pre>
  
  <p>Obviously it can't find the libdl.so library; I thought that by adding the path to the location of the appropriate library by using the <code>-L</code> flag would fix the problem, but it didn't.</p>
  
  <p>What am I missing with the ARM compiler command?</p>