c++ - Undefine reference error for static function -


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

Popular posts from this blog

javascript - ScrollTo Effect (href to div) -

javascript - document.registerElement extending HTMLInputElement prototype while using custom tag name to avoid implicit browser style -

javascript - How do I find how many occurences are there of a highlighted string, and which occurence is it? -