title: LD_PRELOAD help
body: <p>I'm trying to use LD_PRELOAD.</p>
  
  <p><strong>original.cpp</strong></p>
  
  <pre><code>void myPuts() {  
      puts ("Hello myPuts");  
  }  
  int main() {  
      myPuts();  
      return 0;  
  }
  </code></pre>
  
  <p><strong>hacked.cpp</strong></p>
  
  <pre><code>void myPuts() {  
      std::cout &gt;&gt; "Hello hacked myPuts";  
  }
  </code></pre>
  
  <p>I compile original.cpp:  </p>
  
  <pre><code>g++ original.cpp
  </code></pre>
  
  <p>And hacked.cpp:  </p>
  
  <pre><code>g++ -shared -fPIC hacked.cpp
  </code></pre>
  
  <p>I try:</p>
  
  <pre><code>LD_PRELOAD=./hacked.so ./original.out
  </code></pre>
  
  <p>The string "Hello hacked myPuts" should be seen, by "Hello myPuts" appears.
  (If I try to "overwrite" the puts function, it works correctly)</p>
  
  <p>What am I missing?</p>