5

I am trying to use the Android NDK on Mountain Lion to build a library for Android, following this guide

http://masl.cis.gvsu.edu/2012/01/25/android-echoprint/

When it comes time to compile the library, I run:

cd <path to jni>
<ndk>/ndk-build

I get the following error:

Compile++ thumb  : echoprint-jni <= AndroidCodegen.cpp
arm-linux-androideabi-g++: error trying to exec 'cc1plus': execvp: No such file or directory
make: *** [/Users/wingdom/Desktop/obj/local/armeabi/objs/echoprint-jni/AndroidCodegen.o] Error 1

I believe I have added everything I need to to my path variable:

export PATH=$PATH:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:Developer/android-sdk/tools:/Developer/android-sdk/platform-tools:/Developer/android-ndk:/Developer/android-ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86/bin

What else do I need to do in order to get this to compile? I am using the r8b NDK currently, but have tried it with versions all the way back to 6.

EDIT:

I tried this solution: Error while building android ndk sample project

adding

export PATH=$PATH:/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5.2

to my path gets me this error:

cc1plus: error: unrecognized command line option "-mbionic"
cc1plus: error: unrecognized command line option "-mthumb"
cc1plus: error: unrecognized command line option "-mfpu=vfp"
/Users/wingdom/Desktop/jni/AndroidCodegen.cpp:1: error: bad value (armv5te) for -march= switch
/Users/wingdom/Desktop/jni/AndroidCodegen.cpp:1: error: bad value (xscale) for -mtune= switch
make: *** [/Users/wingdom/Desktop/obj/local/armeabi/objs/echoprint-jni/AndroidCodegen.o] Error 1

but adding

export CROSS_COMPILER=$PATH:/Developer/android-ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86/bin

doesn't help, like it did in the link above.

Community
  • 1
  • 1
Wingdom
  • 439
  • 2
  • 10
  • 23
  • Not sure if that helps: http://ubuntuforums.org/showthread.php?t=345201 missing g++ on your system maybe? – zapl Sep 14 '12 at 23:29
  • Everything Ive read says g++ is installed when you install x-code, which I have installed. If I need to install it separately, how do I do it? Everything I have seen uses apt-get for linux. – Wingdom Sep 14 '12 at 23:39
  • when I just run "g++" on the command line, I get "i686-apple-darwin11-llvm-g++-4.2: no input files" so g++ is installed. – Wingdom Sep 14 '12 at 23:47
  • Is it a typo, or the problem? cd **/..**; /ndk-build – Alex Cohn Sep 15 '12 at 05:25
  • its a typo, I am running ndk-build from my projects directory. – Wingdom Sep 15 '12 at 12:38

4 Answers4

6

I have experienced same error.
I was not able to execute even 'gcc, g++' command. So I have googled a lot to find solution, but nothing helped for me.

Then, I found that some filename in ndk is not correct, with tailing _ on some filename.. (In my case, in toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86/arm-linux-androideabi/bin folder, there are gcc_, g++_, c++_ instead of gcc, g++, c++.)
I used The unarchiver to extract NDK archive, so I think there are something wrong with unarchiving procedure.

So I re-downloaded NDK and checked MD5 checksum, then extracted archive using Mac's default archive utility.

Now, the problem has solved.

Mark Ingram
  • 71,849
  • 51
  • 176
  • 230
Taeho Kim
  • 1,865
  • 2
  • 14
  • 16
0

Sounds like you have a bad download/unpack of the NDK. The cc1plus binary that it's looking for should be in $NDK_HOME/toolchains/arm-linux-androideabi-4.4.3/prebuilt/darwin-x86/libexec/gcc/arm-linux-androideabi/4.4.3/. If it's not there, try re-downloading the SDK and/or unpacking it again.

If it is there, be sure to build passing V=1 to ndk-build, and see if there are any odd -B options passed to the compiler. The -B option tells gcc where to find its "sub-programs" (of which cc1plus is one). Pretty sure there shouldn't be any on the command lines for r8, so if there are, something somewhere is passing bad flags. For example, on my system, a C++ NDK command line ends up looking something like this:

 /opt/android-ndk/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-g++ -MMD -MP -MF ./obj/local/armeabi-v7a/objs/sometarget/SomeCppFile.o.d -fpic -ffunction-sections -funwind-tables -fstack-protector -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__  -Wno-psabi -march=armv7-a -mfloat-abi=softfp -mfpu=vfp -fno-exceptions -fno-rtti -mthumb -Os -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -I/opt/android-ndk/sources/cxx-stl/stlport/stlport -I/opt/android-ndk/sources/cxx-stl//gabi++/include -DANDROID -Wall -Wa,--noexecstack  -frtti  -O2 -DNDEBUG -g   -I/opt/android-ndk/platforms/android-8/arch-arm/usr/include -c  jni/SomeCppFile.cpp -o ./obj/local/armeabi-v7a/objs/sometarget/SomeCppFile.o
kelnos
  • 874
  • 5
  • 11
0

Maybe you need to install the g++:

$sudo apt-get install g++

liushuaikobe
  • 2,152
  • 1
  • 23
  • 26
0

I have spent about a day to find root cause of this

arm-linux-androideabi-gcc: error trying to exec 'cc1': execvp: No such file... 

and others issues.

The issues were that I unpacked NDK and SDK with 7z which removed executable permission for all binaries and Eclipse was not able to start cc1. Once I unpacked tar files of SDK and NDK using tar, everything started working well.

Robert
  • 5,278
  • 43
  • 65
  • 115