title: Cygwin GCC linking with Visual Studio library
body: <p>I've created a simple library (static 64bit - .lib) using Visual Studio 2012 Express.
  All this library has is one function:   </p>
  
  <pre><code>int get_number()
  { 
      return 67; 
  }
  </code></pre>
  
  <p>Let's say that the produced lib is called <code>NumTestLib64.lib</code>.</p>
  
  <p>I'm trying to compile a simple program (Let's call it <code>test.cpp</code>) using Cygwin64 which will link <code>NumTestLib64.lib</code> and will print the result of <code>get_number()</code>:</p>
  
  <pre><code>#include &lt;stdio.h&gt;   
  
  int get_number();
  
  int main()
  {
      printf("get_number: %d\n", get_number());
      return 0;
  }
  </code></pre>
  
  <p>Pretty simple right? Evidently not.<br>
  Compiling with <code>g++ -o test test.cpp -L. -lTestLibStatic64</code> returns:</p>
  
  <pre><code>/tmp/ccT57qc6.o:test.cpp:(.text+0xe): undefined reference to `get_number()'
  /tmp/ccT57qc6.o:test.cpp:(.text+0xe): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `get_number()'
  collect2: error: ld returned 1 exit status
  </code></pre>
  
  <p>and, <code>g++ -o test test.cpp TestLibStatic64.lib</code> returns:  </p>
  
  <pre><code>/tmp/ccMY8yNi.o:test.cpp:(.text+0xe): undefined reference to `get_number()'
  /tmp/ccMY8yNi.o:test.cpp:(.text+0xe): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `get_number()'
  collect2: error: ld returned 1 exit status
  </code></pre>
  
  <p>I'm looking for the brave ones who can provide instructions, both on the Visual Studio side and on the Cygwin command line side, as to how to get this thing done.</p>
  
  <p>I've tried all the possible web pages, so probably links won't help, just exact instructions. I don't mind changing the library to DLL or perform any changes necessary, all code is mine, both in this simple example and in the actual application I'm developing.</p>
  
  <p>Please help!</p>