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.

相关推荐
繁华似锦respect2 分钟前
C++ 设计模式之观察者模式详细介绍
linux·开发语言·c++·windows·观察者模式·设计模式·visual studio
Iris7612 分钟前
Linux 多网口路由配置实践:解决双网口通讯问题
linux
软件测试慧姐4 分钟前
精简版-Linux常用命令
linux·运维·服务器
威桑4 分钟前
一个 CMake 项目是否只能有一个 install 目录?
linux·c++·cmake
大聪明-PLUS7 分钟前
FFmpeg 组件 - 用途、输入/输出数据、配置
linux·嵌入式·arm·smarc
讨厌下雨的天空7 分钟前
Linux信号中断
linux
a3158238068 分钟前
Linux部署Python Django工程和Node工程,使用宝塔面板
linux·服务器·python·django·node·strapi·宝塔面板
dishugj22 分钟前
Linux系统磁盘性能相关命令详解与实例分析
linux·运维·服务器
代码AC不AC23 分钟前
【Linux】深入理解Linux进程:从概念到实践
linux·进程·pcb·fork
南风~古草35 分钟前
20252803《Linux内核原理与分析》第12周作业-Linux系统监控实战(系统安全实验)
linux·运维·系统安全