how to build tbox xml into the demo

I saw https://blog.csdn.net/gitblog_00889/article/details/151057353 says the tbox tool has xml reader/writer functions. so

I download the code from https://github.com/tboox/tbox/releases/tag/v1.7.7 , then unzip it.

build the xml functions into the demo as following steps:

  1. cd tbox-1.7.7 and ./configure

  2. modified tbox.config.h under build/linux/x86_64/release, add one line

    #define TB_CONFIG_MODULE_HAVE_XML 1

modified demo.c under src/demo, add one line

复制代码
#define TB_CONFIG_MODULE_HAVE_XML 1
  1. make
    it reports

    /usr/bin/ld: build/.objs/demo/linux/x86_64/release/src/demo/demo.c.o:(.rodata+0x98): undefined reference to tb_demo_xml_reader_main' /usr/bin/ld: build/.objs/demo/linux/x86_64/release/src/demo/demo.c.o:(.rodata+0xa8): undefined reference to tb_demo_xml_writer_main'
    /usr/bin/ld: build/.objs/demo/linux/x86_64/release/src/demo/demo.c.o:(.rodata+0xb8): undefined reference to `tb_demo_xml_document_main'
    collect2: error: ld returned 1 exit status
    make: *** [makefile:1417: build/linux/x86_64/release/demo] Error 1

  2. then I add following lines into makefile

    build/.objs/demo/linux/x86_64/release/src/demo/xml/document.c.o: src/demo/xml/document.c
    @echo compiling.release src/demo/xml/document.c
    @mkdir -p build/.objs/demo/linux/x86_64/release/src/demo/xml
    (VV)(cc) -c $(demo_cflags) -o build/.objs/demo/linux/x86_64/release/src/demo/xml/document.c.o src/demo/xml/document.c

    build/.objs/demo/linux/x86_64/release/src/demo/xml/reader.c.o: src/demo/xml/reader.c
    @echo compiling.release src/demo/xml/reader.c
    @mkdir -p build/.objs/demo/linux/x86_64/release/src/demo/xml
    (VV)(cc) -c $(demo_cflags) -o build/.objs/demo/linux/x86_64/release/src/demo/xml/reader.c.o src/demo/xml/reader.c

    build/.objs/demo/linux/x86_64/release/src/demo/xml/writer.c.o: src/demo/xml/writer.c
    @echo compiling.release src/demo/xml/writer.c
    @mkdir -p build/.objs/demo/linux/x86_64/release/src/demo/xml
    (VV)(cc) -c $(demo_cflags) -o build/.objs/demo/linux/x86_64/release/src/demo/xml/writer.c.o src/demo/xml/writer.c

    build/.objs/tbox/linux/x86_64/release/src/tbox/xml/node.c.o: src/tbox/xml/node.c
    @echo compiling.release src/tbox/xml/node.c
    @mkdir -p build/.objs/tbox/linux/x86_64/release/src/tbox/xml
    (VV)(cc) -c $(tbox_cflags) -o build/.objs/tbox/linux/x86_64/release/src/tbox/xml/node.c.o src/tbox/xml/node.c

    build/.objs/tbox/linux/x86_64/release/src/tbox/xml/reader.c.o: src/tbox/xml/reader.c
    @echo compiling.release src/tbox/xml/reader.c
    @mkdir -p build/.objs/tbox/linux/x86_64/release/src/tbox/xml
    (VV)(cc) -c $(tbox_cflags) -o build/.objs/tbox/linux/x86_64/release/src/tbox/xml/reader.c.o src/tbox/xml/reader.c

    build/.objs/tbox/linux/x86_64/release/src/tbox/xml/writer.c.o: src/tbox/xml/writer.c
    @echo compiling.release src/tbox/xml/writer.c
    @mkdir -p build/.objs/tbox/linux/x86_64/release/src/tbox/xml
    (VV)(cc) -c $(tbox_cflags) -o build/.objs/tbox/linux/x86_64/release/src/tbox/xml/writer.c.o src/tbox/xml/writer.c

I also add strings at the end of following two positions,

复制代码
tbox: build/linux/x86_64/release/libtbox.a
build/linux/x86_64/release/libtbox.a: 
...
build/.objs/tbox/linux/x86_64/release/src/tbox/xml/node.c.o build/.objs/tbox/linux/x86_64/release/src/tbox/xml/reader.c.o build/.objs/tbox/linux/x86_64/release/src/tbox/xml/writer.c.o
...
build/.objs/tbox/linux/x86_64/release/src/tbox/xml/node.c.o build/.objs/tbox/linux/x86_64/release/src/tbox/xml/reader.c.o build/.objs/tbox/linux/x86_64/release/src/tbox/xml/writer.c.o


demo: build/linux/x86_64/release/demo
build/linux/x86_64/release/demo: 
...
build/.objs/demo/linux/x86_64/release/src/demo/xml/document.c.o build/.objs/demo/linux/x86_64/release/src/demo/xml/reader.c.o build/.objs/demo/linux/x86_64/release/src/demo/xml/writer.c.o
...
build/.objs/demo/linux/x86_64/release/src/demo/xml/document.c.o build/.objs/demo/linux/x86_64/release/src/demo/xml/reader.c.o build/.objs/demo/linux/x86_64/release/src/demo/xml/writer.c.o
  1. run make again

    It build the demo and libtbox.a under /build/linux/x86_64/release .

  2. run

    build/linux/x86_64/release/demo xml_writer a.xml

it build the file a.xml.

复制代码
build/linux/x86_64/release/demo xml_reader a.xml
<?xml version = "1.0" encoding = "utf-8" ?>
<!--comments ...-->
<labels name = "hello world">


        <label_1 label = "1" id = "1">

                characters

        </label_1>


        <label_2 id = "2" bool = "true">

                characters

        </label_2>


        <label_3 label = "3" id = "3">

                characters

                <label_4 id = "-4" bool = "false"/>


                <label_5/>


        </label_3>


        <![CDATA[datas]]>
</labels>

it print the content of the file a.xml we just wrote. adding the blank lines as above,

复制代码
build/linux/x86_64/release/demo xml_document a.xml b.xml

it wrote the content of the file a.xml to b.xml, also adding the blank lines as above.

相关推荐
Y1rong1 天前
linux之网络
linux
寄存器漫游者1 天前
Linux 软件编程 - IO 编程
linux·运维·spring
2的n次方_1 天前
CANN Ascend C 编程语言深度解析:异构并行架构、显式存储层级与指令级精细化控制机制
c语言·开发语言·架构
_别来无恙_1 天前
TFTP的使用Linux
linux·服务器
Zaralike1 天前
Linux 服务器网络不通排查 SOP(标准操作流程)
linux·服务器·网络
_F_y1 天前
C语言重点知识总结(含KMP详细讲解)
c语言·开发语言
getapi1 天前
注塑件的费用构成
linux·服务器·ubuntu
郝学胜-神的一滴1 天前
深入解析C/S模型下的TCP通信流程:从握手到挥手的技术之旅
linux·服务器·c语言·网络·网络协议·tcp/ip
释怀不想释怀1 天前
Linux网络基础(ip,域名)
linux·网络·tcp/ip
初願致夕霞1 天前
Linux_进程
linux·c++