ubus安装+开机自启动ubusd
安装教程来自以下:安装ubus:https://segmentfault.com/a/1190000012061795安装json-c,libubox:https://segmentfault.com/a/1190000012017022安装ubus之前需要先安装json-c,再安装libubox,最后安装ubusubus下载:git clone git://nbd.name...
·
安装教程来自以下:
安装ubus:https://segmentfault.com/a/1190000012061795
安装json-c,libubox:https://segmentfault.com/a/1190000012017022
安装ubus之前需要先安装json-c,再安装libubox,最后安装ubus
ubus下载:
git clone git://nbd.name/luci2/ubus.git
json-c下载:
git clone https://github.com/json-c/json-c.git
libubox下载:
git clone http://git.openwrt.org/project/libubox.git
补充:编译安装ubus时可能出现json头文件找不到的问题,因为安装libubox时只生成libblobmsg_json.a静态库没有生成.so文件,可以这样修改:
cmake_minimum_required(VERSION 2.6)
INCLUDE(CheckLibraryExists)
INCLUDE(CheckFunctionExists)
ADD_DEFINITIONS(-DJSONC)
INCLUDE_DIRECTORIES("/usr/local/include/json-c")
INCLUDE_DIRECTORIES("/usr/local/include")
INCLUDE_DIRECTORIES("/usr/local/lib")
SET(CMAKE_INSTALL_PREFIX "/usr/bin/libubox")
PROJECT(ubox C)
ADD_DEFINITIONS(-Os -Wall -Werror --std=gnu99 -g3 -Wmissing-declarations)
OPTION(BUILD_LUA "build Lua plugin" ON)
OPTION(BUILD_EXAMPLES "build examples" ON)
INCLUDE(FindPkgConfig)
PKG_SEARCH_MODULE(JSONC json-c)
IF(JSONC_FOUND)
ADD_DEFINITIONS(-DJSONC)
INCLUDE_DIRECTORIES(${JSONC_INCLUDE_DIRS})
ENDIF()
SET(SOURCES avl.c avl-cmp.c blob.c blobmsg.c uloop.c usock.c ustream.c ustream-fd.c vlist.c utils.c safe_list.c runqueue.c md5.c kvlist.c ulog.c base64.c)
ADD_LIBRARY(ubox SHARED ${SOURCES})
ADD_LIBRARY(ubox-static STATIC ${SOURCES})
SET_TARGET_PROPERTIES(ubox-static PROPERTIES OUTPUT_NAME ubox)
SET(LIBS)
CHECK_FUNCTION_EXISTS(clock_gettime HAVE_GETTIME)
IF(NOT HAVE_GETTIME)
CHECK_LIBRARY_EXISTS(rt clock_gettime "" NEED_GETTIME)
IF(NEED_GETTIME)
TARGET_LINK_LIBRARIES(ubox rt)
ENDIF()
ENDIF()
FILE(GLOB headers *.h)
INSTALL(FILES ${headers}
DESTINATION include/libubox
)
INSTALL(TARGETS ubox ubox-static
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
)
#ADD_SUBDIRECTORY(lua)
#ADD_SUBDIRECTORY(examples)
find_library(json NAMES json-c)
IF(EXISTS ${json})
ADD_LIBRARY(blobmsg_json SHARED blobmsg_json.c)
TARGET_LINK_LIBRARIES(blobmsg_json ubox ${json})
ADD_LIBRARY(blobmsg_json-static STATIC blobmsg_json.c)
SET_TARGET_PROPERTIES(blobmsg_json-static
PROPERTIES OUTPUT_NAME blobmsg_json)
ADD_EXECUTABLE(jshn jshn.c)
TARGET_LINK_LIBRARIES(jshn blobmsg_json ${json})
ADD_LIBRARY(json_script SHARED json_script.c)
TARGET_LINK_LIBRARIES(json_script ubox)
INSTALL(TARGETS blobmsg_json-static json_script
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
)
FILE(GLOB scripts sh/*.sh)
INSTALL(FILES ${scripts}
DESTINATION share/libubox
)
ENDIF()
最后将.so文件放进.a的目录下或者放进/usr/lib目录就好
开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!
更多推荐
已为社区贡献1条内容
所有评论(0)