Note that there are some explanatory texts on larger screens.

plurals
  1. POMy makefile isn't working
    primarykey
    data
    text
    <p>I'm new to C++, switching over from Java for a class I'm taking in college. In our first assignment we have to write several makefiles for our code. My first makefile isn't working - it always complains about an error in "TempControlTest: undefined reference to 'BangBangControl::XXXX', where XXXX a function in BangBangControl (I get errors for every function in BangBangControl). I've been looking around online and all the makefile examples look slightly different so I can't tell what I'm doing wrong. I'll post all my code below, if anyone could just give me a little help, that would be AWESOME. Also, this is due tonight, so any quick help is appreciated so much. If you're still here, thanks very much!</p> <p>HeatingUnit.h:</p> <pre><code>#ifndef HEATINGUNIT_H #define HEATINGUNIT_H class HeatingUnit { private: bool on; int temp; public: HeatingUnit(bool o, int t); void turnOn(); void turnOff(); int tick(); }; #endif </code></pre> <p>HeatingUnit.cpp:</p> <pre><code>#include "HeatingUnit.h" HeatingUnit::HeatingUnit(bool o, int t) { on = o; temp = t; } void HeatingUnit::turnOn() { on = true; } void HeatingUnit::turnOff() { on = false; } int HeatingUnit::tick() { if(on) return ++temp + 1; else return --temp; } </code></pre> <p>BangBangControl.h:</p> <pre><code>#ifndef BANGBANGCONTROL_H #define BANGBANGCONTROL_H #include "HeatingUnit.h" class BangBangControl { private: int tempToKeep; HeatingUnit unit; public: BangBangControl(int ttk, bool on, int initTemp); void setTemp(int t); int getTemp(); void update(); }; #endif </code></pre> <p>BangBangControl.cpp:</p> <pre><code>#include "HeatingUnit.h" #include "BangBangControl.h" BangBangControl::BangBangControl(int ttk, bool on, int initTemp) : unit(on, initTemp) { tempToKeep = ttk; } void BangBangControl::setTemp(int t) { tempToKeep = t; } int BangBangControl::getTemp() { return tempToKeep; } void BangBangControl::update() { int currentTemp = unit.tick(); if(currentTemp &gt; tempToKeep + 2) unit.turnOff(); else if(currentTemp &lt; tempToKeep - 2) unit.turnOn(); } </code></pre> <p>TempControlTest.cpp:</p> <pre><code>include &lt;iostream&gt; #include "BangBangControl.h" using namespace std; int main() { BangBangControl bang(100, false, 60); for(int i = 0; i &lt; 50; i++) { bang.update(); cout &lt;&lt; bang.getTemp() &lt;&lt; " "; if(i % 10 == 9) cout &lt;&lt; endl; } } </code></pre> <p>And finally, Makefile_Executable:</p> <pre><code>all: TempControlTest TempControlTest: TempControlTest.cpp BangBangControl.o g++ -o TempControlTest TempControlTest.cpp BangBangControl.o: BangBangControl.cpp HeatingUnit.o g++ -c BangBangControl.cpp HeatingUnit.o: HeatingUnit.cpp g++ -c HeatingUnit.cpp clean: rm -rf *.o TempControlTest </code></pre> <p>Again, thank you very much!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload