天天看点

goahead移植

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函数 

     修改: 

[html]  view plain copy

goahead移植
goahead移植
  1. #if 0     
  2.     if ((hp = gethostbyname(host)) == NULL) {   //MHB 2013-10-22     
  3.         error("Can't get host address for host %s: errno %d", host, errno);     
  4.         return -1;     
  5.     }     
  6.     memcpy((char*) &intaddr, (char *) hp->h_addr_list[0], (size_t) hp->h_length);     
  7.     ipaddr = inet_ntoa(intaddr);     
  8. #else   //MHB 2013-10-22 换种方式获取ip地址 (ipv4)     
  9.     int sockfd;      
  10.     struct sockaddr_in sin;      
  11.     struct ifreq ifr;            
  12.     sockfd = socket(AF_INET, SOCK_DGRAM, 0);         
  13.     if (sockfd == -1)   {                
  14.         return -1;               
  15.     }            
  16.     strncpy(ifr.ifr_name, "eth0", IFNAMSIZ);    //网卡多的得修改下     
  17.     ifr.ifr_name[IFNAMSIZ - 1] = 0;          
  18.     if (ioctl(sockfd, SIOCGIFADDR, &ifr) < 0)    {                
  19.         return -1;       
  20.     }        
  21.     memcpy(&sin, &ifr.ifr_addr, sizeof(sin));        
  22.     ipaddr=inet_ntoa(sin.sin_addr);      
  23. #endif     
  24.     websSetIpAddr(ipaddr);     
  25.     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目录,启动是 可以指定。