title: Cross compile Static Library from Linux for windows
body: <p>I want to compile static library in linux for windows. Following is the procedure I followed for compiling</p>
  
  <ol>
  <li>Compile the source code of static library in linux using <code>i586-mingw32msvc-cc  -c static_lib.c -o static_lib.o</code></li>
  <li>Created the static library in linux <code>ar rv static_lib.a static_lib.o</code> and <code>ranlib static_lib.a</code></li>
  <li>I created a sample program in eclipse on windows and linked this static library which is cross compiled in linux for windows. The compiler used at windows was mingw.</li>
  </ol>
  
  <p>while compiling the program in windows eclipse, the compiler gives me the following error.</p>
  
  <pre><code>static_test\static_lib.a: file format not recognized; treating as linker script 
  \static_test\static_lib.a:1: syntax error
  collect2: ld returned 1 exit status
  Build error occurred, build is stopped
  </code></pre>
  
  <p>The Codes are as follows:</p>
  
  <p>static_lib.c</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  void func(void)
  {
          printf("Hello\n");
          printf("Hello\n");
          printf("Hello\n");
          printf("Hello\n");
          printf("Hello\n");
          printf("Hello\n");
          printf("Hello\n");
          printf("Hello\n");
          printf("Hello\n");
          printf("Hello\n");
          printf("Hello\n");
          printf("Hello\n");
  }
  </code></pre>
  
  <p>sample_static.c</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  extern void func(void);
  
  int main ()
  {
      printf ("Main function\n");
      func();
  }
  </code></pre>
  
  <p>kindly give me suggestions to compile and get it work.</p>
  
  <p>Regards
  Johnnie Alan</p>