title: Compiling Objective-C on Debian 8 GNU/Linux with Clang and GNUstep make
body: <p>On Debian 8 GNU/Linux, I'm trying to compile some Objective-C code from <a href="http://rypress.com/tutorials/objective-c/classes" rel="nofollow noreferrer">this tutorial</a> using Clang and GNUstep make. I ran the following commands to install a build pipeline:</p>
  
  <pre class="lang-sh prettyprint-override"><code>sudo apt-get install build-essential clang gnustep-devel
  </code></pre>
  
  <p>These are the files I am using:</p>
  
  <p>GNUmakefile:</p>
  
  <pre class="lang-none prettyprint-override"><code>CC = clang
  
  include $(GNUSTEP_MAKEFILES)/common.make
  
  TOOL_NAME = Main
  Main_OBJC_FILES = main.m Car.m
  
  include $(GNUSTEP_MAKEFILES)/tool.make
  </code></pre>
  
  <p>main.m:</p>
  
  <pre class="lang-m prettyprint-override"><code>#import &lt;Foundation/Foundation.h&gt;
  #import "Car.h"
  
  int main () {
    @autoreleasepool {
      Car *toyota = [[Car alloc] init];
  
      [toyota setModel:@"Toyota Corolla"];
      NSLog(@"Created a %@", [toyota model]);
  
      toyota.model = @"Toyota Camry";
      NSLog(@"Changed the car to a %@", toyota.model);
  
      [toyota drive];
    }
    return 0;
  }
  </code></pre>
  
  <p>Car.h:</p>
  
  <pre class="lang-m prettyprint-override"><code>#import &lt;Foundation/Foundation.h&gt;
  
  @interface Car : NSObject {}
  
  @property (copy) NSString *model;
  
  - (void)drive;
  
  @end
  </code></pre>
  
  <p>Car.m:</p>
  
  <pre class="lang-m prettyprint-override"><code>#import "Car.h"
  
  @implementation Car {
    double _odometer;
  }
  
  @synthesize model = _model;
  
  - (void)drive {
    NSLog(@"Driving a %@. Vrooom!", self.model);
  }
  
  @end
  </code></pre>
  
  <p>I am compiling with:</p>
  
  <pre class="lang-sh prettyprint-override"><code>. /usr/share/GNUstep/Makefiles/GNUstep.sh &amp;&amp; make -k
  </code></pre>
  
  <p>When I compile, I get the following errors:</p>
  
  <pre class="lang-none prettyprint-override"><code>Car.m:4:10: error: inconsistent number of instance variables specified
    double _odometer;
           ^
  Car.m:7:13: error: synthesized property 'model' must either be named the same as a compatible instance variable or must
        explicitly name an instance variable
  @synthesize model = _model;
  </code></pre>
  
  <p>To fix the errors, I need to update the Car interface to:</p>
  
  <pre class="lang-m prettyprint-override"><code>@interface Car : NSObject {
    NSString * _model;
    double _odometer;
  }
  </code></pre>
  
  <p>And the Car implementation to:</p>
  
  <pre class="lang-m prettyprint-override"><code>@implementation Car {
    NSString * _model;
    double _odometer;
  }
  </code></pre>
  
  <p>It seems like my current compilation setup is forcing me to write more code than the tutorial suggests is needed in order to compile. In fact, in the tutorial, the author specifically recommends against including "protected instance variables" in the interface:</p>
  
  <pre class="lang-m prettyprint-override"><code>@interface Car : NSObject {
      // Protected instance variables (not recommended)
  }
  </code></pre>
  
  <p>I feel like I am using an outdated / misconfigured compilation setup. Am I? If so, how can I fix it so I can write code like in the referenced tutorial? (I'd prefer to use GNUstep make rather than the Clang CLI, if possible.)</p>