[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: OT: converting C to C++ : linkng problems

Joris Huizer wrote:

Sorry for offtopic-posting but I wouldn't directly know where to ask elsewhere... I'd like to ask this question: in some project I try to switch from C to C++ , in order to refactor/learn C++ constructs (that is, classes, inheritance, and such) better There is this problem: it doesn't link correctly; I get link errors such like this:

rm -f lex.yy.cc y.tab.* y.output *.o \
    `find . -name core -o -name \*\.bak` \
    democomp toc \
bison --yacc --defines --debug --verbose spascal.y -o y.tab.cc
g++   -Wall  -g -ggdb    -c y.tab.cc -o y.tab.o
flex --c++  spascal.l
sed -i -e 's/extern "C" int isatty (int );/extern "C" int isatty (int) throw();/g' lex.yy.cc
g++   -Wall  -g -ggdb    -c lex.yy.cc -o lex.yy.o

<snip ... compiling all .cc files using g++ >

g++ -g -o democomp y.tab.o lex.yy.o debug.o list.o symbol.o syntax.o parser.o intermediate.o register.o flowgraph.o dag.o optimize.o inttomips.o mips.o -lfl
y.tab.o(.text+0x46a): In function `yyparse()':
/home/jorishuizer/zooi/coco3-hack/y.tab.cc:1105: undefined reference to `yylex()'
y.tab.o(.text+0x6dd): In function `yyparse()':
/home/jorishuizer/zooi/coco3-hack/spascal.y:116: undefined reference to `selectEndOfTable'
<snip ... lots of these >
Symbols in two files are not found: those in symbol.cc and those in lex.yy.cc (generated with flex)

does someone have any ideas?


Without seeing your source, difficult to say.
I do this lots of time: c->c++
Generally speaking: do the first error first if it is a compilation error.
If it is a linking error, you are doing something wrong in the c++ declarations.


Reply to: