title: shared object library not found when running program, but it's linked during compiling
body: <p>Update: issue is solved. The library was Made for Armv7a CPUs but it was "soft float" Not "hard float". It seems like my machine is HF and Not SF compatible</p>
  
  <p>My program depends on an externally build .so library called libMyLib.so. When I compile the program like this:</p>
  
  <pre><code>$ g++ -std=c++11 main.cpp -o run -pthread
  </code></pre>
  
  <p>it reports that there are a lot of undefined references, obviously because i didn't include libMyLib.so when compiling. So the compiler knows what he needs to compile the program. When i compile the program like this:</p>
  
  <pre><code>$ g++ -std=c++11 main.cpp -o run -pthread -lMyLib
  </code></pre>
  
  <p>it doesn't report any errors and creates the file "run". Notice that libMyLib.so is already in /usr/local/lib and it looks like it is linked when compiling since the references are defined now and the "run" file is created. But as i run the file, this happens:</p>
  
  <pre><code>$ ./run
      ./run: error while loading shared libraries: libMyLib.so: cannot open shared object file: No such file or directory
  </code></pre>
  
  <p>I've checked with ldd and it shows me this:</p>
  
  <pre><code>$ ldd run
      ...
      libMyLib.so =&gt; not found
      ...
  </code></pre>
  
  <p>So ldd doesn't find the library on execution, but it finds it while compiling. I'm quite new to Linux and linking libraries so i don't know what to do.</p>
  
  <p>Also, running ldd on the .so file returns this:</p>
  
  <pre><code>$ ldd /usr/local/lib/libMyLib.so
      not a dynamic executable
  </code></pre>
  
  <p>I've already checked an this message may occur when running a .so file on the wrong platform. But i've checked, the library is compiled for arm (I'm running on a raspberry pi -> arm):</p>
  
  <pre><code>$  objdump -f /usr/local/lib/libMyLib.so | grep ^architecture
      architecture: arm, flags 0x00000150:
  </code></pre>
  
  <p>I also update the linker:</p>
  
  <pre><code>$ sudo ldconfig -v
  ...
  /usr/local/lib:
      libwiringPi.so -&gt; libwiringPi.so.2.44
      libwiringPiDev.so -&gt; libwiringPiDev.so.2.44
      libMyLib.so -&gt; libMyLib.so.1
  ...
  </code></pre>
  
  <p>I really have no clue why this might still happen. Can anyone help me?</p>