title: Link .o (C object file) to C++ file/project on Linux
body: <p>I have a problem with .o file in linux as follow:</p>
  
  <p>I have Visual.cpp which call function ECL_Drawrect() and this function is defined as:</p>
  
  <pre><code>#define ECL_Drawrect ECL_bDrawrect
  </code></pre>
  
  <p>In my Visual.cpp I also include "ecl.h" as:</p>
  
  <pre><code>#include "ecl.h"
  
  int main() {
      ECL_Drawrect (0,0,20,20,false);
      return 0;
  }
  </code></pre>
  
  <p>The problem is that the function ECL_bDrawrect is in the <strong>ecl.o</strong> file and i don't know how to link it to use the function mentioned above.</p>
  
  <p>After some research I figured out and setup as follow:</p>
  
  <pre><code>g++ Visual.cpp -o Visual /usr/include/ecl.o
  </code></pre>
  
  <p>The ecl.o path also incluced in my project and when I compiled i get this error:</p>
  
  <pre><code>**** Build of configuration Debug for project Visual ****
  
  make all 
  Building file: ../src/Visual.cpp
  Invoking: GCC C++ Compiler
  g++ -m32 -O0 -g3 -Wall -c -fmessage-length=0 /usr/include/ecl.o -MMD -MP -MF"src/Visual.d" -MT"src/Visual.d" -o "src/Visual.o" "../src/Visual.cpp"
  g++: /usr/include/ecl.o: linker input file unused because linking not done
  Finished building: ../src/Visual.cpp
  
  Building target: Visual
  Invoking: GCC C++ Linker
  g++ -m32  -o "Visual"  ./src/Visual.o   
  /usr/bin/ld: ./src/Visual.o: in function main:../src/Visual.cpp:7: error: undefined reference to 'ECL_bDrawrect'
  collect2: ld returned 1 exit status
  make: *** [Visual] Error 1
  
  **** Build Finished ****
  </code></pre>
  
  <p>I don't know whether the link is correct or not? How can I link this ecl.o file in properly way?</p>
  
  <p>p/S: I'm using eclipse CDT in ubuntu 11.04 64-bit and the <strong>ecl.o</strong> is for 32-bit, that's why I have to put -m32 to g++.</p>