Andruk Tatum
December 30th, 2007, 03:10 AM
Hi, I'm learning C++, and the book I have has me building a CLI calculator.
I keep getting an "undefined reference" error when I build/compile my project with g++ as follows:
g++ calc.cc
This is the exact output:
/tmp/ccisJFOE.o: In function `main':
calc.cc:(.text+0x10f): undefined reference to `(anonymous namespace)::init()'
calc.cc:(.text+0x17b): undefined reference to `(anonymous namespace)::flag()'
collect2: ld returned 1 exit status
I'm using Anjuta to code it out, and that had the same result (expected, as I think Anjuta uses g++).
I have also tried building the author's code, which resulted in the same errors, but it had his namespace, not the "anonymous namespace".
The relevant files are attached, but here's the rundown:
calc.cc - the main part of the program
err.cc & err.h - the error handling implementation and header
prompt.cc & prompt.h - the UI implementation and header
I've looked it over (perhaps too much) and rewritten it several times, and nothing has worked. Do I have a typo somewhere? What am I doing wrong?
I'm sure I'll look back on this and cringe.
I keep getting an "undefined reference" error when I build/compile my project with g++ as follows:
g++ calc.cc
This is the exact output:
/tmp/ccisJFOE.o: In function `main':
calc.cc:(.text+0x10f): undefined reference to `(anonymous namespace)::init()'
calc.cc:(.text+0x17b): undefined reference to `(anonymous namespace)::flag()'
collect2: ld returned 1 exit status
I'm using Anjuta to code it out, and that had the same result (expected, as I think Anjuta uses g++).
I have also tried building the author's code, which resulted in the same errors, but it had his namespace, not the "anonymous namespace".
The relevant files are attached, but here's the rundown:
calc.cc - the main part of the program
err.cc & err.h - the error handling implementation and header
prompt.cc & prompt.h - the UI implementation and header
I've looked it over (perhaps too much) and rewritten it several times, and nothing has worked. Do I have a typo somewhere? What am I doing wrong?
I'm sure I'll look back on this and cringe.