69,382
社区成员
发帖
与我相关
我的任务
分享
Building static version
Download and unpack sources of openssl. It comes in the tar.gz archive. Any build environment mentioned above includes tar program which is used to unpack archives.
Open command window (or terminal window on Unix), make sure that cygwin (or all of msys, mingw and ActiveState perl) directories are in your PATH (on Unix cross compiler automatically installed into PATH and perl is already there), change into top-level directory of unpacked source.
Open Configure script with text editor, find line
$IsMK1MF=1 if ($target eq "mingw" && $^O ne "cygwin" && !is_msys());
and comment it out (or delete altogether). If you are using Cygwin perl, you can omit this step. Condition would be false anyway. But function is_msys() might not work properly, and of course it wouldn't work when cross-compiling for Unix.
Configure script. On *nix you can just start
./Configure mingw
With cygwin or ActiveState perl you'll have to feed this script to perl
perl Configure mingw
Soon you get message "Configured for mingw".
Now, you are ready to run make. In the cygwin or msys environment just type make. On unix, if you type just make, native compiler would be invoked. You have to specify crosscompiler in the CC makefile variable:
make CC=i586-mingw32msvc-gcc RANLIB=i585-mingw32msvc-ranlib
With current stable (0.9.8d) verything should go fine until rehash target would be invoked. With development branch (0.9.9) you can go into some trouble - it is development version, it supposed to be buggy. See Troubleshooting section below for some hints.
When make tells "Doing certs" it would probably complain about 'openssl' program not found in msys and about inability to run program on Unix. You can safely ignore that for a while.
After build is finished you should have openssl.exe file in the apps directory, and two library files libssl.a and libcrypto.a in the toplevel directory.
If you are on native Win32 system, you may run test suite typing
make test
If you are doing build on Unix and want to run test, you have to find windows system to do so. This system should have MSYS and perl installed.
Doing shared build
You are probably not interesting in static build. Probably you want to have OpenSSL dlls which can be used with some native Win32 application such as Miranda IM.
To achieve this, you have to add shared parameter to Configure.
perl Configure mingw shared
But there bad thing happens:
everything is compiled, cryptoeay32-0.9.8.dll is built, but when it comes to building something that depends on this dll (such as ssleay32-0.9.8.dll), you get lot of complaints about unresolved symbols.
If you examine dll with dumpbin tool from MSVC you'll see that it doesn't export anything.
Fix is quite simple:
Open Configure script with text editor, find line with mingw configuration option:
"mingw","gcc:-mno-cygwin -DL_ENDIAN....
Find fragment which defines options for dll building (it lloks like
:-mno-cygwin -shared:
and add there -Wl,--export-all, so section would look like:
:-mno-cygwin -Wl,--export-all -shared:
Then rerun Configure mingw shared and make. Anything should run fine except certificate rehash.