Index of /mc-android

      Name                    Last modified       Size  

[DIR] Parent Directory 25-Feb-2019 13:18 - [   ] mc-android.tar.gz 16-Aug-2012 14:01 253k [   ] mc-android-src.tar.gz 16-Aug-2012 14:01 1.3M

Here you will find my version of Midnight Commander for Android.

This version exists because, as of Aug. 2012, I was not able to find an
installable version that would run properly on Cyanogenmod 9 (CM9)...

Specifically, access to the '/system' dir (and others) would fail:

To install this version, you'll need to extract 'mc-android.tar.gz' to the
root of your Android device.  Here's a quick cheat sheet (it is assumed that
you already have the Android SDK installed):

  adb push mc-android.tar.gz /sdcard/mc-android.tar.gz

  adb shell
    su -
      cd /
        tar xvzf /sdcard/mc-android.tar.gz
        rm       /sdcard/mc-android.tar.gz

This mc will work well with the version of vim found here:

I put these statements in my bash startup file (YMMV):

  export TERM=xterm
  export PATH=/data/local/bin:/data/xbin:$PATH
  export EDITOR=vim

  alias vi=$EDITOR

  resize # gets COLUMNS and LINES setup

That's it for installation.  It runs well if you ssh into your phone.  It does
not work very well inside 'adb shell', but that is not my typical use case.

If you're interested in the source code, then keep reading...

The upstream archive can be found here (but you do not need to download this):

My modified (and ready to build) source archive is:


The reason I chose to build such an ancient version of mc is because it's
easier.  There's less code to deal with and there's no glib dependency...

I originally tried to save myself some effort by looking for some existing
mc-for-android source code, but all I could find was incomplete/abandoned git
repo's w/o any build instructions.  So...

Here I offer you build instructions and a source code archive that is actually
ready to build (and you even get it as a tarball, so no waiting for git to do
"the dance of a hundred thousand deltas" before you discover it won't work
with ndk-build...  :^)

First, major credit goes to the vim builder (see above link) who made a model
archive that I could easily copy as my starting point.

What I did was replace the vim files with the mc files (but I left the ncurses
files).  I lost the AndroidManifest.xml (and other non NDK stuff).  Then I
updated the and hand-crafted a new config.h.  Next I ran ndk-build
and started cleaning up the errors until a got a smooth build.

Once built, I made a new installable archive for mc that included the terminfo
files I found in the vim installable archive.

Here's how I compile the source on my Mac Mini (OS X 10.7):

  Download the NDK:

    cd /tmp
      wget -nd

  Install the NDK:

    mkdir /usr/local/android-ndk-macosx
    cd    /usr/local/android-ndk-macosx
      tar xvzf /tmp/android-ndk-r8-darwin-x86.tar.bz2

  Prepare the NDK for use:

    export PATH=$PATH:/usr/local/android-ndk-macosx/android-ndk-r8

  Install the mc source:

    mkdir -p /usr/local/src/mc-android
    cd       /usr/local/src/mc-android
      tar xvzf /tmp/mc-android-src.tar.gz


    cd /usr/local/src/mc-android/mc-3.1.2/jni


        ls -l ../libs/armeabi/mc # <-- the resulting executable

To run it in gdb (the GNU debugger):

    NOTE: The ndk-gdb script will not work because it assumes you're running a
          "normal" Java app and you're just using the NDK for some JNI speedup
          libraries.  Consequently, it runs gdb against 'app_process' after it
          inspects AndroidManifest.xml.

          We're using the NDK for the entire app and do not even have a
          "normal" project tree that includes an AndroidManifest.xml file.

  cd /usr/local/src/mc-android/mc-3.1.2/jni

    ndk-build clean
    ndk-build -B V=1 NDK_DEBUG=1

    adb push ../obj/local/armeabi/mc   /sdcard/mc        # <-- NOTE: not under ../libs
    adb push ../libs/armeabi/gdbserver /sdcard/gdbserver

    # open two new shells:

      # in shell 1
      adb shell
        su -
              mv -f /sdcard/mc        /data/local/bin/mc.real
              mv -f /sdcard/gdbserver /data/local/bin/gdbserver
              chmod 4755              /data/local/bin/mc.real
              chmod 4755              /data/local/bin/gdbserver


      # in shell 2
      adb shell
        su -
              gdbserver :5039 --attach \
                `ps | grep -v grep | grep '/data/local/bin/mc.real' | awk '{print $2}'`

                  # NOTE: this stops execution in the app...

    # Meanwhile, back at the ranch (from the jni dir)...

    adb pull /system/lib/                ../obj/local/armeabi/

    /bin/cp -vf ../libs/armeabi/gdb.setup       ../obj/local/armeabi/gdb.setup

    echo 'file `pwd`/../obj/local/armeabi/mc' >>../obj/local/armeabi/gdb.setup
    echo 'target remote :5039'                >>../obj/local/armeabi/gdb.setup

    adb forward tcp:5039 tcp:5039

    $GDB -x ../obj/local/armeabi/gdb.setup

      b tree.c:my_mkdir