libcurl依赖openssl
the second generation abandons the monolithic庞大的 Configure
and places individual单个 configurations in the Configurations directory.
you should always perform a make test to ensure the library performs as expected
under its self tests.
If you are building OpenSSL 1.1.0 and above, then you will also need PERL 5.10 or higher (see README.PERL for details).
using Configure and config. 最好用Configure
You can run Configure LIST to see a list of available platforms.
You can also configure on Darwin by exporting KERNEL_BITS: $ export KERNEL_BITS=64
1
./config shared no-ssl2 no-ssl3 enable-ec_nistp_64_gcc_128 --openssldir=/usr/local/ssl/macosx-x64/
you should perform a make clean to ensure the list of objects files is accurate after a reconfiguration.
when building a shared object, both the static archive and shared objects are built. You do not need to do anything special to build both when shared is specified. 当编译动态库时,会同时编译出静态库。
1
--prefix=XXX --openssldir shared no-ssl2
Using RPATHs
1
./config -Wl,-rpath=/usr/local/ssl/lib -Wl,--enable-new-dtags
verify the settings stuck:
1
2
3
4
5
$ readelf -d ./libssl.so | grep -i -E 'rpath|runpath'
$ ldd /usr/local/ssl/lib/libssl.so
linux-vdso.so.1 => (0x00007ffceff6c000)
ibcrypto.so.1.0.0 => /usr/local/ssl/lib/libcrypto.so.1.0.0 (0x00007ff5eff96000)
1
2
3
make
make test
sudo make install
OS X
./Configure darwin64-x86_64-cc shared enable-ec_nistp_64_gcc_128 no-ssl2 no-ssl3 no-comp –openssldir=/usr/local/ssl/macos-x86_64 make depend sudo make install
1
2
3
./Configure darwin64-x86_64-cc shared no-ssl2 --prefix=/Users/ws/Downloads/openssl_build --openssldir=/Users/ws/Downloads/openssl_build -Wl,-rpath=/usr/local/myssl/lib -Wl,--enable-new-dtags
./config shared no-ssl2 --prefix=/Users/ws/Downloads/openssl_build --openssldir=/Users/ws/Downloads/openssl_build -Wl,-rpath=/usr/local/myssl/lib -Wl,--enable-new-dtags
'-Wl,--enable-new-dtags,-rpath,$(LIBRPATH)'
如果不识别 RPATH
unknown option: -rpath=
hard coding the RPATH into a configure line. For example, on Debian x86_64 open the file Configure in an editor, copy linux-x86_64, name it linux-x86_64-rpath, and make the following change to add the -rpath option. Notice the addition of -Wl,-rpath=… in two places.
1
2
3
"linux-x86_64-rpath", "gcc:-m64 -DL_ENDIAN -O3 -Wall -Wl,-rpath=/usr/local/ssl/lib::
-D_REENTRANT::-Wl,-rpath=/usr/local/ssl/lib -ldl:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_UNROLL:
${x86_64_asm}:elf:dlfcn:linux-shared:-fPIC:-m64:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::64",
Above, fields 2 and 6 were changed. They correspond to $cflag and $ldflag in OpenSSL’s builds system. Then, Configure with the new configuration:
1
$ ./Configure linux-x86_64-rpath
小结:
1
2
3
4
export MACOSX_DEPLOYMENT_TARGET=10.13 && ./Configure darwin64-x86_64-cc shared
--prefix=xxx --openssldir=xxx 2个目录一般设置一样
make -j8
make install
查看版本
/usr/include/openssl/opensslv.h
1
openssl version -a
windows下编译
需要安装perl
编译出来的库有2个libcrypto和libssl(依赖crypto)
perl ./Configure查一下cpu平台,看见有个VC-WIN64-ARM 进入openssl根目录,配置一下arm64的vs环境变量vcvarsamd64_arm64.bat,在C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Auxiliary\Build目录下 Environment initialized for: ‘x64_arm64’ perl ./Configure VC-WIN64-ARM no-asm shared –prefix=C:\devel\compile\build\openssl –openssldir=C:\devel\compile\build\openssl 编译nmake nmake install
参考
https://wiki.openssl.org/index.php/Compilation_and_Installation