title: Generating .so file
body: <p>I have file <code>main.c</code>, I want to create <code>main.so</code>.</p>
  
  <p><code>main.c</code> depends on <code>libCmodel.so</code> file.</p>
  
  <p><code>main.c</code> looks like</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include "Cmodel.h" // Must include before Amodel and Bmodel
  #include "Amodel.h"
  #include "Bmodel.h"
  
  int main(){
  ..
  return 0;
  }
  </code></pre>
  
  <p>It can be observed that, <code>libCmodel.so</code> file depends on <code>libAmodel.so.4</code> and <code>libBmodelso.11.</code>
  All the <code>"*.so"</code> files are present in the same directory as <code>main.c</code></p>
  
  <p>I used the following command to generate object file </p>
  
  <pre><code>gcc -x c++ -fPIC main.c -o main.o -c -I.
  </code></pre>
  
  <p>I see that <code>main.o</code> is generated. 
  But, I am not sure if I have used the correct command. Is the above command correct?</p>
  
  <p>Then, I tried the following commads to generate main.so ,</p>
  
  <pre><code>g++ -shared -o main.so main.o -L. -lCmodel
  g++ -shared -o main.so main.o -L. -lCmodel -lAmodel -lBmodel
  g++ -shared -o main.so main.o -L. -lCmodel -lAmodel.4 -lBmodel.11
  g++ -shared -o main.so main.o -L. -lCmodel -lAmodel.so.4 -lBmodel.so.11
  </code></pre>
  
  <p>Which one of the above commands is correct?
  Please help </p>