title: Calling JNI C function in another source file
body: <p>I'm trying to call a C function foo() from a JNI native-lib.cpp file. foo() is declared in foo.h and defined in foo.c. native-lib.cpp already included "foo.h", so Android Studio seems to recognize that the function exists, but upon build, I get the following error:</p>
  
  <pre><code>error: undefined reference to 'foo(unsigned char const*, unsigned int*, int)'
  </code></pre>
  
  <p>foo() is declared as such in foo.h:</p>
  
  <pre><code>void foo(const unsigned char key[], unsigned int w[], int keysize);
  </code></pre>
  
  <p>foo() is called in native-lib.cpp as follows:</p>
  
  <pre><code>static unsigned char byteArray[32];
  unsigned int intArray[64];
  foo(byteArray, intArray, 256);
  </code></pre>
  
  <p>Am I missing anything? Why am I getting the error?</p>
  
  <p>I also notice that when I open my foo.c, Android Studio informs me that "This file is not part of the project. Please include it in the appropriate build file (build.gradle, CMakeLists.txt or Android.mk etc.) and sync the project." How do I do that?</p>