编译工程生成,使用qmake生成qt工程文件(海思平台时,要用海思平台的qmake),将

TEMPLATE = app

修改为:

TEMPLATE = lib

添加如下:

win32:LIBS += -lws2_32  #windows下用的

QMAKE_CXXFLAGS += -msse4 -maes -mpclmul -msha

在windows下,用mingw

windows下编译好之后,头文件放入到mingw的include里,如下路径:

D:\Qt\Qt5.12.6\5.12.6\mingw73_32\include

libcryptopp.a要放在如下目录里:

D:\Qt\Qt5.12.6\Tools\mingw730_32\lib

海思的库文件和头文件编译好之后,可以放入到编译器的安装目录下(我用的是静态库):

/opt/hisi-linux/x86-arm/arm-hisiv500-linux/target/usr

这个目录下的include和lib下面

windows下编译没有遇到问题,直接可以编译通过,下面都是海思编译器交叉编译的问题:

-----------------------------------------------------------------------------------------------------

1.编译错误1

arm-hisiv500-linux-g++ -c -pipe -msse4 -maes -mpclmul -msha -O2 -std=gnu++11 -Wall -W -D_REENTRANT -fPIC -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I../../cryptopp800 -I. -I../../cryptopp800 -I/opt/qt5.12-arm/include -I/opt/qt5.12-arm/include/QtGui -I/opt/qt5.12-arm/include/QtCore -I. -I/opt/qt5.12-arm/mkspecs/linux-hisiv500-g++ -o 3way.o ../3way.cpp
arm-hisiv500-linux-g++: error: unrecognized command line option ‘-msse4’
arm-hisiv500-linux-g++: error: unrecognized command line option ‘-maes’
arm-hisiv500-linux-g++: error: unrecognized command line option ‘-mpclmul’
arm-hisiv500-linux-g++: error: unrecognized command line option ‘-msha’
Makefile:1303: recipe for target '3way.o' failed
make: *** [3way.o] Error 1

原因:

海思编译器可能不支持-msse4 -maes -mpclmul -msha编译选项;

去掉这几项即可编译

-----------------------------------------------------------------------------------------------------

2.编译错误2

/opt/hisi-linux/x86-arm/arm-hisiv500-linux/lib/gcc/arm-hisiv500-linux-uclibcgnueabi/4.9.4/include/arm_neon.h:31:2: error: #error You must enable NEON instructions (e.g. -mfloat-abi=softfp -mfpu=neon) to use arm_neon.h
 #error You must enable NEON instructions (e.g. -mfloat-abi=softfp -mfpu=neon) to use arm_neon.h
  ^
../aria_simd.cpp:66:34: error: ‘uint32x4_t’ does not name a type
 inline void ARIA_GSRK_NEON(const uint32x4_t X, const uint32x4_t Y, byte RK[16])
                                  ^
../aria_simd.cpp:66:54: error: ‘uint32x4_t’ does not name a type
 inline void ARIA_GSRK_NEON(const uint32x4_t X, const uint32x4_t Y, byte RK[16])
                                                      ^
../aria_simd.cpp: In function ‘void CryptoPP::ARIA_UncheckedSetKey_Schedule_NEON(CryptoPP::byte*, CryptoPP::word32*, unsigned int)’:
../aria_simd.cpp:81:8: error: ‘uint32x4_t’ does not name a type
  const uint32x4_t w0 = vld1q_u32(ws+ 0);
        ^
../aria_simd.cpp:82:8: error: ‘uint32x4_t’ does not name a type
  const uint32x4_t w1 = vld1q_u32(ws+ 8);
        ^
../aria_simd.cpp:83:8: error: ‘uint32x4_t’ does not name a type
  const uint32x4_t w2 = vld1q_u32(ws+12);
        ^
../aria_simd.cpp:84:8: error: ‘uint32x4_t’ does not name a type
  const uint32x4_t w3 = vld1q_u32(ws+16);
        ^
../aria_simd.cpp:86:21: error: ‘w0’ was not declared in this scope
  ARIA_GSRK_NEON<19>(w0, w1, rk +   0);
                     ^
../aria_simd.cpp:86:25: error: ‘w1’ was not declared in this scope
  ARIA_GSRK_NEON<19>(w0, w1, rk +   0);
                         ^
../aria_simd.cpp:87:25: error: ‘w2’ was not declared in this scope
  ARIA_GSRK_NEON<19>(w1, w2, rk +  16);
                         ^
../aria_simd.cpp:88:25: error: ‘w3’ was not declared in this scope
  ARIA_GSRK_NEON<19>(w2, w3, rk +  32);
                         ^
../aria_simd.cpp: At global scope:
../aria_simd.cpp:79:59: warning: unused parameter ‘ws’ [-Wunused-parameter]
 void ARIA_UncheckedSetKey_Schedule_NEON(byte* rk, word32* ws, unsigned int keylen)
                                                           ^
../aria_simd.cpp: In function ‘void CryptoPP::ARIA_ProcessAndXorBlock_NEON(const byte*, CryptoPP::byte*, const byte*, CryptoPP::word32*)’:
../aria_simd.cpp:137:22: error: ‘vld1q_u8’ was not declared in this scope
     vld1q_u8(xorBlock),
                      ^
../aria_simd.cpp:140:31: error: ‘vrev32q_u8’ was not declared in this scope
      vrev32q_u8(vld1q_u8((rk))))));
                               ^
../aria_simd.cpp:140:32: error: ‘veorq_u8’ was not declared in this scope
      vrev32q_u8(vld1q_u8((rk))))));
                                ^
../aria_simd.cpp:140:33: error: ‘veorq_u8’ was not declared in this scope
      vrev32q_u8(vld1q_u8((rk))))));
                                 ^
../aria_simd.cpp:140:33: error: redeclaration of ‘<typeprefixerror>veorq_u8’
../aria_simd.cpp:140:32: note: previous declaration ‘<typeprefixerror>veorq_u8’
      vrev32q_u8(vld1q_u8((rk))))));
                                ^
../aria_simd.cpp:140:34: error: ‘vst1q_u8’ was not declared in this scope
      vrev32q_u8(vld1q_u8((rk))))));
                                  ^
../aria_simd.cpp:146:22: error: ‘vld1q_u8’ was not declared in this scope
     vld1q_u8(outBlock),
                      ^
../aria_simd.cpp:147:28: error: ‘vrev32q_u8’ was not declared in this scope
     vrev32q_u8(vld1q_u8(rk))));
                            ^
../aria_simd.cpp:147:29: error: ‘veorq_u8’ was not declared in this scope
     vrev32q_u8(vld1q_u8(rk))));
                             ^
../aria_simd.cpp:147:30: error: ‘vst1q_u8’ was not declared in this scope
     vrev32q_u8(vld1q_u8(rk))));
                              ^
Makefile:1378: recipe for target 'aria_simd.o' failed
make: *** [aria_simd.o] Error 1

原因:

Makefile中的加上-mfloat-abi=softfp -mfpu=neon编译选项:

CXXFLAGS      = -pipe  -O2 -std=gnu++11 -Wall -W -D_REENTRANT -fPIC $(DEFINES) -mfloat-abi=softfp -mfpu=neon

------------------------------------------------------------------------------------------------------

3.问题3,这个是编译测试代码时的问题:

arm-hisiv500-linux-g++ -Wl,-O1 -Wl,-rpath,/opt/qt5.12-arm/lib -o ../bin/CerealApp temp/obj/harddriver.o temp/obj/main.o temp/obj/registerhandle.o temp/obj/moc_registerhandle.o   -lcryptopp /opt/qt5.12-arm/lib/libQt5Charts.so /opt/qt5.12-arm/lib/libQt5Widgets.so /opt/qt5.12-arm/lib/libQt5Gui.so /opt/qt5.12-arm/lib/libQt5Network.so /opt/qt5.12-arm/lib/libQt5Sql.so /opt/qt5.12-arm/lib/libQt5SerialPort.so /opt/qt5.12-arm/lib/libQt5Core.so -lpthread   
/opt/hisi-linux/x86-arm/arm-hisiv500-linux/bin/../target/usr/lib/libcryptopp.a(rijndael.o):在函数‘CryptoPP::CRYPTOGAMS_set_encrypt_key(unsigned char const*, int, unsigned int*)’中:
rijndael.cpp:(.text+0x300):对‘AES_set_encrypt_key’未定义的引用
/opt/hisi-linux/x86-arm/arm-hisiv500-linux/bin/../target/usr/lib/libcryptopp.a(rijndael.o):在函数‘CryptoPP::CRYPTOGAMS_set_decrypt_key(unsigned char const*, int, unsigned int*)’中:
rijndael.cpp:(.text+0x304):对‘AES_set_decrypt_key’未定义的引用
/opt/hisi-linux/x86-arm/arm-hisiv500-linux/bin/../target/usr/lib/libcryptopp.a(rijndael.o):在函数‘CryptoPP::CRYPTOGAMS_encrypt(unsigned char const*, unsigned char const*, unsigned char*, unsigned int const*)’中:
rijndael.cpp:(.text+0x31c):对‘AES_encrypt’未定义的引用
/opt/hisi-linux/x86-arm/arm-hisiv500-linux/bin/../target/usr/lib/libcryptopp.a(rijndael.o):在函数‘CryptoPP::CRYPTOGAMS_decrypt(unsigned char const*, unsigned char const*, unsigned char*, unsigned int const*)’中:
rijndael.cpp:(.text+0xadc):对‘AES_decrypt’未定义的引用
collect2: error: ld returned 1 exit status
Makefile:206: recipe for target '../bin/CerealApp' failed
make: *** [../bin/CerealApp] Error 1

问题原因是:

aes_armv4.S文件没有编译,在使用qmake生成工程文件时,该文件没有被加进去,

只需要在工程文件里的添加到source,然后重新执行qmake生成Makefile,再次编译没有问题了。

使用方法,核心代码:

   //------------------------
// 生成RSA密钥对
//------------------------
void GenerateRSAKey(unsigned int keyLength, const char *privFilename, const char *pubFilename, const char *seed){
RandomPool randPool;
randPool.IncorporateEntropy((unsigned char *)seed, strlen(seed)); RSAES_OAEP_SHA_Decryptor priv(randPool, keyLength);
HexEncoder privFile(new FileSink(privFilename));
priv.AccessMaterial().Save(privFile);
privFile.MessageEnd(); RSAES_OAEP_SHA_Encryptor pub(priv);
HexEncoder pubFile(new FileSink(pubFilename));
pub.AccessMaterial().Save(pubFile);
pubFile.MessageEnd();
} //------------------------
// RSA加密
//------------------------
string RSAEncryptString(const char *pubFilename, const char *seed, const char *message){ FileSource pubFile(pubFilename, true, new HexDecoder);
RSAES_OAEP_SHA_Encryptor pub(pubFile); RandomPool randPool;
randPool.IncorporateEntropy((unsigned char *)seed, strlen(seed)); std::string result;
StringSource(message, true, new PK_EncryptorFilter(randPool, pub, new HexEncoder(new StringSink(result))));
return result;
} //------------------------
// RSA解密
//------------------------
string RSADecryptString(const char *privFilename, const char *ciphertext){
FileSource privFile(privFilename, true, new HexDecoder);
RSAES_OAEP_SHA_Decryptor priv(privFile); std::string result;
try{
StringSource(ciphertext, true,
new HexDecoder(new PK_DecryptorFilter(GlobalRNG(), priv, new StringSink(result))));
}
catch(const Exception &e)
{
std::cout << "\nException caught: " << e.what() << std::endl;
return "";
}
catch(const std::exception &e)
{
std::cout << "\nstd::exception caught: " << e.what() << std::endl;
return "";
}
// std::cout << "result: " << result<< std::endl; return result;
}

微信订阅号:

cryptopp使用Qt mingw编译,以及海思平台交叉编译的更多相关文章

  1. 海思平台交叉编译curl支持SSL功能

    1.准备工具 1).交叉编译工具 2).下载libcurl和openssl源代码,我使用的是(openssl-1.0.2o.tar,curl-7.59.0.tar) 3).查看cpu详细 ~ # ca ...

  2. 用VS2013+VELT-0.1.4进行海思平台 Linux内核 的开发

    快乐虾 http://blog.csdn.net/lights_joy/(QQ群:Visual EmbedLinux Tools 375515651) 欢迎转载,但请保留作者信息 本文仅适用于vs20 ...

  3. 【ARM-Linux开发】用VS2013+VELT-0.1.4进行海思平台 Linux内核 的开发

    1.1    什么是VELT VELT的全称是Visual EmbedLinuxTools,它是一个与visual gdb类似的visual studio插件,用以辅助完成Linux开发.利用这个插件 ...

  4. OpenCV开发笔记(七十四):OpenCV3.4.1+ffmpeg3.4.8交叉编译移植到海思平台Hi35xx平台

    前言   移植opencv到海思平台,opencv支持对视频进行解码,需要对应的ffmpeg支持.   Ffmpeg的移植   Ffmpeg的移植请参考之前的文章:<FFmpeg开发笔记(十): ...

  5. 海思平台服务器版软件V15.2产品发布

    深度操作系统海思平台服务器版软件是武汉深之度科技有限公司发布的针对华为海思平台的TaiShan系列服务器发布的企业级服务器操作系统软件产品,主要面向企业级服务器应用场景,为用户在国产化平台上提供更具可 ...

  6. (转)海思平台HI35XX系列内存设置

    海思平台的内存分为两部分,一部分给系统使用,另外的一部分给多媒体使用.可以通过cat /proc/meminfo查看系统内存和cat /proc/media-mem 查看多媒体内存使用情况. /pro ...

  7. libx264开发笔记(一):libx264介绍、海思平台移植编译

    前言   在编译ffmpeg时,使用到h264编码时是需要依赖libx264的,本文章是将将libx264作为静态库移植到海思上.   相关博客 <Qt开发笔记之编码x264码流并封装mp4(一 ...

  8. 用vs2013+velt-0.1.4进行嵌入式开发 进行海思平台 UBOOT 开发

    1.1    什么是VELT VELT的全称是Visual EmbedLinuxTools,它是一个与visual gdb类似的visual studio插件,用以辅助完成Linux开发.利用这个插件 ...

  9. 海思dv300cv500交叉编译webrtc

    感谢声网提供的webrtc国内源码镜像. 首先要安装好海思编译工具链和git. 先替换一下webrtc代码的仓库网址路径 git config --global user.email "10 ...

随机推荐

  1. U盘+grub2安装centos8实战

    1. U盘准备 这里的U盘也可以换成硬盘 grub2安装一直失败,怀疑U盘坏了,下面命令修复了一下 [root@host2 ~]# lsblk NAME MAJ:MIN RM SIZE RO TYPE ...

  2. scala 数据结构(八 ):-map映射操作

    在Scala中可以通过map映射操作来解决: 将集合中的每一个元素通过指定功能(函数)映射(转换)成新的结果集合这里其实就是所谓的将函数作为参数传递给另外一个函数,这是函数式编程的特点 以HashSe ...

  3. 机器学习实战基础(二十六):sklearn中的降维算法PCA和SVD(七) 附录

  4. 数据可视化实例(十六):有序条形图(matplotlib,pandas)

    排序 (Ranking) 棒棒糖图 (Lollipop Chart) 棒棒糖图表以一种视觉上令人愉悦的方式提供与有序条形图类似的目的. https://datawhalechina.github.io ...

  5. Guava集合--Immutable(不可变)集合

    所谓不可变集合,顾名思义就是定义了之后不可修改的集合. 一.为什么要使用不可变集合 不可变对象有很多优点,包括: 当对象被不可信的库调用时,不可变形式是安全的: 不可变对象被多个线程调用时,不存在竞态 ...

  6. 安装调试mosquitto日志

    1.下载mosquitto安装包https://mosquitto.org/download/2.安装其他依赖包 yum install gcc gcc-c++ libstdc++-devel yum ...

  7. 深入了解PHP的生成器

    在驾驶方面,速度并不会决定一切.但是在网络上,速度至关重要.你的应用程序越快,用户体验就越好.好吧,这时候有人就奇怪了,本文是关于PHP 生成器的,那么为什么我们要谈论速度呢?很快你就会发现,生成器在 ...

  8. 京东阅读(web)体验优化

    京东有电子书可以购买,可以多端阅读.比如PC客户端,移动端,以及本文提到的PC网站端. 先换个镜头,读书要记笔记(电子版本), 方便以后查阅. 镜头换回来,但是,我们为了方便肯定是想复制,下载啊,分享 ...

  9. Java应用服务器之tomcat session server msm搭建配置

    在上一篇博客中,我们介绍了tomcat自带的cluster组件配置session replication cluster,回顾请参考https://www.cnblogs.com/qiuhom-187 ...

  10. .log文件超过2.56MB?Pycharm的.log文件读取不完全?.log文件无法被调用?

    问题截图: 问题表现情况: 1.pycharm头部出现上图警告 2.该.log文件读取不完全 3.该.log文件无法被调用 解决步骤: 参考博客:https://blog.csdn.net/Shen1 ...