Make a portable Fcitx

From Fcitx
Jump to navigation Jump to search


Portable means extract and run, no extra dependency, all required library is in the tarball. But still, correct environment variable is required to make Fcitx work.


  • im module cannot be used, only XIM will work.
  • not all input method support this.


  • Get latest source, at least newer than 4.2.1.
  • Make sure all the depdenency is installed.
  • The kernel version of the machine you compile on is the lowest kernel version of this Fcitx can run on, due to glibc limit. So use the linux with oldest kernel you can find to compile.


Read Compile from source first, and grab all required dependency. Take fcitx 4.2.1 as example.

mkdir -p $HOME/portable/
cd $HOME/portable/
tar xvf fcitx-4.2.1_dict.tar.xz
cd fcitx-4.2.1/
mkdir build
cd build/
#### Disable most dependency ####
make install

Make it portable

In order to make it portable, all rpath need to be reomved, with chrpath, you might not install it, so install it first.

cd $HOME/portable/dest/bin
for f in *; do chrpath -d $f; done
cd $HOME/portable/dest/lib
for f in `find . -name '*.so'`; do chrpath -d $f; done

Next find all required libraries and copy them to the lib directory.

cd $HOME/portable/dest/
filelist=`find . -type f`
lddresult=`for f in $filelist; do ldd $f | grep so; done`
librarylist=`for f in $lddresult
echo $f
done | grep '^/' | sort | uniq`
cp $librarylist lib/

And then replace all binary with proper sccript wrapper, but if you only need to run fcitx, you can just do this

cd $HOME/portable/dest/
mv bin/fcitx bin/fcitx.bin

and create bin/fcitx with following content

export FCITXDIR="$( cd "$( dirname "$0" )/.." && pwd )"
$FCITXDIR/lib/ $FCITXDIR/bin/fcitx.bin "$@"

and make it executable

chmod +x bin/fcitx

Then there you go, create a tarball for dest/ directory

cd $HOME/portable/
tar czvf portable.tar.gz dest/

If you wish add additional component to this, consider install other required library and addon to this prefix before "make it portable" step.