title: Generating object file to separate directory using g++ compiler - C++
body: <p>I use the following code to compile a cpp file to object file.</p>
  
  <pre><code>g++ -c main.cpp
  </code></pre>
  
  <p>Above code generates the .o fles in same directory where main.cpp resides. </p>
  
  <ol>
  <li>Suppose I have a folder named obj and need to generate the object files there, how could I write it?</li>
  <li>How can I see the compiler switches supported by g++ and it's usages?</li>
  </ol>
  
  <p>Any help would be great</p>