移植minilogger
在sdk中找到minilogger,复制到任意的文件夹,执行
cmake ./
make
make install
把minilogger 安装到系统
修改Makefile
在上次那个基础上,修改Makefile
#* 这里原来要包含../Makefile.param,但含有sdk的很多参数,放弃
#*ifeq ($(APP_PARAM), )
#* APP_PARAM:=../Makefile.param
#* include $(APP_PARAM)
#*endifexport LC_ALL=C
SHELL:=/bin/bashCURRENT_DIR := $(shell pwd)
#* 取消这个项,不用安装不用复制
#* PKG_INSTALL_TO_ROOTFS ?= NO
PKG_NAME := ipcweb-backend
PKG_BIN ?= out
PKG_BUILD ?= build
#* RK_APP_ARCH_TYPE在Makefile.param里面定义 Makefile.param RK_APP_ARCH_TYPE:=arm
RK_APP_ARCH_TYPE:=arm
PKG_TARBALL := ipcweb-backend/ipcweb-env-$(RK_APP_ARCH_TYPE)
PKG_TARPATH ?= $(PKG_BIN)/
# debug: build cmake with more message
# PKG_CONF_OPTS += -DCMAKE_VERBOSE_MAKEFILE=ON
##* RK_APP_MEDIA_INCLUDE_PATH 是sdk里面media的头文件路径,放弃
#* RK_APP_CFLAGS = -I $(RK_APP_MEDIA_INCLUDE_PATH) \
#* -I $(CURRENT_DIR)/$(PKG_TARPATH)/include \#* 只包含out文件夹里面的include
RK_APP_CFLAGS = -I $(CURRENT_DIR)/$(PKG_TARPATH)/includeRK_APP_LDFLAGS = -L $(CURRENT_DIR)/$(PKG_TARPATH)/usr/lib/#* RK_APP_OPTS 也是sdk里面的库和头文件路径,放弃
#* RK_APP_OPTS += -Wl,-rpath-link,$(RK_APP_MEDIA_LIBS_PATH):$(RK_APP_PATH_LIB_INCLUDE)/root/usr/lib
PKG_CONF_OPTS += -DCMAKE_C_FLAGS="$(RK_APP_CFLAGS) $(RK_APP_LDFLAGS) $(RK_APP_OPTS) -g -O0" \-DCMAKE_CXX_FLAGS="$(RK_APP_CFLAGS) $(RK_APP_LDFLAGS) $(RK_APP_OPTS) -g -O0"# define project/cfg/BoardConfig*.mk#* RK_APP_IPCWEB_BACKEND 是编译开关
RK_APP_IPCWEB_BACKEND = y
ifeq ($(RK_APP_IPCWEB_BACKEND),y)
PKG_TARGET := ipcweb-build
endififeq ($(PKG_BIN),)
$(error ### $(CURRENT_DIR): PKG_BIN is NULL, Please Check !!!)
endifall: $(PKG_TARGET)@echo "build $(PKG_NAME) done"ipcweb-build:@rm -rf $(PKG_BIN) $(PKG_TARPATH) && mkdir -p $(PKG_TARPATH) $(PKG_BIN) $(PKG_BUILD);@cp -rfa $(PKG_TARBALL)/include $(PKG_TARPATH)/;@cp -rfa $(PKG_TARBALL)/usr $(PKG_TARPATH)/;@echo "PKG_TARPATH is $(PKG_TARPATH)";
#* 修改gcc和g++ pushd $(PKG_BUILD)/; \rm -rf CMakeCache.txt; \cmake $(CURRENT_DIR)/$(PKG_NAME)/ \-DCMAKE_C_COMPILER=gcc \-DCMAKE_CXX_COMPILER=g++ \-DCMAKE_INSTALL_PREFIX="$(CURRENT_DIR)/$(PKG_BIN)" \-DCMAKE_BUILD_TYPE=Release \-DCMAKE_COLOR_MAKEFILE=OFF \-DCMAKE_SYSTEM_NAME=Linux \-DUSE_RKIPC=ON \$(PKG_CONF_OPTS) ;\make -j6 || exit -1; \make install; \popd;(mkdir -p $(PKG_BIN)/usr;mv $(PKG_BIN)/www $(PKG_BIN)/usr;);#* 因为在ubuntu上运行,所以不需要安装到rootfs,也不需要把配置复制。
#* ifeq ($(PKG_INSTALL_TO_ROOTFS),YES)
#* @cp -rfa $(PKG_TARBALL)/etc $(PKG_TARPATH)/;
#* @cp -rfa $(PKG_TARBALL)/usr $(PKG_TARPATH)/;
#* else
#* @cp -rfa $(PKG_TARBALL)/etc4oem $(PKG_TARPATH)/etc
#* endif
#*这两项安装的放弃
#* @test ! -d $(PKG_BIN)/root/include || mv $(PKG_BIN)/root/include $(PKG_BIN)/;
#* $(call MAROC_COPY_PKG_TO_APP_OUTPUT, $(RK_APP_OUTPUT), $(PKG_BIN))clean:@rm -rf $(PKG_BIN) $(PKG_BUILD) $(PKG_TARPATH)distclean: clean
C_BLACK = \e[30;1m
C_RED = \e[31;1m
C_GREEN = \e[32;1m
C_YELLOW = \e[33;1m
C_BLUE = \e[34;1m
C_PURPLE = \e[35;1m
C_CYAN = \e[36;1m
C_WHITE = \e[37;1m
C_NORMAL = \033[0m
info:
ifeq ($(RK_APP_IPCWEB_BACKEND),y)@echo -e "$(C_YELLOW)-------------------------------------------------------------------------$(C_NORMAL)"@echo -e "$(C_YELLOW)-------------------------------------------------------------------------$(C_NORMAL)"
endif
修改 ipcweb-backend/CMakeLists.txt
修改ipcweb-backend/CMakeLists.txt,增加对MiniLogger支持
#
# Copyright 2019 Fuzhou Rockchip Electronics Co., Ltd. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
#
cmake_minimum_required(VERSION 3.5)list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
project(ipcweb-backendLANGUAGES CXX)
set(DESCRIPTION "IP Camera web backend cgi projects")option(IPCWEBBACKEND_BUILD_TESTS "Build tests executables" OFF)
option(ENABLE_JWT "enbale jwt" OFF)
option(MEDIASERVER_ROCKFACE "enbale mediaserver rockface" OFF)
option(USE_RKIPC "use rkipc" OFF)set(PROJECT_THIRDPARTY_DIR "${CMAKE_SOURCE_DIR}/thirdparty")
include(clang-format)
include(cppcheck)if (NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR NOT DEFINED CMAKE_SYSTEM_PROCESSOR)message(FATAL_ERROR "This project can only be built for linux")
endif()set(TARGET_HOST ${CMAKE_SYSTEM_PROCESSOR}-linux)if (${USE_RKIPC})
#find_package(jwt_cpp REQUIRED)
find_package(MiniLogger REQUIRED)
else()
find_package(MiniLogger REQUIRED)
find_package(Cgicc)
find_package(nlohmann_json REQUIRED)
find_package(jwt_cpp REQUIRED)
find_package(OpenSSL REQUIRED)
endif()include(GNUInstallDirs)
if (${IPCWEBBACKEND_BUILD_TESTS})enable_testing()add_subdirectory(thirdparty/googletest)add_subdirectory(test)
endif()
if (${ENABLE_JWT})add_definitions(-DENABLE_JWT)
endif()
if (${MEDIASERVER_ROCKFACE})add_definitions(-DMEDIASERVER_ROCKFACE)
endif()
if (${USE_RKIPC})add_definitions(-DUSE_RKIPC "-fno-rtti -fno-exceptions -Os")
endif()
add_subdirectory(src)
修改ipcweb-backend/src/rest_api.h
修改ipcweb-backend/src/rest_api.h使用minilogger
// *改为1使用mimilogger
#if 1
#include "minilogger/backtrace.h"
#include "minilogger/log.h"
#else
#define minilog_warn(...)
#define minilog_error(...)
#define minilog_info(...)
#define minilog_debug(...)
#define __minilog_log_init(...)
#endif
更改ipcweb-backend/src/system_api.c
强制status返回0, auth返回1, 注意,第一个才是使用#ifdef USE_RKIPC 为真的
//res.emplace("status", id_mark);//res.emplace("auth", 0);res.emplace("status", 0);res.emplace("auth", 1);
编译
在顶层文件夹中make
设置nginx的位置
server {listen 80;server_name localhost;# location /live {
# flv_live on;
# }#charset koi8-r;#access_log logs/host.access.log main;location / {root ~/ipcweb/out/usr/www;index index.html index.htm;}location ~* \.(mp4|bmp)$ {root /usr/www;if ($request_uri ~* view$) {add_header Content-Disposition inline;}if ($request_uri !~* view$) {add_header Content-Disposition attachment;}}# error_page 404 /404.html;error_page 404 /;# redirect server error pages to the static page /50x.html## error_page 500 502 503 504 /50x.html;# location = /50x.html {# root html;# }location /cgi-bin/ {gzip off;root ~/ipcweb/out/usr/www;fastcgi_pass unix:/var/run/fcgiwrap.socket;fastcgi_index entry.cgi;fastcgi_param DOCUMENT_ROOT unix:/var/run/fcgiwrap.socket/cgi-bin;fastcgi_param SCRIPT_NAME /entry.cgi;include fastcgi_params;set $path_info "";set $real_script_name $fastcgi_script_name;if ($fastcgi_script_name ~ "^(.+?\.cgi)(/.+)$") {set $real_script_name $1;set $path_info $2;}fastcgi_param PATH_INFO $path_info;fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;fastcgi_param SCRIPT_NAME $real_script_name;}
把nginx的根目录盒cgi目录设置为新编译好文件的位置
安装 fcgiwrap
sudo apt-get install fcgiwrap
sudo systemctl start fcgiwrap
重启 nginx
sudo systemctl restar nginx
登录测试
进到登录页面以后,输入任意的账号密码都能进入系统