1.网上下载goahead-3.1.2-0-src.tgz包
2.解压
tar -zxvf goahead-3.1.2-0-src.tgz
3.编译
cd goahead-3.1.2-0
make CC=arm-hisiv100-linux-gcc ARCH=arm
在linux-arm-default/bin中可以找到goahead和相关库文件,将库文件拷贝到板子/lib下
4.测试
运行./goahead -v /web 192.168.1.155:9000
问题1:
goahead: 0: Can't get host address for host dvr: errno 11
goahead: 0: Can't initialize server. Exiting.
出处:goahead-3.1.1-0\src\http.c文件的setLocalHost函数
修改:
#if 0 if ((hp = gethostbyname(host)) == NULL) { //MHB 2013-10-22 error("Can't get host address for host %s: errno %d", host, errno); return -1; } memcpy((char*) &intaddr, (char *) hp->h_addr_list[0], (size_t) hp->h_length); ipaddr = inet_ntoa(intaddr); #else //MHB 2013-10-22 换种方式获取ip地址 (ipv4) int sockfd; struct sockaddr_in sin; struct ifreq ifr; sockfd = socket(AF_INET, SOCK_DGRAM, 0); if (sockfd == -1) { return -1; } strncpy(ifr.ifr_name, "eth0", IFNAMSIZ); //网卡多的得修改下 ifr.ifr_name[IFNAMSIZ - 1] = 0; if (ioctl(sockfd, SIOCGIFADDR, &ifr) < 0) { return -1; } memcpy(&sin, &ifr.ifr_addr, sizeof(sin)); ipaddr=inet_ntoa(sin.sin_addr); #endif websSetIpAddr(ipaddr); websSetHost(ipaddr);
问题2:
goahead: 0: Can't open config file route.txt
goahead: 0: Can't initialize server. Exiting.
解决方法:
拷贝goahead-3.1.1-0\src\route.txt文件到goahead同目录下
问题3:
网页存放位置
/web目录,启动是
可以指定。