Cross-compiling mc

You’ll need the cross-compiled version of libiconv, libgettext, glib, and slang.

Compiling libiconv

1
2
3
#!/bin/bash
CC=arm-linux-gcc ./configure --host=arm-linux-gnu --prefix=/usr --enable-static
make install DESTDIR=/home/nonoo/common-libs-compiled/arm/libiconv

Compiling libgettext

1
2
3
#!/bin/bash
CC=arm-linux-gcc ./configure --host=arm-linux-gnu --prefix=/usr --disable-csharp --disable-java --disable-openmp --disable-c++ --disable-native-java --enable-static --with-libiconv-prefix=/home/nonoo/common-libs-compiled/arm/libiconv/usr
make install DESTDIR=/home/nonoo/common-libs-compiled/arm/libgettext

Compiling libffi (needed by glib)

1
2
3
#!/bin/bash
CC=arm-linux-gcc ./configure --host=arm-linux-gnu --prefix=/usr
make install DESTDIR=/home/nonoo/common-libs-compiled/arm/libffi

Compiling glib

1
2
3
4
5
6
7
8
9
10
11
#!/bin/bash
echo "glib_cv_stack_grows=no" >config.cache
echo "glib_cv_uscore=no" >>config.cache
echo "ac_cv_func_posix_getpwuid_r=yes" >>config.cache
echo "ac_cv_func_posix_getgrgid_r=yes" >>config.cache
CPPFLAGS="-I/home/nonoo/common-libs-compiled/arm/libffi/usr/lib/libffi-3.0.11/include -I/home/nonoo/common-libs-compiled/arm/libgettext/usr/include" \
LDFLAGS="-L/home/nonoo/common-libs-compiled/arm/libiconv/usr/lib -L/home/nonoo/common-libs-compiled/arm/libgettext/usr/lib" \
LIBFFI_CFLAGS="-I/home/nonoo/common-libs-compiled/arm/libffi/usr/lib/libffi-3.0.11/include" \
LIBFFI_LIBS="-L/home/nonoo/common-libs-compiled/arm/libffi/usr/lib -lffi" \
CC=arm-linux-gcc ./configure --host=arm-linux-gnu --prefix=/usr -C --enable-static
make install DESTDIR=/home/nonoo/common-libs-compiled/arm/glib

Compiling slang

1
2
3
#!/bin/bash
CC=arm-linux-gcc ./configure --host=arm-linux-gnu --prefix=/usr
make install DESTDIR=/home/nonoo/common-libs-compiled/arm/slang

Compiling mc

1
2
3
4
5
6
7
#!/bin/bash
CPPFLAGS="-I/home/nonoo/common-libs-compiled/arm/libiconv/usr/include -I/home/nonoo/common-libs-compiled/arm/libgettext/usr/include -I/home/nonoo/common-libs-compiled/arm/glib/usr/include/glib-2.0 -I/home/nonoo/common-libs-compiled/arm/glib/usr/lib/glib-2.0/include" \
LDFLAGS="-L/home/nonoo/common-libs-compiled/arm/libiconv/usr/lib -L/home/nonoo/common-libs-compiled/arm/libgettext/usr/lib -L/home/nonoo/common-libs-compiled/arm/glib/usr/lib -lintl -lglib-2.0" \
PKG_CONFIG_PATH=/home/nonoo/common-libs-compiled/arm/glib/usr/lib/pkgconfig \
GLIB_LIBDIR=/home/nonoo/common-libs-compiled/arm/glib/usr/lib \
CC=arm-linux-gcc ./configure --host=arm-linux-gnu --prefix=/usr --with-slang-includes=/home/nonoo/common-libs-compiled/arm/slang/usr/include --with-slang-libs=/home/nonoo/common-libs-compiled/arm/slang/usr/lib
make install DESTDIR=/home/nonoo/common-libs-compiled/arm/mc

You will find the compiled mc in /home/nonoo/common-libs-compiled/arm/mc.


Archived version of this post

Here’s how to cross-compile mc for the BeagleBone. This tutorial is suitable for other target platforms as well, you just have to use a different cross-compiler.

glib

To cross-compile compile Midnight Commander, you’ll have to compile glib first, otherwise mc will start with this error:

1
mc: error while loading shared libraries: libgmodule-2.0.so.0: cannot open shared object file: No such file or directory

libffi

For glib, you’ll need libffi from here. Extract it and compile:

1
2
3
CC=arm-arago-linux-gnueabi-gcc ./configure --host=arm --prefix=~/libffi
make
make install

glib again

Download and extract the glib source, and compile it:

1
PKG_CONFIG_PATH=~/libffi/lib/pkgconfig CC=arm-arago-linux-gnueabi-gcc ./configure --host=arm --prefix=~/glib -C

This of course throws an error:

1
configure: error: cannot run test program while cross compiling

To fix this, I opened the configure script and searched for the cache variable names of the failed tests. More info about them here. Finally I added these to the config.cache file:

1
2
3
4
glib_cv_stack_grows=no
glib_cv_uscore=yes
ac_cv_func_posix_getpwuid_r=yes
ac_cv_func_posix_getgrgid_r=yes

After this, configure ran without errors. I compiled glib then with make and make install.

slang

mc needs slang, so download it’s source and compile it:

1
2
3
CC=arm-arago-linux-gnueabi-gcc ./configure --host=arm --prefix=~/slang
make
make install

mc

Download and compile mc:

1
2
3
PKG_CONFIG_PATH=~/glib/lib/pkgconfig GLIB_LIBDIR=~/glib/lib CC=arm-arago-linux-gnueabi-gcc ./configure --host=arm --prefix=~/mc --with-slang-includes=~/slang/include --with-slang-libs=~/slang/lib --with-glib-static
make
make install

There were some errors, so I inserted this to the beginning of the configure script:

1
fu_cv_sys_stat_statfs2_bsize=yes

I had to remove the # from the beginning of the following line in src/Makefile:

1
am__append_4 = -DSAVERDIR=""$(pkglibexecdir)""

After this configure ran without errors and I could proceed with compiling. I then copied the whole ~/mc dir to the /usr folder of the SD card’s rootfs.

Fine tuning

To avoid the Unable to load ‘default’ skin error, I added this line to the end of /etc/profile:

1
MC_SKIN=/usr/share/mc/skins/default.ini
scott 2013-09-03 01:56:56

this method run on android?

Nonoo 2013-09-03 10:01:31

I don’t think so

 
 
misko 2013-09-24 16:50:38

Very helpful, thank you.
Although zlib must be cross compiled also because it is required by glib.

 
sm0k0 2014-02-08 17:03:44

Hi,
beside zlib, it’s not working with a default duildroot toolchain for uClibc armv5t. Compile of MC stops at “diffviewer” creation …

 
nerbius 2015-02-21 16:41:50

What version glib did you use?
I use glib-2.32.4 and I have error:
gzlibcompressor.c:28: fatal error: zlib.h: No such file or directory
compilation terminated.

 

[…] midnight commander (mc.zip) approximately following this reference (use mc -a in case of missing line drawing characters) libz (zlib-1.2.8) CHOST=arm-linux-gnueabihf […]

 
Name (required)
E-mail (required - never shown publicly)
Webpage URL
Comment:
You may use <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> in your comment.

About me

Nonoo
I'm Nonoo. This is my blog about music, sounds, filmmaking, amateur radio, computers, programming, electronics and other things I'm obsessed with. ... »

Twitter

Listening now

My favorite artists