vs使用openssl aes gcm
C++ Openssl AES GCM 128bits代码示例,可wins10的visual studio 2017 中直接运行_ChainingBlocks-CSDN博客
https://github.com/openssl/openssl/issues/10459
github 是否解决win下编译问题 提问
linux交叉编译win
第一步:安装mingw32
本人 linux 环境是ubuntu18.04
sudo apt-get install mingw-w64
sudo apt-get install mingw-w64-tools
sudo apt-get install mingw-w64-i686-dev
sudo apt-get install mingw-w64-x86-64-dev
https://blog.csdn.net/zuihaobushi/article/details/90167362
CROSS_COMPILE="x86_64-w64-mingw32-" ./Configure mingw64 no-asm shared --prefix=/opt/mingw64
PATH=$PATH:/opt/mingw64/bin make
sudo PATH=$PATH:/opt/mingw64/bin make install
https://www.cnblogs.com/findumars/p/6372299.html
http://www.blogcompiler.com/2011/12/21/openssl-for-windows/
https://www.perl.org/
msvc
perl Configure --prefix="%CD%\..\MSVC64r\dll" --openssldir="%CD%\..\MSVC64r\dll\ssl" -EHsc -arch:AVX -FS threads no-deprecated shared VC-WIN64A && nmake
./Configure --prefix=$PWD/GCC32r shared mingw --unified && make depend && make && make install
pacman -S base-devel msys2-devel mingw-w64-{x86_64,i686}-toolchain
perl Configure mingw64 no-shared --prefix=/d/Code/openssl-1.0.2a/build-x64-PT-seh
./Configure threads no-deprecated shared mingw64 >_Configure.log && make
perl Configure -MTd threads no-deprecated no-shared debug-VC-WIN64A && nmake
- '
/MDd' for Debug+Shared build, - '
/MD' for Release+Shared build, - '
/MT' for Release+Static build,
as expected according to its description. But for some reason it add - '
/MT' and '/MDd' keys, instead of '/MTd', for Debug+Static build.
./Configure --prefix="$PWD/../GCC64d" -std=gnu11 -mtune=native -march=native threads no-deprecated shared debug-mingw64 >_Configure.log && ma ke
./configure --prefix="$BASEDIR" \ --with-mibdirs="$BASEDIR/share/snmp/mibs" \ --with-mib-modules="agentx disman/event-mib winExtDLL "\ --disable-embedded-perl --without-perl-modules --enable-ipv6
./Configure --prefix="$PWD/../GCC64r" -std=gnu11 -mtune=native -march=native threads no-deprecated shared mingw64 && make
perl Configure mingw64 --cross-compile-prefix=x86_64-w64-mingw32-
Then I make with no problems:make
Then I test:make test
perl Configure VC-WIN64A shared --prefix=\dev\openssl-1.1.1 /FS
jom -j 8
perl Configure VC-WIN64A shared --prefix=\dev\openssl /FS
jom -j 8
perl Configure mingw no-shared no-asm --prefix=/c/OpenSSL
make depend
make
git config core.autocrlf falsegit rm --cached -r .git reset --hard
git config --local core.autocrlf false
git config --local core.eol lf
git rm --cached -r .
git reset --hard
前文 git等各种源码仓库
https://www.cnblogs.com/marklove/p/11831539.html
./Configure mingw64 初始化配置 2
windows 刚开始编译时提示找不到gcc 添加环境变量 export PATH=$PATH:/mingw64/bin $source /etc/profile 将openssl源码复制到C:\msys64\home\world下 MSYS2 SHELL 切换到 /home/world/openssl ./Configure mingw64 make ============================================ ubuntu下 进去openssl perl Configure gcc shared make
常用软件包我们可以简单的使用命令直接从官网安装即可,比如安装openssl:
- 32bit:
pacman -S mingw-w64-i686-openssl - 64bit:
pacman -S mingw-w64-x86_64-openssl
有时候根据项目需要我们不得不自己动手编译依赖的软件包,以下是我在工作用到的库编译过程记录。
openssl
-
64bit
mkdir openssl64 cd openssl64 tar zxvf openssl-1.0.2c.tar.gz cd openssl-1.0.2c ./configure mingw64 shared make make INSTALL_PREFIX=../ install -
32bit
mkdir openssl32 cd openssl32 tar zxvf openssl-1.0.2c.tar.gz cd openssl-1.0.2c ./configure mingw shared make make INSTALL_PREFIX=../ install
zlib
- 32bit
mkdir zlib32
cd zlib32
tar zxvf zlib-1.2.8.tar.gz
cd zlib-1.2.8/
make -f ./win32/Makefile.gcc
make
make install -f win32/Makefile.gcc DESTDIR=../
通常Linux系统自带OpenSSL,但是其so文件由于没有debug信息,因此无法跟踪内部函数,对于学习 不太方便,需要通过源码重新安装。 我的Linux系统是CentOS7,自带的OpenSSL的版本是1.0.1e。在网上下载了OpenSSL1.0.1f后,通过 如下方法安装 [html] view plain copy ./config --prefix=/usr/local --openssldir=/usr/local/ssl make && make install ./config -d shared --prefix=/usr/local --openssldir=/usr/local/ssl make clean make && make install 先安装静态库版本,再安装动态库版本。安装目录为/usr/local下。安装动态库时增加-d选项,因为 调试时使用动态库,需要跟踪代码。 这样后面就可以写调试代码调试,如下面的例子: #include <stdio.h> #include <string.h> #include <openssl/bio.h> int main() { BIO *b = NULL; int len = 0; char *out = NULL; b = BIO_new(BIO_s_mem()); if (NULL == b) { return 0; } len = BIO_write(b,"openssl",4); len = BIO_printf(b,"%s","zcp"); len = BIO_ctrl_pending(b); out = (char *)OPENSSL_malloc(len); if (NULL == out) { return 0; } memset(out, 0, len); len = BIO_read(b,out,len); printf("out is : %s\n",out); OPENSSL_free(out); BIO_free(b); return 0; } 在当前路径下创建一个新的动态库软链接: ln -s /usr/local/lib64/libcrypto.so.1.0.0 libcrypto.so.10 然后gcc编译时指明使用这个libcrypto: gcc -g -DDEBUG -o openssl_mem_bio_test openssl_mem_bio_test.c -lcrypto -Wl,-rpath=.