【问题标题】:linux flex gcc compile fails with `undefined reference to `TclReError'`linux flex gcc 编译失败,“未定义对 `TclReError' 的引用”
【发布时间】:2016-10-15 08:59:29
【问题描述】:

我在从源代码编译 flex 时遇到一些问题。配置正在通过 CC=/home/mybin/bin/gcc CPPFLAGS=-I/home/mybin/include LDFLAGS=-L/home/mybin/lib.

在 ../include 我有两个包含引用的文件

regex.h:110:#define regerror    TclReError
regcustom.h:78:#define  regerror    TclReError

运行配置时,不会产生错误,并且日志中没有任何感兴趣的内容,但是 make 会抛出错误

     /bin/sh ../libtool  --tag=CC   --mode=link /home/mybin/bin/gcc  -g -O2  -L/home/mybin/lib -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 ../lib/libcompat.la -lm 
libtool: link: /home/mybin/bin/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  -L/home/_bin/lib ../lib/.libs/libcompat.a -lm
regex.o: In function `flex_regcomp':
/home/tmp/flex-2.6.0/src/regex.c:66: undefined reference to `TclReError'
collect2: error: ld returned 1 exit status
make[2]: *** [flex] Error 1

在 configure --help 中没有提及显式标志

Some influential environment variables:

  CC          C compiler command
  CFLAGS      C compiler flags
  LDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries in a
              nonstandard directory <lib dir>
  LIBS        libraries to pass to the linker, e.g. -l<library>
  CPPFLAGS    (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
              you have headers in a nonstandard directory <include dir>
  LT_SYS_LIBRARY_PATH
              User-defined run-time library search path.
  CPP         C preprocessor
  YACC        The `Yet Another Compiler Compiler' implementation to use.
              Defaults to the first program found out of: `bison -y', `byacc',
              `yacc'.
  YFLAGS      The list of arguments that will be passed by default to $YACC.
              This script will default YFLAGS to the empty string to avoid a
              default value of `-d' given by some make applications.
  CXX         C++ compiler command
  CXXFLAGS    C++ compiler flags
  CXXCPP      C++ preprocessor

我也试过直接用export CPPFLAGS="-I/home/mybin/include"导出

在 SO 和 google 上的扩展搜索返回了明显的结果,任何关于我缺少什么的指针?

【问题讨论】:

  • 去掉双引号,试试看:export CPPFLAGS=-I/home/mybin/include
  • 尝试了引用和不引用,同样的错误。还尝试在调用 make 之前在 bash 脚本中显式设置。没有运气
  • 你试过用CFLAGS代替CPPFLAGS吗?
  • @MarkPlotnick 从downloads.sourceforge.net/project/flex/flex-2.6.0.tar.gz 下载,直接 tar -xzf flex-2.6.0.tar.gz。你有其他我可以尝试的回购吗?
  • 两个数据包与beyond compare相比是相同的

标签: c++ c linux gcc flex-lexer


【解决方案1】:

您将它们设置为环境变量; configure 通过检查配置文件和环境来确定 LDFLAGSCPPFLAGS。你可以这样试试。

  export CPPFLAGS='-I/home/mybin/include'
  export LDFLAGS='-L/home/mybin/lib'
  ./configure

或单线:

 env CPPFLAGS='-I/home/mybin/include' LDFLAGS='-L/home/mybin/lib' ./configure

请试试这个...

【讨论】:

  • 很有趣,我将它作为一个衬里而不是 bash 脚本进行了尝试,得到的输出略有不同 regex.c:(.text+0xfd): undefined reference to TclReError'`
猜你喜欢
  • 1970-01-01
  • 2021-06-08
  • 1970-01-01
  • 2015-08-25
  • 1970-01-01
  • 2018-11-25
  • 2021-01-14
  • 1970-01-01
  • 2013-06-12
相关资源
最近更新 更多