0

I am trying to build c file included by ndk under cygwin

In Android.mk, I add -I/usr/include to LOCAL_FLAGS like

LOCAL_FLAGS := -I/usr/include

And I have checked that openssl does under /usr/include

But when I run ndk-build under by project dir, it output

"fatal error: openssl/ssl.h: No such file or directory"

I think I have specified the include directory, but not solve this problem.

Is there any other way can I try?

4

1 回答 1

1

You seem to have some gaps in your knowledge:

  • C code compiles to processor's native instruction set. Your desktop/build machine probably has a different architecture from your Android device(thus a different instruction set).
  • NDK doesn't just compile, it cross-compiles. It means that the NDK runs on the build machine, but the executable it produces cannot run on the build machine(different instruction sets).
  • All libraries on your desktop are in your desktop's processoer's instruction set. Thus, you cannot link any program build by the NDK using the desktop's libraries. This means:
    • No includes from '/usr/include/'
    • No libs from /lib, /usr/lib, /lib64 or /usr/lib64
    • No Cygwin packages under on Windows

What you need to do is build your own openssl using the NDK and use that to link against when you build your executable.

Please note that the answer is missing a lot of information (at least 3 Bachelor's level Computer Science courses worth of information).

于 2013-07-26T06:40:21.047 回答