Note that there are some explanatory texts on larger screens.

plurals
  1. POproblem finding a header with a c++ makefile
    text
    copied!<p>I've started working with my first makefile. I'm writing a roguelike in C++ using the libtcod library, and have the following hello world program to test if my environment's up and running:</p> <pre><code>#include "libtcod.hpp" int main() { TCODConsole::initRoot(80, 50, "PartyHack"); TCODConsole::root-&gt;printCenter(40, 25, TCOD_BKGND_NONE, "Hello World"); TCODConsole::flush(); TCODConsole::waitForKeypress(true); } </code></pre> <p>My project directory structure looks like this:</p> <pre><code>/CppPartyHack ----/libtcod-1.5.1 # this is the libtcod root folder --------/include ------------libtcod.hpp ----/PartyHack --------makefile --------partyhack.cpp # the above code </code></pre> <p>(while we're here, how do I do proper indentation? Using those dashes is silly.)</p> <p>and here's my makefile: </p> <p><pre><code> SRCDIR = . INCDIR = ../libtcod-1.5.1/include CFLAGS = $(FLAGS) -I$(INCDIR) -I$(SRCDIR) -Wall CC = gcc CPP = g++ .SUFFIXES: .o .h .c .hpp .cpp</p> <p>$(TEMP)/%.o : $(SRCDIR)/%.cpp $(CPP) $(CFLAGS) -o $@ -c $&lt; $(TEMP)/%.o : $(SRCDIR)/%.c $(CC) $(CFLAGS) -o $@ -c $&lt; </p> <p>CPP_OBJS = $(TEMP)partyhack.o</p> <p>all : partyhack</p> <p>partyhack : $(CPP_OBJS) $(CPP) $(CPP_OBJS) -o $@ -L../libtcod-1.5.1 -ltcod -ltcod++ -Wl,-rpath,.</p> <p>clean : \rm -f $(CPP_OBJS) partyhack </pre></code></p> <p>I'm using Ubuntu, and my terminal gives me the following errors:</p> <p>max@max-desktop:~/Desktop/Development/CppPartyhack/PartyHack$ make<br> g++ -c -o partyhack.o partyhack.cpp<br> partyhack.cpp:1:23: error: libtcod.hpp: No such file or directory<br> partyhack.cpp: In function ‘int main()’:<br> partyhack.cpp:5: error: ‘TCODConsole’ has not been declared<br> partyhack.cpp:6: error: ‘TCODConsole’ has not been declared<br> partyhack.cpp:6: error: ‘TCOD_BKGND_NONE’ was not declared in this scope<br> partyhack.cpp:7: error: ‘TCODConsole’ has not been declared<br> partyhack.cpp:8: error: ‘TCODConsole’ has not been declared<br> make: *** [partyhack.o] Error 1</p> <p>So obviously, the makefile can't find libtcod.hpp. I've double checked and I'm sure the relative path to libtcod.hpp in INCDIR is correct, but as I'm just starting out with makefiles, I'm uncertain what else could be wrong. My makefile is based off a template that the libtcod designers provided along with the library itself, and while I've looked at a few online makefile tutorials, the code in this makefile is a good bit more complicated than any of the examples the tutorials showed, so I'm assuming I screwed up something basic in the conversion. Thanks for any help.</p>
 

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