title: Linker error: "linker input file unused because linking not done", undefined reference to a function in that file
body: <p>I'm having trouble with the linking of my files.</p>
  
  <p>Basically, my program consists of:</p>
  
  <ul>
  <li>The main program, <code>gen1</code>.</li>
  <li><code>gen1</code> - receives input sends to <code>str2value</code> for
  processing, outputs results <code>str2value</code>, breaks input into tokens
  using "tokenizer" determines what sort of processing to do to each
  token, and passes them off to <code>str2num</code>, or <code>str2cmd</code>. It then returns an
  array of the results.</li>
  <li><code>str2num</code> - does some processing</li>
  <li><code>str2cmd</code> - ditto</li>
  <li><code>author.py</code> - a python script that generates <code>str2cmd.c</code> and <code>str2cmd.h</code> from a header <code>cmdTable.h</code>.</li>
  </ul>
  
  <p>I'm pretty sure I have my includes right, I've checked a couple of times. I've also checked that there are no conditions <code>#ifndef</code> wrong in the headers.</p>
  
  <p>Here is my Makefile:</p>
  
  <pre><code>#CPP = g++ -lserial
  CPP = g++ -DTESTMODE
  C= gcc
  DEFINES = LURC
  CFLAGS = -Wall -fshort-enums -D$(DEFINES)
  PROJECTFILES = gen1.cpp str2value.o
  
  STR2VALUEFILES = str2value.cpp str2cmd.o str2num.o tokenizer.o str2value.h
  
  gen1 : $(PROJECTFILES)
          $(CPP) $(CFLAGS) -o gen1 $(PROJECTFILES)
  
  
  
  str2value.o : $(STR2VALUEFILES)
  #       echo "str2value"
          $(CPP) $(CFLAGS) -c $(STR2VALUEFILES)
  
  str2num.o: str2num.cpp  str2value.h str2num.hpp
           $(C) $(CFLAGS) -c $^
  
  
  tokenizer.o: tokenizer.cpp tokenizer.hpp
          $(CPP) $(CFLAGS) -c $^
  
  str2cmd.o : authorCMDs.py cmdTable.h
          python authorCMDs.py cmdTable.h str2cmd #this uses the gcc -E cmdTable.h -DLURC
          $(C) $(CFLAGS) -c str2cmd.c str2cmd.h
  
  #TODO: add a thing that checks str2cmd.h/.c has not been modified by hand
  
  
  
  .PHONEY: clean
  clean:
          rm *.o
  
  .PHONEY: all
  all:
          clear
          make clean
          make
  </code></pre>
  
  <p>Here is the output I recieve from make all:</p>
  
  <pre><code>make clean
  make[1]: Entering directory `/home/frames/LURC/gen1/gen1Source'
  rm *.o
  make[1]: Leaving directory `/home/frames/LURC/gen1/gen1Source'
  make
  make[1]: Entering directory `/home/frames/LURC/gen1/gen1Source'
  python authorCMDs.py cmdTable.h str2cmd #this uses the gcc -E cmdTable.h -DLURC
  str2cmd.c and str2cmd.h, generated from cmdTable.h
  
  gcc  -Wall -fshort-enums -DLURC -c str2cmd.c str2cmd.h
  gcc  -Wall -fshort-enums -DLURC -c str2num.cpp str2value.h str2num.hpp
  g++ -DTESTMODE -Wall -fshort-enums -DLURC -c tokenizer.cpp tokenizer.hpp
  g++ -DTESTMODE -Wall -fshort-enums -DLURC -c str2value.cpp str2cmd.o str2num.o tokenizer.o str2value.h
  g++: str2cmd.o: linker input file unused because linking not done
  g++: str2num.o: linker input file unused because linking not done
  g++: tokenizer.o: linker input file unused because linking not done
  g++ -DTESTMODE -Wall -fshort-enums -DLURC -o gen1 gen1.cpp str2value.o
  str2value.o: In function `getValue(char*)':
  str2value.cpp:(.text+0xbd): undefined reference to `str2cmd(char*)'
  str2value.cpp:(.text+0x102): undefined reference to `str2num(char*)'
  str2value.o: In function `getAllValues(char*)':
  str2value.cpp:(.text+0x164): undefined reference to `tokenizer::tokenizer(char*)'
  str2value.cpp:(.text+0x177): undefined reference to `tokenizer::getNumTokens(char const*)'
  str2value.cpp:(.text+0x1a9): undefined reference to `tokenizer::getNextToken(char const*)'
  str2value.cpp:(.text+0x1e9): undefined reference to `tokenizer::getNumTokens(char const*)'
  str2value.cpp:(.text+0x201): undefined reference to `tokenizer::~tokenizer()'
  str2value.cpp:(.text+0x25b): undefined reference to `tokenizer::~tokenizer()'
  collect2: ld returned 1 exit status
  make[1]: *** [gen1] Error 1
  make[1]: Leaving directory `/home/frames/LURC/gen1/gen1Source'
  make: *** [all] Error 2
  </code></pre>
  
  <p>Any suggestions about what this is about? <code>STR2VALUESFILES</code> has all the object files I need, to define the missing functions.</p>