lbubox是openwrt的一個核心庫,封裝了一系列基礎實用功能,主要提供事件循環,二進制格式處理,linux鏈表實現和一些JSON輔助處理。
它的目的是以動態鏈接庫方式來提供可重用的通用功能,給其他模塊提供便利和避免再造輪子。
libubox主要提供三部分功能:
1)提供多種基礎通用功能接口,包含鏈表,平衡二叉樹,二進制處理,key-value鏈表,MD5等。
2)socket通信。
3)一套基于事件驅動的機制及任務隊列管理功能。
編譯安裝到PC
1.?修改目錄下CMakelists.txt,先去掉lua部分(不使用lua)。
#OPTION(BUILD_LUA "build Lua plugin" ON) #ADD_SUBDIRECTORY(lua)
2. cmake編譯安裝
mkdir build; cd build ; cmake .. ; make; make install
[ 4%] Built target blobmsg_json-static [ 38%] Built target ubox-static [ 72%] Built target ubox [ 76%] Built target blobmsg_json [ 80%] Built target jshn [ 84%] Built target json_script [ 88%] Built target blobmsg-example [ 92%] Built target runqueue-example [ 96%] Built target ustream-example [100%] Built target json_script-example Install the project... -- Install configuration: "" -- Up-to-date: /usr/local/include/libubox/kvlist.h -- Up-to-date: /usr/local/include/libubox/json_script.h -- Up-to-date: /usr/local/include/libubox/blobmsg_json.h -- Up-to-date: /usr/local/include/libubox/ulog.h -- Up-to-date: /usr/local/include/libubox/avl-cmp.h -- Up-to-date: /usr/local/include/libubox/blob.h -- Up-to-date: /usr/local/include/libubox/runqueue.h -- Up-to-date: /usr/local/include/libubox/uloop.h -- Up-to-date: /usr/local/include/libubox/list.h -- Up-to-date: /usr/local/include/libubox/ustream.h -- Up-to-date: /usr/local/include/libubox/vlist.h -- Up-to-date: /usr/local/include/libubox/avl.h -- Up-to-date: /usr/local/include/libubox/blobmsg.h -- Up-to-date: /usr/local/include/libubox/safe_list.h -- Up-to-date: /usr/local/include/libubox/usock.h -- Up-to-date: /usr/local/include/libubox/md5.h -- Up-to-date: /usr/local/include/libubox/utils.h -- Installing: /usr/local/lib/libubox.so -- Installing: /usr/local/lib/libubox.a -- Installing: /usr/local/lib/libblobmsg_json.so -- Set runtime path of "/usr/local/lib/libblobmsg_json.so" to "" -- Installing: /usr/local/lib/libblobmsg_json.a -- Installing: /usr/local/bin/jshn -- Set runtime path of "/usr/local/bin/jshn" to "" -- Installing: /usr/local/lib/libjson_script.so -- Set runtime path of "/usr/local/lib/libjson_script.so" to "" -- Up-to-date: /usr/local/share/libubox/jshn.sh
?
參考文檔:
libubox組件(1)——usock
libubox組件(2)——blob/blobmsg
libubox組件(3)——uloop
BLOB二進制對象(blob.c/h)
libubox [4] - uloop runqueue ustream