栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > C/C++/C#

用C++条码扫描SDK测试龙芯3A5000的二进制翻译

C/C++/C# 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

用C++条码扫描SDK测试龙芯3A5000的二进制翻译

本文主要记录了Dynamsoft Barcode Reader(DBR)在龙芯3A5000上的运行测试。感谢子扉提供的ssh主机。

龙芯3A5000国产CPU采用自主研发的LoongArch架构,支持以软硬结合的方式翻译arm、mips和x86架构的应用。Dynamsoft Barcode Reader是用C++编写的条码/二维码扫描SDK,并支持用Javascript、Java、Objective-C、Python等语言进行调用。

目前DBR还没有LoongArch架构的库,这里主要以二进制翻译的形式运行x86的程序,记录解下面两张图分别用的时间。

扫码结果(时间单位为秒):

图1图2
Wine 32bit0.0861.207
WebAssembly0.2540.397

在Intel i5 10400的Windows设备上的解码时间分别为: 0.016, 0.187。可以看到运行速度存在一定差距。

下面具体的测试过程:

Linux x86-64

x86-64端编译这个仓库的Linux二进制文件,并在龙芯上运行,但显示错误:

lophyxp@sancog:/tmp/dbr$ ./BarcodeReader
latx-x86_64: ./BarcodeReader: requires virtual address space that is in use (omit the -B option or choose a different value)

可以看到系统会用翻译器来运行,但不清楚这里错误的原因,暂时不测试了。

Windows x86

Windows上编译这个项目的32位二进制文件,并在龙芯上使用wine运行。这里因为没搞定wine的64位环境,测的32位版。

  1. 安装wine

    $ sudo apt install wine
    
  2. 可以发现wine的二进制文件是x86的

    lophyxp@sancog:~$ file /opt/wine-6.0/bin/wine
    /opt/wine-6.0/bin/wine: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.2, for GNU/Linux 3.2.0, BuildID[sha1]=18bb34b3edf8be645836f13cdd815c1fd3ef94b0, with debug_info, not stripped
    
  3. 直接运行DBR

    lophyxp@sancog:/tmp/dbr_x86$ wine ./BarcodeReaderDemo.exe
    *************************************************
    Welcome to Dynamsoft Barcode Reader Demo
    *************************************************
    Hints: Please input 'Q'or 'q' to quit the application.
    >> Step 1: Input your image file's full path:
    
Java

DBR的Java版用JNI调用的C++库,在龙芯上运行会提示无法加载提供的Linux AMD64的库。看来只有直接运行可执行程序时才会进行二进制翻译。

$ java -jar BarcodeReader.jar
java.lang.UnsatisfiedlinkError: /tmp/dynamsoft/8.8/libDynamsoftBarcodeJNI.so: /tmp/dynamsoft/8.8/libDynamsoftBarcodeJNI.so: 无法打开共享对象文 件: 没有那个文件或目录 (Possible cause: can't load AMD 64-bit .so on a LOONGARCH64-bit platform)
WebAssembly

DBR的JS版采用WebAssembly编译,可以直接用node运行。

代码仓库:https://github.com/xulihang/Loongson-3A5000-Barcode-Reading-Test

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/690022.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号