android ndk7 - undefined reference
<p>I am trying to compile v8 using the the android ndk</p>

<p>here is my android.mk file</p>

<pre><code>TOP_LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
include $(TOP_LOCAL_PATH)/nodejs/deps/v8/Android.mk
LOCAL_PATH := $(TOP_LOCAL_PATH)

include $(CLEAR_VARS)
LOCAL_MODULE    := hello-jni
LOCAL_SRC_FILES := hello-jni.cpp
LOCAL_C_INCLUDES := $(LOCAL_PATH)/nodejs/deps/v8/include
LOCAL_STATIC_LIBRARIES := libv8
include $(BUILD_SHARED_LIBRARY)
</code></pre>

<p>this compiles v8 without any errors and creates a static library which is 70-80 meg in size but whenever i try and call a function from this library i get an undefined reference error...</p>

<p>edit: here is my v8 android.mk file</p>

<pre><code>LOCAL_PATH:= $(call my-dir)

include $(CLEAR_VARS)
LOCAL_MODULE := libv8
LOCAL_CFLAGS :=\
    -DV8_ANDROID_LOG_STDOUT \
    -DENABLE_DEBUGGER_SUPPORT \
    -DNDEBUG \
    -DOBJECT_PRINT \
    -DENABLE_DISASSEMBLER
LOCAL_CPP_EXTENSION := .cc
LOCAL_SRC_FILES :=\
    src/allocation.cc\
    src/assembler.cc\
    src/bignum.cc\
    src/bootstrapper.cc\
    src/circular-queue.cc\
    src/codegen.cc\
    src/compilation-cache.cc\
    src/contexts.cc\
    src/counters.cc\
    src/cpu-profiler.cc\
    src/d8-posix.cc\
    src/data-flow.cc\
    src/debug-agent.cc\
    src/diy-fp.cc\
    src/elements.cc\
    src/factory.cc\
    src/fixed-dtoa.cc\
    src/flags.cc\
    src/full-codegen.cc\
    src/gdb-jit.cc\
    src/hashmap.cc\
    src/hydrogen.cc\
    src/ic.cc\
    src/interpreter-irregexp.cc\
    src/jsregexp.cc\
    src/lithium.cc\
    src/liveedit.cc\
    src/liveobjectlist.cc\
    src/messages.cc\
    src/objects.cc\
    src/objects-printer.cc\
    src/objects-visiting.cc\
    src/platform-linux.cc\
    src/platform-posix.cc\
    src/preparser.cc\
    src/prettyprinter.cc\
    src/property.cc\
    src/regexp-macro-assembler.cc\
    src/regexp-stack.cc\
    src/runtime.cc\
    src/safepoint-table.cc\
    src/scanner-character-streams.cc\
    src/scopeinfo.cc\
    src/serialize.cc\
    src/spaces.cc\
    src/string-stream.cc\
    src/stub-cache.cc\
    src/type-info.cc\
    src/unicode.cc\
    src/utils.cc\
    src/v8-counters.cc\
    src/v8utils.cc\
    src/version.cc\
    src/zone.cc\
    src/arm/assembler-arm.cc\
    src/arm/builtins-arm.cc\
    src/arm/codegen-arm.cc\
    src/arm/code-stubs-arm.cc\
    src/arm/constants-arm.cc\
    src/arm/cpu-arm.cc\
    src/arm/debug-arm.cc\
    src/arm/deoptimizer-arm.cc\
    src/arm/disasm-arm.cc\
    src/arm/frames-arm.cc\
    src/arm/full-codegen-arm.cc\
    src/arm/ic-arm.cc\
    src/arm/lithium-arm.cc\
    src/arm/lithium-codegen-arm.cc\
    src/arm/lithium-gap-resolver-arm.cc\
    src/arm/macro-assembler-arm.cc\
    src/arm/regexp-macro-assembler-arm.cc\
    src/arm/simulator-arm.cc\
    src/arm/stub-cache-arm.cc
LOCAL_C_INCLUDES :=\
    $(LOCAL_PATH)/src\
    $(LOCAL_PATH)/src/arm\
    $(LOCAL_PATH)/include
LOCAL_SHARED_LIBRARIES := libstlport.so
LOCAL_LDLIBS := -llog -landroid
include $(BUILD_STATIC_LIBRARY)
</code></pre>

<p>here is the calling code(hello-jni.cpp(actually shell.cc from v8 examples but calling any v8 function has the same effect))</p>

<pre><code>#include &lt;jni.h&gt;
#include &lt;assert.h&gt;
#include &lt;fcntl.h&gt;
#include &lt;string.h&gt;
#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;v8.h&gt;

#ifdef COMPRESS_STARTUP_DATA_BZ2
#error Using compressed startup data is not supported for this sample
#endif

/**
 * This sample program shows how to implement a simple javascript shell
 * based on V8.  This includes initializing V8 with command line options,
 * creating global functions, compiling and executing strings.
 *
 * For a more sophisticated shell, consider using the debug shell D8.
 */


v8::Persistent&lt;v8::Context&gt; CreateShellContext();
void RunShell(v8::Handle&lt;v8::Context&gt; context);
int RunMain(int argc, char* argv[]);
bool ExecuteString(v8::Handle&lt;v8::String&gt; source,
                   v8::Handle&lt;v8::Value&gt; name,
                   bool print_result,
                   bool report_exceptions);
v8::Handle&lt;v8::Value&gt; Print(const v8::Arguments&amp; args);
v8::Handle&lt;v8::Value&gt; Read(const v8::Arguments&amp; args);
v8::Handle&lt;v8::Value&gt; Load(const v8::Arguments&amp; args);
v8::Handle&lt;v8::Value&gt; Quit(const v8::Arguments&amp; args);
v8::Handle&lt;v8::Value&gt; Version(const v8::Arguments&amp; args);
v8::Handle&lt;v8::String&gt; ReadFile(const char* name);
void ReportException(v8::TryCatch* handler);


static bool run_shell;


int main(int argc, char* argv[]) {
  v8::V8::SetFlagsFromCommandLine(&amp;argc, argv, true);
  run_shell = (argc == 1);
  v8::HandleScope handle_scope;
  v8::Persistent&lt;v8::Context&gt; context = CreateShellContext();
  if (context.IsEmpty()) {
    printf("Error creating context\n");
    return 1;
  }
  context-&gt;Enter();
  int result = RunMain(argc, argv);
  if (run_shell) RunShell(context);
  context-&gt;Exit();
  context.Dispose();
  v8::V8::Dispose();
  return result;
}


// Extracts a C string from a V8 Utf8Value.
const char* ToCString(const v8::String::Utf8Value&amp; value) {
  return *value ? *value : "&lt;string conversion failed&gt;";
}


// Creates a new execution environment containing the built-in
// functions.
v8::Persistent&lt;v8::Context&gt; CreateShellContext() {
  // Create a template for the global object.
  v8::Handle&lt;v8::ObjectTemplate&gt; global = v8::ObjectTemplate::New();
  // Bind the global 'print' function to the C++ Print callback.
  global-&gt;Set(v8::String::New("print"), v8::FunctionTemplate::New(Print));
  // Bind the global 'read' function to the C++ Read callback.
  global-&gt;Set(v8::String::New("read"), v8::FunctionTemplate::New(Read));
  // Bind the global 'load' function to the C++ Load callback.
  global-&gt;Set(v8::String::New("load"), v8::FunctionTemplate::New(Load));
  // Bind the 'quit' function
  global-&gt;Set(v8::String::New("quit"), v8::FunctionTemplate::New(Quit));
  // Bind the 'version' function
  global-&gt;Set(v8::String::New("version"), v8::FunctionTemplate::New(Version));

  return v8::Context::New(NULL, global);
}


// The callback that is invoked by v8 whenever the JavaScript 'print'
// function is called.  Prints its arguments on stdout separated by
// spaces and ending with a newline.
v8::Handle&lt;v8::Value&gt; Print(const v8::Arguments&amp; args) {
  bool first = true;
  for (int i = 0; i &lt; args.Length(); i++) {
    v8::HandleScope handle_scope;
    if (first) {
      first = false;
    } else {
      printf(" ");
    }
    v8::String::Utf8Value str(args[i]);
    const char* cstr = ToCString(str);
    printf("%s", cstr);
  }
  printf("\n");
  fflush(stdout);
  return v8::Undefined();
}


// The callback that is invoked by v8 whenever the JavaScript 'read'
// function is called.  This function loads the content of the file named in
// the argument into a JavaScript string.
v8::Handle&lt;v8::Value&gt; Read(const v8::Arguments&amp; args) {
  if (args.Length() != 1) {
    return v8::ThrowException(v8::String::New("Bad parameters"));
  }
  v8::String::Utf8Value file(args[0]);
  if (*file == NULL) {
    return v8::ThrowException(v8::String::New("Error loading file"));
  }
  v8::Handle&lt;v8::String&gt; source = ReadFile(*file);
  if (source.IsEmpty()) {
    return v8::ThrowException(v8::String::New("Error loading file"));
  }
  return source;
}


// The callback that is invoked by v8 whenever the JavaScript 'load'
// function is called.  Loads, compiles and executes its argument
// JavaScript file.
v8::Handle&lt;v8::Value&gt; Load(const v8::Arguments&amp; args) {
  for (int i = 0; i &lt; args.Length(); i++) {
    v8::HandleScope handle_scope;
    v8::String::Utf8Value file(args[i]);
    if (*file == NULL) {
      return v8::ThrowException(v8::String::New("Error loading file"));
    }
    v8::Handle&lt;v8::String&gt; source = ReadFile(*file);
    if (source.IsEmpty()) {
      return v8::ThrowException(v8::String::New("Error loading file"));
    }
    if (!ExecuteString(source, v8::String::New(*file), false, false)) {
      return v8::ThrowException(v8::String::New("Error executing file"));
    }
  }
  return v8::Undefined();
}


// The callback that is invoked by v8 whenever the JavaScript 'quit'
// function is called.  Quits.
v8::Handle&lt;v8::Value&gt; Quit(const v8::Arguments&amp; args) {
  // If not arguments are given args[0] will yield undefined which
  // converts to the integer value 0.
  int exit_code = args[0]-&gt;Int32Value();
  fflush(stdout);
  fflush(stderr);
  exit(exit_code);
  return v8::Undefined();
}


v8::Handle&lt;v8::Value&gt; Version(const v8::Arguments&amp; args) {
  return v8::String::New(v8::V8::GetVersion());
}


// Reads a file into a v8 string.
v8::Handle&lt;v8::String&gt; ReadFile(const char* name) {
  FILE* file = fopen(name, "rb");
  if (file == NULL) return v8::Handle&lt;v8::String&gt;();

  fseek(file, 0, SEEK_END);
  int size = ftell(file);
  rewind(file);

  char* chars = new char[size + 1];
  chars[size] = '\0';
  for (int i = 0; i &lt; size;) {
    int read = fread(&amp;chars[i], 1, size - i, file);
    i += read;
  }
  fclose(file);
  v8::Handle&lt;v8::String&gt; result = v8::String::New(chars, size);
  delete[] chars;
  return result;
}


// Process remaining command line arguments and execute files
int RunMain(int argc, char* argv[]) {
  for (int i = 1; i &lt; argc; i++) {
    const char* str = argv[i];
    if (strcmp(str, "--shell") == 0) {
      run_shell = true;
    } else if (strcmp(str, "-f") == 0) {
      // Ignore any -f flags for compatibility with the other stand-
      // alone JavaScript engines.
      continue;
    } else if (strncmp(str, "--", 2) == 0) {
      printf("Warning: unknown flag %s.\nTry --help for options\n", str);
    } else if (strcmp(str, "-e") == 0 &amp;&amp; i + 1 &lt; argc) {
      // Execute argument given to -e option directly.
      v8::Handle&lt;v8::String&gt; file_name = v8::String::New("unnamed");
      v8::Handle&lt;v8::String&gt; source = v8::String::New(argv[++i]);
      if (!ExecuteString(source, file_name, false, true)) return 1;
    } else {
      // Use all other arguments as names of files to load and run.
      v8::Handle&lt;v8::String&gt; file_name = v8::String::New(str);
      v8::Handle&lt;v8::String&gt; source = ReadFile(str);
      if (source.IsEmpty()) {
        printf("Error reading '%s'\n", str);
        continue;
      }
      if (!ExecuteString(source, file_name, false, true)) return 1;
    }
  }
  return 0;
}


// The read-eval-execute loop of the shell.
void RunShell(v8::Handle&lt;v8::Context&gt; context) {
  printf("V8 version %s [sample shell]\n", v8::V8::GetVersion());
  static const int kBufferSize = 256;
  // Enter the execution environment before evaluating any code.
  v8::Context::Scope context_scope(context);
  v8::Local&lt;v8::String&gt; name(v8::String::New("(shell)"));
  while (true) {
    char buffer[kBufferSize];
    printf("&gt; ");
    char* str = fgets(buffer, kBufferSize, stdin);
    if (str == NULL) break;
    v8::HandleScope handle_scope;
    ExecuteString(v8::String::New(str), name, true, true);
  }
  printf("\n");
}


// Executes a string within the current v8 context.
bool ExecuteString(v8::Handle&lt;v8::String&gt; source,
                   v8::Handle&lt;v8::Value&gt; name,
                   bool print_result,
                   bool report_exceptions) {
  v8::HandleScope handle_scope;
  v8::TryCatch try_catch;
  v8::Handle&lt;v8::Script&gt; script = v8::Script::Compile(source, name);
  if (script.IsEmpty()) {
    // Print errors that happened during compilation.
    if (report_exceptions)
      ReportException(&amp;try_catch);
    return false;
  } else {
    v8::Handle&lt;v8::Value&gt; result = script-&gt;Run();
    if (result.IsEmpty()) {
      assert(try_catch.HasCaught());
      // Print errors that happened during execution.
      if (report_exceptions)
        ReportException(&amp;try_catch);
      return false;
    } else {
      assert(!try_catch.HasCaught());
      if (print_result &amp;&amp; !result-&gt;IsUndefined()) {
        // If all went well and the result wasn't undefined then print
        // the returned value.
        v8::String::Utf8Value str(result);
        const char* cstr = ToCString(str);
        printf("%s\n", cstr);
      }
      return true;
    }
  }
}


void ReportException(v8::TryCatch* try_catch) {
  v8::HandleScope handle_scope;
  v8::String::Utf8Value exception(try_catch-&gt;Exception());
  const char* exception_string = ToCString(exception);
  v8::Handle&lt;v8::Message&gt; message = try_catch-&gt;Message();
  if (message.IsEmpty()) {
    // V8 didn't provide any extra information about this error; just
    // print the exception.
    printf("%s\n", exception_string);
  } else {
    // Print (filename):(line number): (message).
    v8::String::Utf8Value filename(message-&gt;GetScriptResourceName());
    const char* filename_string = ToCString(filename);
    int linenum = message-&gt;GetLineNumber();
    printf("%s:%i: %s\n", filename_string, linenum, exception_string);
    // Print line of source code.
    v8::String::Utf8Value sourceline(message-&gt;GetSourceLine());
    const char* sourceline_string = ToCString(sourceline);
    printf("%s\n", sourceline_string);
    // Print wavy underline (GetUnderline is deprecated).
    int start = message-&gt;GetStartColumn();
    for (int i = 0; i &lt; start; i++) {
      printf(" ");
    }
    int end = message-&gt;GetEndColumn();
    for (int i = start; i &lt; end; i++) {
      printf("^");
    }
    printf("\n");
    v8::String::Utf8Value stack_trace(try_catch-&gt;StackTrace());
    if (stack_trace.length() &gt; 0) {
      const char* stack_trace_string = ToCString(stack_trace);
      printf("%s\n", stack_trace_string);
    }
  }
}
</code></pre>
