4

I asked this on the openssl-users mailing list with no replies, so I thought I'd try here.

I am trying to build a Windows DLL that includes the static OpenSSL FIPS libraries. I built the FIPS libraries using perl Configure fips --with-fipslibdir=... -no-shared and then nmake -f ms\nt.mak. I'm using openssl-fips-2.0.5, openssl-1.0.1j, and MS Visual Studio 2010.

Now I'm trying to link the resulting libraries into my DLL. I've followed the instructions in the OpenSSL FIPS 2.0 User's Guide, setting a bunch of environment variables (FIPS_LINK, FIPS_CC, FIPS_CC_ARGS, etc.) and then called fipslink.pl. But I'm getting a "First stage Link failure".

It reports "Integrity check OK" and then compiles fips_premain.c, but when linking the DLL I get a bunch of "locally defined symbol _time64 imported" warnings (as well as strncmp, _errno, abort, fprintf, and others), and then some unresolved external symbols including:

__imp_strncpy
__imp_qsort
__imp_wcsstr
__imp_vsnwprintf

All of the errors come from libeayfips32.lib, libeaycompat32.lib, and ssleay32.lib.

I've played around with adding and removing things like /NODEFAULTLIB:msvcrt and /NODEFAULTLIB:libcmtd, and building with /MT or /MD or neither, but I keep getting linker errors each time. What am I missing?

Graeme Perrow
  • 56,086
  • 21
  • 82
  • 121

2 Answers2

2

I speculate that the "-no-shared" switch to the Configure script statically links the C standard library. You'd get your static OpenSSL FIPS library, but it would include implementations of printf and friends, as you actually experience.

Mike Crawford
  • 2,232
  • 2
  • 18
  • 28
  • Perhaps this is true but it doesn't help me. I *can* build a shared version (i.e. DLLs) but I want to build a static library. – Graeme Perrow Dec 17 '14 at 13:46
2

open file ms\nt.mak then modify line #28 by adding msvcrt.lib msvcrtd.lib at the end , to be like:

EX_LIBS=ws2_32.lib gdi32.lib advapi32.lib crypt32.lib user32.lib msvcrt.lib msvcrtd.lib

then run : nmake -f ms\nt.mak from visual studio command prompt.I hope that no linker messages will appear.

Also try to build the DLL by nmake -f ms\ntdll.mak

houssam
  • 1,823
  • 15
  • 27