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

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 文件了。


  • • php curl_exec写了两个

    PHP中的curl_exec是一个非常有用的函数,它用于执行一个CURL会话并获取结果。在某些情况下,我们可能需要执行多个CURL请求,这时

  • • php curl_exec返回值头

    PHP的curl_exec函数是一个强大的工具,在网络通信方面非常有用。它可以发送HTTP请求并返回响应结果。当我们调用curl_exec函数时

  • • php curl_init语法错误

    在使用PHP开发过程中,我们经常会用到curl库来进行网络请求。而curl_init()函数则是curl库中非常重要的一个函数,它的作用是初始

  • • php curl_post是做什么的

    在PHP中,有一个很常用的函数叫做curl_post。这个函数主要用于发送POST请求,并获取服务器返回的响应。通过curl_post函数,我们

  • • php curl_setopt设置请求头

    在使用PHP的curl库发送HTTP请求时,我们可以通过curl_setopt函数来设置请求头,以便定制化我们的请求。设置请求头可以为我们提供

  • 植物大战僵尸原版电脑下载
    植物大战僵尸1老版本中文版下载
    免费看mv大片的app下载
    google play store最新版本下载
    谷歌商店app下载
    我的VR女友2.0安卓版下载
    囧次元动漫app正版下载
    ehviewer白色版官网入口下载
    gg修改器官网下载
    漫蛙2官方下载
    小雪节气吃什么?小雪节气吃什么传统食物最好
    小雪的古诗词有哪些?小雪的古诗词经典名诗
    小雪是什么意思?小雪是什么意思含义
    小雪节气一般气温多少?小雪节气的天气特点
    小雪三候分别是哪三候?小雪三候指的是什么
    小雪节气有哪些风俗?小雪节气的由来特点及风俗
    2025年中秋节多少号?中秋节一般是农历几月
    2025年中秋节法定假日几天?2025年中秋节放假时间是几号
    2025年中秋节农历几月几日?中秋节一般是几月几日
    2025年中秋节放假几天?2025年中秋节放假安排时间表