c++ - Undefine reference error for static function -
this question has answer here:
i have below code , getting undefined reference `stinit::instance()'
file stinit.h
class stinit { public: static stinit* instance(); };
file stinit.cc
#include "stinit.h" stinit* stinit::instance() { static stinit *myptr = null; ...... ...... return myptr; }
file nm.cc
#include "stinit.h" stinit* stor_init = stinit::instance();
i don't know why getting error. how resolve error?
you not including 2nd file stinit.cc
binary, hence linker error. not familiar tup, looking @ manual seems need include both files in tup file.
look @ last example in documentation: http://gittup.org/tup/ex_a_first_tupfile.html, copying should going.
so change tupfile
to:
: foreach *.c |> gcc -wall -c %f -o %o |> %b.o : *.o |> gcc %f -o %o |> hello
and hello
should have both files compiled , linked in.
Comments
Post a Comment