? 一、zint開源庫的介紹
zint 是一個開源的條碼編碼庫,它支持超過50種條碼,包括 Code-128, Data Matrix, EAN-128, UPC/EAN, ITF, QR Code, Code 16k, PDF417, MicroPDF417, LOGMARS, Maxicode, GS1 DataBar, Aztec, Composite Symbols 等等,基本上你見過的條碼都能用它來進行編碼,它支持直接輸出 PNG 格式的圖像文件和位圖的字節(jié)數(shù)組。
它的開源項目介紹頁面,Zint Barcode Generator download | SourceForge.net 可自行閱讀。
二、zint源碼在linux平臺下的編譯和安裝
編譯平臺介紹:
系統(tǒng)版本 :Red Hat Enterprise Linux6
Linux內(nèi)核版本:Linux localhost.localdomain 2.6.32-71.el6.i686 #1 SMP Wed Sep 1 01:26:34 EDT 2010 i686 i686 i386 GNU/Linux
gcc版本 :4.4.4 20100726 (Red Hat 4.4.4-13) (GCC)
zint版本:zint-2.4.3
編譯步驟:
1) 下載源碼
在開源頁面中下載到對應版本的zint源碼;
Zint Barcode Generator - Browse /zint/2.4.3 at SourceForge.net
筆者下載的版本是zint-2.4.3,對應的壓縮包文件為 zint-2.4.3.tar.gz
將下載的源碼放于一個新的linux的目錄下,比如/zint_src
2) 解壓源碼
cd /zint_src
tar –xvf zint-2.4.3.tar.gz 解壓到當前目錄
解壓完了之后,用ls看一下當前路徑,如果有zint-2.4.3文件夾生成,且里面有文件,解壓過程沒有報錯,則表示解壓成功了。
3) 閱讀編譯指南
cd zint-2.4.3
vi readme-cmake
里面的內(nèi)容如下:
how to :
mkdir build
cd build
cmake ..
make [-j nr_proc+1]
make install
4) 開始正式編譯
mkdir build
cd build
cmake ..
執(zhí)行后這句后,成功的話就會提示 Build files have been written to: /zint_src/zint-2.4.3/build
這個時候ls一下當前目錄就會發(fā)現(xiàn)有makefile了,我們就可以使用make直接來安裝了
make install
輸入完后,會看到百分比提示了:
【筆者第一次make install報錯了,是因為windows主機和linux虛擬機之間使用了共享文件,剛好做so文件軟鏈接的時候就報錯了,如下:】
[root@localhost build]# make install
Scanning dependencies of target zint
[ 1%] Building C object backend/CMakeFiles/zint.dir/common.c.o
[ 3%] Building C object backend/CMakeFiles/zint.dir/library.c.o
[ 5%] Building C object backend/CMakeFiles/zint.dir/render.c.o
.....[中間省略]
[ 55%] Building C object backend/CMakeFiles/zint.dir/code1.c.o
[ 57%] Building C object backend/CMakeFiles/zint.dir/gridmtx.c.o
Linking C shared library libzint.so
CMake Error: cmake_symlink_library: System Error: Operation not supported
CMake Error: cmake_symlink_library: System Error: Operation not supported
make[2]: *** [backend/libzint.so.2.4.1] 錯誤 1
make[1]: *** [backend/CMakeFiles/zint.dir/all] 錯誤 2
make: *** [all] 錯誤 2
[root@localhost build]#
如果按照一開始將源碼放于/zint_src (非主機與虛擬機的共享目錄),則可以很順利的編譯和安裝,如下:
root@localhost build]# make install
Scanning dependencies of target zint
[ 1%] Building C object backend/CMakeFiles/zint.dir/common.c.o
[ 3%] Building C object backend/CMakeFiles/zint.dir/library.c.o
[ 5%] Building C object backend/CMakeFiles/zint.dir/render.c.o
[ 7%] Building C object backend/CMakeFiles/zint.dir/ps.c.o
[ 9%] Building C object backend/CMakeFiles/zint.dir/large.c.o
[ 11%] Building C object backend/CMakeFiles/zint.dir/reedsol.c.o
.....[中間省略]
[ 53%] Building C object backend/CMakeFiles/zint.dir/code49.c.o
[ 55%] Building C object backend/CMakeFiles/zint.dir/code1.c.o
[ 57%] Building C object backend/CMakeFiles/zint.dir/gridmtx.c.o
Linking C shared library libzint.so
[ 57%] Built target zint
Scanning dependencies of target zint_frontend
[ 59%] Building C object frontend/CMakeFiles/zint_frontend.dir/main.c.o
Linking C executable zint
[ 59%] Built target zint_frontend
Scanning dependencies of target QZint
[ 61%] Building CXX object backend_qt4/CMakeFiles/QZint.dir/qzint.cpp.o
Linking CXX shared library libQZint.so
[ 61%] Built target QZint
[ 63%] Generating qrc_resources.cxx
[ 65%] Generating moc_mainwindow.cxx
[ 67%] Generating moc_datawindow.cxx
[ 69%] Generating moc_sequencewindow.cxx
[ 71%] Generating moc_exportwindow.cxx
[ 73%] Generating ui_mainWindow.h
[ 75%] Generating ui_extData.h
[ 76%] Generating ui_extSequence.h
[ 78%] Generating ui_extExport.h
Scanning dependencies of target zint-qt
[ 80%] Building CXX object
frontend_qt4/CMakeFiles/zint-qt.dir/barcodeitem.cpp.o
[ 82%] Building CXX object frontend_qt4/CMakeFiles/zint-qt.dir/main.cpp.o
[ 84%] Building CXX object
frontend_qt4/CMakeFiles/zint-qt.dir/mainwindow.cpp.o
[ 86%] Building CXX object
frontend_qt4/CMakeFiles/zint-qt.dir/datawindow.cpp.o
[ 88%] Building CXX object
frontend_qt4/CMakeFiles/zint-qt.dir/sequencewindow.cpp.o
[ 90%] Building CXX object
frontend_qt4/CMakeFiles/zint-qt.dir/exportwindow.cpp.o
[ 92%] Building CXX object
frontend_qt4/CMakeFiles/zint-qt.dir/moc_mainwindow.cxx.o
[ 94%] Building CXX object
frontend_qt4/CMakeFiles/zint-qt.dir/moc_datawindow.cxx.o
[ 96%] Building CXX object
frontend_qt4/CMakeFiles/zint-qt.dir/moc_sequencewindow.cxx.o
[ 98%] Building CXX object
frontend_qt4/CMakeFiles/zint-qt.dir/moc_exportwindow.cxx.o
[100%] Building CXX object
frontend_qt4/CMakeFiles/zint-qt.dir/qrc_resources.cxx.o
Linking CXX executable zint-qt
[100%] Built target zint-qt
Install the project...
-- Install configuration: "RelWithDebInfo"
-- Installing: /usr/share/cmake/Modules/FindZint.cmake
-- Installing: /usr/local/lib/libzint.so.2.4.1
-- Installing: /usr/local/lib/libzint.so.2.4
-- Installing: /usr/local/lib/libzint.so
-- Installing: /usr/local/include/zint.h
-- Installing: /usr/local/bin/zint
-- Installing: /usr/local/lib/libQZint.so.2.4.1
-- Installing: /usr/local/lib/libQZint.so.2.4
-- Installing: /usr/local/lib/libQZint.so
-- Installing: /usr/local/include/qzint.h
-- Installing: /usr/local/bin/zint-qt
到這里zint庫就已經(jīng)安裝好了。
5) 測試zint和libzint
通過第4步后已經(jīng)完成了安裝,這個步驟我們來試一下zint和libzint如下:
先看下libzint是否安裝成功,
[root@localhost build]# ls -al /usr/local/lib/libzint.so
lrwxrwxrwx. 1 root root 14 10月 16 17:20 /usr/local/lib/libzint.so ->
libzint.so.2.4
則正是zint動態(tài)庫已經(jīng)鏈接完成。
測試zint 如下:
在終端輸入 zint –h
[liluchang@localhost src]$ zint -h
Zint version 2.4.1
Encode input data in a barcode and save as a PNG, EPS or SVG file.
-h, --help Display this message.
-t, --types Display table of barcode types
-i, --input=FILE Read data from FILE.
-o, --output=FILE Write image to FILE. (default is out.png)
-d, --data=DATA Barcode content.
-b, --barcode=NUMBER Number of barcode type (default is 20 (=Code128)).
--height=NUMBER Height of symbol in multiples of x-dimension.
-w, --whitesp=NUMBER Width of whitespace in multiples of x-dimension.
--border=NUMBER Width of border in multiples of x-dimension.
--box Add a box.
--bind Add boundary bars.
-r, --reverse Reverse colours (white on black).
--fg=COLOUR Specify a foreground colour.
--bg=COLOUR Specify a background colour.
--scale=NUMBER Adjust size of output image.
--directpng Send PNG output to stdout
--directeps Send EPS output to stdout
--directsvg Send SVG output to stdout
--dump Dump binary data to stdout
--rotate=NUMBER Rotate symbol (PNG output only).
--cols=NUMBER (PDF417) Number of columns.
--vers=NUMBER (QR Code) Version
--secure=NUMBER (PDF417 and QR Code) Error correction level.
--primary=STRING (Maxicode and Composite) Structured primary message.
--mode=NUMBER (Maxicode and Composite) Set encoding mode.
--gs1 Treat input as GS1 data
--binary Treat input as Binary data
--notext Remove human readable text
--square Force Data Matrix symbols to be square
--init Create reader initialisation symbol (Code 128)
--smalltext Use half-size text in PNG images
--batch Treat each line of input as a separate data set
error: No data received, no symbol generated
[liluchang@localhost src]$
能看到版本信息,證明zint這個bin文件已經(jīng)安裝好了。
至此zint和libzint的安裝已全部結(jié)束,筆者在安裝的過程中,幾乎使用的默認路徑,感興趣的童鞋可以試著修改一些自定義的安裝路徑,可以定制化自己的zint和libzint。
本章介紹到此結(jié)束,下一篇將介紹如何使用libzint生成二維碼,敬請關(guān)注。
-
嵌入式
+關(guān)注
關(guān)注
5082文章
19104瀏覽量
304807 -
Linux
+關(guān)注
關(guān)注
87文章
11292瀏覽量
209327 -
編程
+關(guān)注
關(guān)注
88文章
3614瀏覽量
93686 -
zint
+關(guān)注
關(guān)注
0文章
1瀏覽量
1005
發(fā)布評論請先 登錄
相關(guān)推薦
評論