title: Using C Headers in C++
body: <p>I have searched the googles for this and have found that you use</p>
  
  <pre><code>extern "C" {
  #include "header.h"
  }
  </code></pre>
  
  <p>To include a C library inside of a C++ library... however, when I do this. The C++ program seems to pick up all my #defines and struct definitions but none of the function declarations leaving me with undefined reference to `function'.</p>
  
  <p>Here is a minimal amount of src I am using.</p>
  
  <p>json.h</p>
  
  <pre><code>//json.h
  typedef struct json_object json_object;
  struct json_object {
      char key[15][50];
      int size;
      char value[15][50];
  };
  void json_parseText(char * text, struct json_object *jo);
  </code></pre>
  
  <p>test.cpp</p>
  
  <pre><code>//test.cpp
  extern "C" {
      #include "json.h"
  }
  
  int main() {
      struct json_object jo;
      char * keyVal;
      char * text = "{ \"MsgType\": \"article\" }";
  
      json_parseText(text, &amp;jo);
  }
  </code></pre>
  
  <p>g++ yields the following:</p>
  
  <pre><code>test.cpp:(.text+0x2c): undefined reference to `json_parseText'
  </code></pre>
  
  <p>notice that it is not complaining about the struct definition, so it seems like it got that from the header file. But not the function. This baffles me. I have never used C++ before now, but for my testing framework it must be in C++. Let me know if you have any thoughts on how to fix this. Thanks.</p>