title: Runtime error when compiling Objective-C project using g++
body: <p>I've made a really small project using Objective-C, and If I run it with the Xcode, It works really well.</p>
  <p>But, I need to compile it using below command lines:</p>
  <pre><code>g++ Main.mm -o Main `gnustep-config --objc-flags` `gnustep-config --base-libs` -O2 -DONLINE_JUDGE -DBOJ
  </code></pre>
  <p>This command line is what the site I'm trying to upload my code to compile uses to compile Objective-C projects.</p>
  <p>But, whenever I compile whit that command line, I get runtime errors for using <code>NSMutableArray</code>, <code>NSSet</code> and <code>NSString</code>.</p>
  <p>Errors:</p>
  <pre><code>zsh: command not found: gnustep-config
  zsh: command not found: gnustep-config
  Undefined symbols for architecture x86_64:
    &quot;_OBJC_CLASS_$_NSMutableArray&quot;, referenced from:
        objc-class-ref in Main-49f6e3.o
    &quot;_OBJC_CLASS_$_NSSet&quot;, referenced from:
        objc-class-ref in Main-49f6e3.o
    &quot;_OBJC_CLASS_$_NSString&quot;, referenced from:
        objc-class-ref in Main-49f6e3.o
    &quot;___CFConstantStringClassReference&quot;, referenced from:
        CFString in Main-49f6e3.o
    &quot;_objc_msgSend&quot;, referenced from:
        _main in Main-49f6e3.o
    &quot;_objc_opt_new&quot;, referenced from:
        _main in Main-49f6e3.o
  ld: symbol(s) not found for architecture x86_64
  clang: error: linker command failed with exit code 1 (use -v to see invocation)
  </code></pre>
  <p>And, here is my source code:</p>
  <pre class="lang-c prettyprint-override"><code>#import &lt;Foundation/Foundation.h&gt;
  
  int main(void) {
      int num = 0;
      int answer = 0;
      scanf(&quot;%i&quot;, &amp;num);
      NSMutableArray *cl = [NSMutableArray new];
      
      for (int k = 0; k &lt; num; k++) {
          char str[4];
          getchar();
          scanf(&quot;%[^\n]s&quot;, str);
          NSString *userInput = [NSString stringWithUTF8String:str];
          
          if (userInput.length == 1) {
              [cl removeObjectAtIndex:0];
          } else {
              [cl addObject:[userInput substringFromIndex:[userInput length] - 1]];
          }
          
          NSMutableArray *result = [NSMutableArray new];
          for (int i = 1; i &lt;= cl.count; i++) {
              for (int j = 0; j &lt;= cl.count-i; j++) {
                  [result addObject:[[cl subarrayWithRange:NSMakeRange(j, i)] componentsJoinedByString:@&quot;&quot;]];
              }
          }
          
          answer += [[NSSet setWithArray:result] allObjects].count;
      }
      
      printf(&quot;%d\n&quot;, answer%1000000007);
      
      return 0;
  }
  </code></pre>