zoukankan      html  css  js  c++  java
  • 18.16 gcc-3.4.5编译错误及解决方法集锦

    18.16.1 自写BootLoader错误

    ERROR 01:    
      boot.c:62: warning: return type of 'main' is not `int'
    ANSWER 01:    
      int main(void){
              ……
              return -1;/*执行到这里就出错了*/
      }
    ERROR 02:    
      boot.c: In function `main':【未声明】
      boot.c:68: warning: implicit declaration of function `uart0_init'
      boot.c:70: warning: implicit declaration of function `puts'
      boot.c:71: warning: implicit declaration of function `nand_read'
    ANSWER 02:    
      在函数前声明即可
    ERROR 03:    
      boot.c:75: warning: passing arg 2 of `nand_read' makes pointer from integer without a cast
    ANSWER 03:    
      将整型强制类型转换为指针    
      nand_read(0x60000+64, (unsigned char *)0x30008000, 0x200000);
    ERROR 04:    
      init.c: In function `isBootFromNorFlash':
      init.c:33: warning: integer constant is too large for "long" type
      init.c:33: warning: overflow in implicit constant conversion
      init.c:34: warning: integer constant is too large for "long" type
      init.c:34: warning: comparison is always false due to limited range of data type
    ANSWER 04:    
      是0x12345678不是0x123456789(超出整型2^32)
          volatile int *p = (volatile int *)0;//
          int val;        //用来保存原来的值,在判断完后恢复
          val = *p;
          *p = 0x12345678;
    ERROR 05:    
      init.c:184: warning: conflicting types for built-in function 'puts'
      boot.c:4: warning: conflicting types for built-in function 'puts'
      boot.c:43: warning: conflicting types for built-in function 'strcpy'
    ANSWER 05:    
      /*错误原因:
      *    编译器自带了strcpy和自己写的strcpy函数类型冲突
      *    在Makefile链接的时候加
      *    CPPFLAGS    :=-nostdinc -nostdlib
      */
      The ISO C90 functions 
      abort, abs, acos, asin, atan2, atan, calloc, ceil, cosh,cos, exit, exp, fabs,
      floor, fmod, fprintf, fputs, frexp, fscanf, isalnum, isalpha,iscntrl, isdigit, 
      isgraph, islower, isprint, ispunct, isspace, isupper, isxdigit,tolower, toupper, 
      labs, ldexp, log10, log, malloc, memchr, memcmp, memcpy, memset,modf, 
      pow, printf, putchar, puts, scanf, sinh, sin, snprintf, sprintf, sqrt, sscanf,
      strcat, strchr, strcmp, strcpy, strcspn, strlen, strncat, strncmp, 
      strncpy, strpbrk,strrchr, strspn, strstr, tanh, tan, vfprintf, vprintf and vsprintf 
      are all recognized as built-in functions unless ‘-fno-builtin’ is specified (or ‘-fno-builtin-function’ is specified for an individual function). All of these functions have corresponding versions
      prefixed with __builtin_.
    
      将Makefile中CPPFLAGS       := -nostdinc
      改为CPPFLAGS       := -nostdinc -fno-builtin

    ERROR 06:         

      my_printf.c:(.text+0x120):undefined reference to `__aeabi_uidivmod`

      my_printf.c:(.text+0x158):undefined reference to `__aeabi_uidiv`

    ANSWER 06:   

      /*编译器找不到除法函数*/

      在arm-linux-gcc-4.3.2编译器使用libgcc.a中的除法可以

      在arm-linux-gcc-3.4.5编译器使用lib1funcs.S中的除法可以

    ERROR 07:         

    book@book-desktop:/work/system/linux-2.6.22.6$  sudo make uImage

    编译刚解压的目录时,显示如下错误:

      [sudo] password for lsb: make: arm-linux-gnu-gcc: Command not found

      CHK     include/linux/version.h

      make[1]: `include/asm-arm/mach-types.h' is up to date.

       CHK     include/linux/utsrelease.h

       CC      arch/arm/kernel/asm-offsets.s

      /bin/sh: arm-linux-gnu-gcc: not found

      make[1]: *** [arch/arm/kernel/asm-offsets.s] Error 127

      make: *** [prepare0] Error 2

    ANSWER 07:   

      在根目录下没有权限。

      sudo chmod 777 kernel -R

      其中,kernel为内核目录。

      最值得注意的是:定目录的Makefile 是否该为相对应的交叉工具链



  • 相关阅读:
    UVa
    UVa 1630
    P3891 [GDOI2014]采集资源
    一个非常naive的小学数学魔术证明题
    P2831 [NOIP2016 提高组] 愤怒的小鸟
    P4211 [LNOI2014]LCA
    P4137 Rmq Problem / mex 强制在线做法
    P2272 [ZJOI2007]最大半连通子图
    P5664 [CSP-S2019] Emiya 家今天的饭
    盘点linux操作系统中的10条性能调优命令,一文搞懂Linux系统调优
  • 原文地址:https://www.cnblogs.com/baixu/p/10494535.html
Copyright © 2011-2022 走看看