当前位置: 首页 » 网站建设 » 网站制作知识 » 正文

Windows 下编译 GNU barcode 库

发布时间:2025-01-10 以下文章来源于网友投稿,内容仅供参考!

gnu barcode 是一个用来生成条形码的库。主页在:
gnu/software/barcode/

对这个库就不多介绍了。

因为装了 MSYS2, 本来觉得编译这个库很简单,configure, make, make install 三步就够了。结果 第二步 mingw32make 时就出了错,提示:

make allrecursive
process_begin: CreateProcess(NULL, make allrecursive, …) failed.
make (e=2): 系统找不到指定的文件。
mingw32make: *** [Makefile:1271: all] Error 2

没找到解决办法。 只能想别的办法编译了。既然 MSYS2 编译出了点问题,那就用 VS 吧。

仔细翻了翻源代码,发现只要编译几个 C 文件就行:
codabar 、code11 、 code128 、code39 、code93 、 ean、i25 、 library 、 msi 、 plessey 、pcl 、ps、svg。

cmd main 和 sample 这三个不用管。

为了编译成 Dll,还需要个 barcode.def 文件。手写了一份:

1 ; gnu barcode library 2 EXPORTS 3 ; basic functions 4 Barcode_Create 5 Barcode_Encode 6 Barcode_Position 7 Barcode_Print 8 Barcode_Encode_and_Print 9 Barcode_Version 10 11 ; advanced functions

至此,准备工作就差不多了。我没用 VS 的IDE ,用了 qtcreator。 这个 IDE 比较轻量,还可以手写 .pro 文件。

下面是我们写的 barcode.pro 文件:

1 # 2 # 3 # Project created by QtCreator 20200522T21:57:07 4 # 5 # 6 7 VERSION = 0.99 8 QT = core gui 9 10 ConFIG += dll 11 TEMPLATE = lib 12 13 #DEFINES += GNUBARCODE_LIBRARY 14 # The following define makes your cpiler emit warnings if you use 15 # any feature of Qt which has been marked as deprecated (the exact warnings 16 # depend on your cpiler). Please consult the documentation of the 17 # deprecated API in order to know how to port your code away fr it. 18 DEFINES += QT_DEPRECATED_WARNINGS 19 20 # You can also make your code fail to cpile if you use deprecated APIs. 21 # In order to do so, uncment the following line. 22 # You can also select to disable deprecated APIs only up to a certain version of Qt. 23 #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 24 25 SOURCES += \ 26 codabar \ 27 code11 \ 28 code128 \ 29 code39 \ 30 code93 \ 31 ean \ 32 i25 \ 33 library \ 34 msi \ 35 plessey \ 36 pcl \ 37 ps \ 38 svg 39 40 HEADERS += \ 41 barcode.h \ 42 config.h 43 44 unix 48 49 win32 else 65 }

编译时还会提示一些错误,如下:

错误 1:
barcode.h:29: error: C1083: 无法打开包括文件: “gettext.h”: No such file or directory

解决办法:去掉对 gettext.h 的包含。

/// #include// 这行注释掉

/// #define _(X) gettext (X) //改为:#define _(X) (X)

错误 2:
library:29: error: C1083: 无法打开包括文件: “unistd.h”: No such file or directory

解决办法:将 config.h 文件中 #define HAVE_UNISTD_H 1
改为:

#undef HAVE_UNISTD_H

之后就可以正常的生成 dll 和 lib 文件了。


  • • VisualStdio2022使用JetBrainsMono字体

    背景听说这个字体是最方便程序员的,那么为了追赶潮流我也理当试试。第一步:下载与安装下载【官网】JetBrains Mono: A free and

  • • Fiddler 汉化补丁

    汉化过程:1.安装Fiddler,比如我的Fiddler安装在:D:\Programs\Fiddler2.将FiddlerTexts.txt复制到D:\Programs\Fiddler\3.将FdT

  • • Qt Creator9.0生成工程后没有.pro文件

    Qt Creator9.0 默认建立的widget项目只有CMakeLists.txt文件,没有pro文件发现生成工程文件时默认选择的是cmake,不是qmake导致

  • • Qt Creator 9.0 设置代码编辑器JetBrainsMono字体

    下载github/JetBrains/JetBrainsMono/releases解压将下载的压缩包中的ttf文件拷贝到C:\Qt\Tools\QtCreator\share\qtcreator\fo

  • • Qt 6.5快速安装(Windows)

    前言本文仅适用于初学者参考!!!如有错误和疑问请指出安装步骤1.进入Index of /qt/archive/online_installers/ | 清华大学开源

  • 中国人民银行汇率查询
    银联汇率
    360文库
    腾讯广告推广平台入口
    360移动开放平台
    360广告投放平台
    360广告联盟平台官网
    京东联盟官网登录入口
    微盟官网
    阿里妈妈官网
    首都之窗网站:http://www.beijing.gov.cn
    北京人民政府网站:www.beijing.gov.cn
    国家互联网信息办公室网站:http://www.scio.gov.cn
    全国人社政务服务平台:http://www.12333.gov.cn
    中央人民政府门户网站:www.gov.cn
    沈阳政务服务平台:http://zwfw.shenyang.gov.cn
    广东省公共机构能源资源消费统计工作指南
    黑龙江政务服务平台:http://zwfw.hlj.gov.cn
    公共机构能源资源消费统计系统:http://nyzyxftj.ggj.gov.cn
    国家能源局网站:http://www.nea.gov.cn