title: How to create and using vapi files?
body: <p>I want to make a custom vapi file, I have the basic stuff but I obviously miss something and I can't find anywhere how to do this properly. My main goal is to create a torent app, using <a href="http://www.libtorrent.org/" rel="nofollow noreferrer">libtorrent</a>, and create the GUI (the frontend?) with vala and gtk.</p>
  <p>I have a c_func_head.h:</p>
  <pre><code>#ifndef WHATEVER_H_INCLUDED
  #define WHATEVER_H_INCLUDED
  int add(int a, int b);
  #endif
  </code></pre>
  <p>c_functions.c:</p>
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &quot;c_func_head.h&quot;
  
  int add(int a, int b){
    printf(&quot;Adding numbers in c...\n&quot;);
    return a+b;
  }
  </code></pre>
  <p>vala_p.vapi:</p>
  <pre><code>[CCode (cheader_filename = &quot;c_func_head.h&quot;)]
  namespace MyFunc {
      [CCode (cname = &quot;add&quot;)]
      public int add (int a, int b);
  }
  </code></pre>
  <p>and finally vala_program.vala:</p>
  <pre><code>//extern int add(int a, int b);
  using MyFunc;
  
  void main(){
      stdout.printf(&quot;Calling a c function...\n&quot;);
      //stdout.printf(&quot;The sum is: %d\n&quot;, add2number(2, 2));
      int sum = add(2, 2);
      stdout.printf(&quot;The sum is: %d\n&quot;, sum);
  }
  </code></pre>
  <p>As you can see I used an extern too, it worked with it but I want to use vapi files.</p>
  <p>I compiled with (everything is in the same folder):</p>
  <blockquote>
  <p>valac vala_program.vala --vapidir=vala_p.vapi -o mustrun</p>
  </blockquote>
  <p>and the error is:</p>
  <blockquote>
  <p>The namespace name `MyFunc' could not be found using MyFunc;</p>
  </blockquote>
  <p>One more thing. Is it possible to make bindings for libtorrent? It uses c++ and I gues I have to use c++ too.</p>