title: Building a program (sscep) against OpenSSL: undefined reference to '[...]'
body: <p>I am trying to build a tool called sscep (http://www.klake.org/~jt/sscep/) for Windows. It does not run natively and I have a "patch" that changes sscep to make it compile on Windows.
  After applying the patch, it does <em>compile</em> perfectly but the linker screws. I am using gcc in minGW/msys
  The original messsage was that it couldn't find the crypto lib so I added the library with "-L../openssl-mingw/lib" which then didn't create any more errors. I also have the command line switch -lcrypto in my command: <code>gcc -L../openssl-mingw/lib -lcrypto sscep.o init.o net.o sceputils.o pkcs7.o ias.o fileutils.o -o sscep</code>.In this directory is a libcrypto.a. OpenSSL itself was compiled with the exact same compiler just running <code>./config &amp;&amp; make &amp;&amp; make test &amp;&amp; make install</code>. Also the sources were extracted using the minGW tar and not 7-zip.</p>
  
  <p>After following all documentation this is my (truncated) output:</p>
  
  <pre><code>sscep.o:sscep.c:(.text+0x83): undefined reference to `WSAStartup@8'
  sscep.o:sscep.c:(.text+0xa5): undefined reference to `WSACleanup@0'
  sscep.o:sscep.c:(.text+0x3d5): undefined reference to `BIO_new_mem_buf'
  sscep.o:sscep.c:(.text+0x3e0): undefined reference to `ASN1_INTEGER_new'
  sscep.o:sscep.c:(.text+0x414): undefined reference to `a2i_ASN1_INTEGER'
  sscep.o:sscep.c:(.text+0x432): undefined reference to `ASN1_INTEGER_to_BN'
  sscep.o:sscep.c:(.text+0x448): undefined reference to `BN_bn2dec'
  sscep.o:sscep.c:(.text+0xb7e): undefined reference to `EVP_des_cbc'
  sscep.o:sscep.c:(.text+0xbaf): undefined reference to `EVP_bf_cbc'
  sscep.o:sscep.c:(.text+0xbda): undefined reference to `EVP_des_cbc'
  sscep.o:sscep.c:(.text+0xc02): undefined reference to `EVP_des_ede3_cbc'
  sscep.o:sscep.c:(.text+0xc48): undefined reference to `EVP_md5'
  sscep.o:sscep.c:(.text+0xc79): undefined reference to `EVP_md5'
  sscep.o:sscep.c:(.text+0xca1): undefined reference to `EVP_sha1'
  </code></pre>
  
  <p>This goes on for every file in there and supposedly every function called.
  Searching here and google resulted in a missing library but omitting the -L directive from above I get another error about not finding libcrypto. So I assume that the library is actually found but somewhat with wrong addresses or something?</p>
  
  <p>Here my compiler/linker knowledge actually ends.
  If it is possible that the patch is responsible for that (which I do not believe since these are all openssl functions and the compiling works) then I can provide you with it.</p>
  
  <p>Edit: Is there any information that I should provide so someone can help me? The version of openssl is 1.0.1 if this makes any difference.
  On this topic: If it does make a difference, could this error occur because of a wrong version. As far as I understand linker theory, this error should not originate from a wrong version unless <em>all</em> of the below functions were replaced by differently named ones (but then the compiler would have complained, I guess?).</p>
  
  <p>Another addition: Since I am on a 64 bit Windows 7, I tried to compile it with -m32 flag but that did not help. I assume since mingw is already 32 bit only, I can't even build x64. Another question is whether it is a problem that I am running in a virtualized environment on an AMD Opteron while openssl is built with the command "-march=i486"?</p>