{"id":3401,"date":"2014-03-24T01:26:38","date_gmt":"2014-03-24T01:26:38","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/24\/c-makefile-with-external-h-and-o-files-collection-of-common-programming-errors\/"},"modified":"2014-03-24T01:26:38","modified_gmt":"2014-03-24T01:26:38","slug":"c-makefile-with-external-h-and-o-files-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/24\/c-makefile-with-external-h-and-o-files-collection-of-common-programming-errors\/","title":{"rendered":"c++ Makefile with external h and o files-Collection of common programming errors"},"content":{"rendered":"<p>I have project files and I need to use an external test file named <code>TestSuite1.cpp<\/code> that includes an external header file <code>SignalMasker.h<\/code> (Was given it and it&#8217;s object file SignalMasker.o) and my main header file <code>uthreads.h<\/code>.<\/p>\n<p>I&#8217;m still getting undefined refrences such as:<\/p>\n<pre><code>TestSuite1.cpp:63: error: undefined reference to 'SignalMasker::~SignalMasker()'\n<\/code><\/pre>\n<p>This means my Makefile isn&#8217;t including the <code>SignalMasker.o<\/code> file that resides in the same directory.<\/p>\n<p>This is my Makefile:<\/p>\n<pre><code>CC = g++\nFLAGS = -Wall -g \n\nOBJECTS = uthreads.o Thread.o Scheduler.o SchedulerStarter.o TestSuite1.o\n\n.PHONY :  clean\n\n\nall: test1\n\ntest1: $(OBJECTS)\n    g++  $(FLAGS) $(OBJECTS) SignalMasker.o -L . -o test1\n\n\nTestSuite1.o  : TestSuite1.cpp SignalMasker.h uthreads.h\n    $(CC) -c $(FLAGS) TestSuite1.cpp\n\nuthreads.o  : uthreads.cpp uthreads.h SchedulerStarter.h Scheduler.h Thread.h\n    $(CC) -c $(FLAGS) uthreads.cpp \n\nScheduler.o  : Scheduler.cpp Scheduler.h Thread.h\n    $(CC) -c $(FLAGS) Scheduler.cpp \n\nSchedulerStarter.o  : SchedulerStarter.cpp SchedulerStarter.h Scheduler.h\n    $(CC) -c $(FLAGS) SchedulerStarter.cpp \n\nThread.o  : Thread.cpp Thread.h uthreads.h translateAdd.h\n    $(CC) -c $(FLAGS) Thread.cpp \n\nclean:\n    rm -f $(OBJECTS) *~\n<\/code><\/pre>\n<p>And now I&#8217;m getting:<\/p>\n<pre><code>~\/Desktop\/tests$ make\ng++  -Wall -g  uthreads.o Thread.o Scheduler.o SchedulerStarter.o TestSuite1.o SignalMasker.o -L . -o test1 \n\/usr\/bin\/ld: error: SignalMasker.o: incompatible target\nTestSuite1.cpp:36: error: undefined reference to 'SignalMasker::SignalMasker(int)'\nTestSuite1.cpp:63: error: undefined reference to 'SignalMasker::~SignalMasker()'\nTestSuite1.cpp:63: error: undefined reference to 'SignalMasker::~SignalMasker()'\nTestSuite1.cpp:68: error: undefined reference to 'SignalMasker::SignalMasker(int)'\nTestSuite1.cpp:111: error: undefined reference to 'SignalMasker::~SignalMasker()'\nTestSuite1.cpp:111: error: undefined reference to 'SignalMasker::~SignalMasker()'\ncollect2: ld returned 1 exit status\n<\/code><\/pre>\n<p><strong>EDIT:<\/strong> I&#8217;m now pondering with the idea that maybe <em>incompatible target<\/em> means they compiled it under 64bit. My machine is 32bit<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I have project files and I need to use an external test file named TestSuite1.cpp that includes an external header file SignalMasker.h (Was given it and it&#8217;s object file SignalMasker.o) and my main header file uthreads.h. I&#8217;m still getting undefined refrences such as: TestSuite1.cpp:63: error: undefined reference to &#8216;SignalMasker::~SignalMasker()&#8217; This means my Makefile isn&#8217;t including [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-3401","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/3401","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=3401"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/3401\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=3401"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=3401"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=3401"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}