yafuflash(4.90.0)在ubuntn_X86(linux)下编译安装

1. 软件准备

(1)gcc 版本

arm@ubuntu:~/test$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/i686-linux-gnu/4.6/lto-wrapper
Target: i686-linux-gnu
Configured with: …/src/configure -v --with-pkgversion=‘Ubuntu/Linaro 4.6.3-1ubuntu5’ --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.6 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --enable-objc-gc --enable-targets=all --disable-werror --with-arch-32=i686 --with-tune=generic --enable-checking=release --build=i686-linux-gnu --host=i686-linux-gnu --target=i686-linux-gnu
Thread model: posix
gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5)

(2)系统版本

arm@ubuntu:~/test$ uname -a
Linux ubuntu 3.11.0-15-generic #25~precise1-Ubuntu SMP Thu Jan 30 17:42:40 UTC 2014 i686 i686 i386 GNU/Linux
arm@ubuntu:~/test$ cat /proc/version
Linux version 3.11.0-15-generic (buildd@akateko) (gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5) ) #25~precise1-Ubuntu SMP Thu Jan 30 17:42:40 UTC 2014

(3)make版本

arm@ubuntu:~/test$ make -v
GNU Make 3.81
Copyright © 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.

(4)openssl版本

安装包文件名openssl-1.1.0g
arm@ubuntu:/usr/local/openssl/bin$ ./openssl version
OpenSSL 1.1.0g 2 Nov 2017
主要用编译得到的库文件libcrypto.a、 libssl.a。

(5)YAFUFlash版本

#define VERSION_NUMBER “4.90.0”

2.安装OpenSSL

# tar -xzf openssl-1.1.0f.tar.gz
# cd openssl-1.1.0f
# mkdir /usr/local/openssl
# ./config --prefix=/usr/local/openssl
# make
# make install
# which openssl
/usr/local/openssl/bin/openssl
创建软连接,如下:
# ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl
# cd /usr/local/openssl
# ldd /usr/local/openssl/bin/openssl
    linux-vdso.so.1 =>  (0x00007ffc63975000)
    libssl.so.1.1 => not found
    libcrypto.so.1.1 => not found
    libdl.so.2 => /lib64/libdl.so.2 (0x00007f8d9da0f000)
    libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f8d9d7f3000)
    libc.so.6 => /lib64/libc.so.6 (0x00007f8d9d431000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f8d9dc28000)

# vim /etc/ld.so.conf
在最后追加一行:
/usr/local/openssl/lib

# openssl version
OpenSSL 1.1.0f  25 May 2017
安装OK

3.修改源代码

(1) 修改libipmi_network_session.c

第①处
在函数AES_CBC_Encrypt内(大约在第1072行),将EVP_CIPHER_CTX ctx;注释掉,在其下面添加以下代码。

EVP_CIPHER_CTX *ctx;		
ctx = EVP_CIPHER_CTX_new();    //分配内存
//在函数AES_CBC_Encrypt末尾,即return LIBIPMI_STATUS_SUCCESS;添加
EVP_CIPHER_CTX_free(ctx);
//释放内存

第②处
在函数AES_CBC_Decrypt内(大约在第1226行),将EVP_CIPHER_CTX ctx;注释掉,在其下面添加以下代码。

EVP_CIPHER_CTX *ctx;		
ctx = EVP_CIPHER_CTX_new();    //分配内存
//在函数AES_CBC_Decrypt末尾,即return LIBIPMI_STATUS_SUCCESS;添加以下语句
EVP_CIPHER_CTX_free(ctx);    //释放内存

第③处
将libipmi_network_session.c中所有的“&ctx”替换为“ctx”。(此处是否应该修改还在待验证中)。

(2) 修改Makefile文件
文件路径yafuflash\yafuflash-4.90.0-ANY\Linux\Linux_x86_32\ Makefile。
INCDIR = ../../../../Build/include(大约在第5行)改为INCDIR = ../../ Build/include
LIBS += $(LIBPATH)/libipmi.a(大约在第21行)下添加以下代码即可:

LIBS += $(LIBPATH)/libssl.a
LIBS += $(LIBPATH)/libcrypto.a
LIBS += -lpthread

4.文件拷贝

mkdir  yafuflash/lib/libipmi/Linux_x86_32  -p
cp  yafuflash/lib/libipmi.a  yafuflash/lib/libipmi/Linux_x86_32
cp  /usr/local/openssl/lib/libcrypto.a   yafuflash/lib/libipmi/Linux_x86_32
cp  /usr/local/openssl/lib/libssl.a   yafuflash/lib/libipmi/Linux_x86_32
cp -rf /usr/local/openssl/include/openssl/   yafuflash/Build/include/

5.编译

cd yafuflash/libipmi-3.142.0-src/data/Linux_x86_32/
make clean
make
cd ../../../yafuflash-4.90.0-ANY/Linux/Linux_x86_32/
make clean
make
cd ../../obj/Linux_x86_32/
在python中用函数优化以下代码while True: print('='*30) loan_type = input('请选择贷款类型:1.商业贷款 2.公积金贷款 3.组合贷款 0.算清楚了谢谢\n') if loan_type == '1' : loan_amount = float(input('请输入贷款金额(万)\n')) term = int(input('请输入贷款期限(年):\n')) if term <= 5 : mon_rate = (4.75 / 100) / 12 else: mon_rate = (4.90 / 100) / 12 mon_pay = loan_amount * 10000 * (mon_rate * ((1+mon_rate)**(term * 12))) / (((1 + mon_rate)** (term * 12)) - 1) all_pay = mon_pay * term * 12 interest = all_pay - loan_amount * 10000 print('每月月供参考(元):{:.2f}'.format(mon_pay)) print('支付利息(元):{:.2f}'.format(interest)) print('还款总额(元):{:.2f}'.format(all_pay)) elif loan_type == '2' : loan_amount = float(input('请输入贷款金额(万):\n')) term = int(input('请输入贷款期限(年):\n')) if term <= 5 : mon_rate = (2.75 / 100) / 12 else: mon_rate = (3.25 / 100) / 12 mon_pay = loan_amount * 10000 * (mon_rate * ((1 + mon_rate) ** (term * 12))) / (((1 + mon_rate)** (term * 12)) - 1) all_pay = mon_pay * term * 12 interest = all_pay - loan_amount * 10000 print('每月月供参考(元):{:.2f}'.format(mon_pay)) print('支付利息(元):{:.2f}'.format(interest)) print('还款总额(元):{:.2f}'.format(all_pay)) elif loan_type == '3': business_loan = float(input('请输入商业贷款金额(万):\n')) fund_loan = int(input('请输入公积金贷款金额(万):\n')) term = int(input('请输入贷款期限(年):\n')) if term <= 5: business_mon_rate = (4.75 / 100) / 12 fund_mon_rate = (2.75 / 100) / 12 else: business_loan = (4.90 / 100) / 12 fund_mon_rate = (3.25 / 100) / 12 business_mon_pay = business_loan * 10000 * (business_mon_rate * ((1 + business_mon_rate) ** (term * 12))) / (((1 + business_mon_rate)** (term * 12)) - 1) fund_mon_pay = fund_loan * 10000 * (fund_mon_rate * ((1 + fund_mon_rate) ** (term * 12))) / (((1 + fund_mon_rate) ** (term * 12)) - 1) mon_all_pay = business_mon_pay + fund_mon_pay all
最新发布
03-09
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值