安装flex包

安装flex包出错:

arm-marvell-linux-gnueabi-gcc  -g -O2   -o flex  ccl.o dfa.o ecs.o scanflags.o gen.o main.o misc.o nfa.o parse.o scan.o skel.o sym.o tblcmp.o yylex.o options.o scanopt.o buf.o tables.o tables_shared.o filter.o regex.o  -lm

scan.o: In function `rpl_malloc':

/home/bao/flex-2.5.35/scan.c:17: multiple definition of `rpl_malloc'

dfa.o:/home/bao/flex-2.5.35/dfa.c:49: first defined here

dfa.o: In function `ntod':

dfa.c:(.text+0x1b30): undefined reference to `rpl_realloc'

scan.o: In function `flex_realloc':

scan.c:(.text+0x43c): undefined reference to `rpl_realloc'

scan.o: In function `yyrealloc':

scan.c:(.text+0x440): undefined reference to `rpl_realloc'

collect2: ld returned 1 exit status

make[2]: *** [flex] Error 1

make[2]: Leaving directory `/home/bao/flex-2.5.35'

make[1]: *** [all-recursive] Error 1

make[1]: Leaving directory `/home/bao/flex-2.5.35'

make: *** [all] Error 2

 

 

这是autoconf的一个BUG

 

解决方法:

 

第一步:在./configure前设置两个环境变量如下:

export ac_cv_func_realloc_0_nonnull=${ac_cv_func_realloc_0_nonnull=yes}

export ac_cv_func_realloc_works=${ac_cv_func_realloc_works=yes}

第二步:在dfa.c中加入

void *malloc ();

/* Allocate an N-byte block of memory from the heap.

   If N is zero, allocate a 1-byte block.  */   

void* rpl_malloc (size_t n)

{

  if (n == 0)

    n = 1;

  return malloc (n);

}

你可能感兴趣的:(安装flex包)