I used this method to compile the FFmpeg binary for inclusion in my Serviio package, because I don’t have a NAS with an Intel CPU. Several people who tried to help were getting strange errors while trying to compile on their NAS units.
To begin, install 64bit Ubuntu Linux (I used a VM). As a test I first successfully cross-compiled ARM binaries using the same method but using the ARM Synology toolchain, since I was able to test the results. Once I got it working I did the following:
#-----set up Synology toolchain cd ~/Downloads wget http://sourceforge.net/projects/dsgpl/files/DSM%203.1%20Tool%20Chains/Intel%20x86%20Linux%202.6.32/gcc420_glibc236_pineview.tgz tar xvfz gcc420_glibc236_pineview.tgz sudo mv i686-linux-gnu /usr/local sudo mv x86_64-linux-gnu /usr/local #-----I think the Synology toolchain is anticipating being run on i686-linux-gnu, so we need 32bit libraries to even run the binaries #-----http://maketecheasier.com/run-32-bit-apps-in-64-bit-linux/2009/08/10 sudo apt-get install ia32-libs export PATH="/usr/local/x86_64-linux-gnu/bin:${PATH}" #-----libz static lib wget http://zlib.net/zlib-1.2.5.tar.gz tar xvfz zlib-1.2.5.tar.gz cd zlib-1.2.5 #-----http://www.crosscompile.org/static/pages/ZLib.html #-----http://tinc-vpn.org/examples/cross-compiling-64-bit-windows-binary/ ./configure --prefix=/usr/local/x86_64-linux-gnu --static sed -i 's/^CC=gcc/CC=x86_64-linux-gnu-gcc/g' Makefile sed -i 's/^LDSHARED=gcc/LDSHARED=x86_64-linux-gnu-gcc/g' Makefile sed -i 's/^CPP=gcc -E/CPP=x86_64-linux-gnu-gcc -E/g' Makefile sed -i 's/^AR=ar rc/AR=x86_64-linux-gnu-ar rc/g' Makefile sed -i 's/^RANLIB=ranlib/RANLIB=x86_64-linux-gnu-ranlib/g' Makefile make libz.a cp libz.a /usr/local/x86_64-linux-gnu/lib cp *.h /usr/local/x86_64-linux-gnu/include/ cd .. #-----libbz2 static lib wget http://bzip.org/1.0.6/bzip2-1.0.6.tar.gz tar xvfz bzip2-1.0.6.tar.gz cd bzip2-1.0.6 sed -i 's/^CC=gcc/CC=x86_64-linux-gnu-gcc/g' Makefile sed -i 's/^AR=ar rc/AR=x86_64-linux-gnu-ar rc/g' Makefile sed -i 's/^RANLIB=ranlib/RANLIB=x86_64-linux-gnu-ranlib/g' Makefile make make install PREFIX=/usr/local/x86_64-linux-gnu cd .. #-----libmp3lame static lib wget http://sourceforge.net/projects/lame/files/lame/3.98.4/lame-3.98.4.tar.gz tar xvfz lame-3.98.4.tar.gz cd lame-3.98.4 ./configure --prefix=/usr/local/x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --build=x86_64-linux-gnu --enable-static --disable-shared --disable-decoder --enable-nasm make make install #-----libssl & libcrypto static libs ipkg install openssl-dev wget http://www.openssl.org/source/openssl-0.9.8p.tar.gz tar xvfz openssl-0.9.8p.tar.gz cd openssl-0.9.8p ./config --prefix=/usr/local/x86_64-linux-gnu no-shared sed -i 's/^CC= gcc/CC= x86_64-linux-gnu-gcc/g' Makefile sed -i 's/^AR= ar /AR= x86_64-linux-gnu-ar /g' Makefile sed -i 's/^ARD=ar /ARD=x86_64-linux-gnu-ar /g' Makefile sed -i 's/^RANLIB= \/usr\/bin\/ranlib/RANLIB=x86_64-linux-gnu-ranlib/g' Makefile sed -i 's/^MAKEDEPPROG= gcc/MAKEDEPPROG= x86_64-linux-gnu-gcc /g' Makefile make make install cd .. #-----librtmp 2.4 static lib wget http://download.serviio.org/opensource/rtmpdump-c58cfb3e9208c6e6bc1aa18f1b1d650d799084e5.tar.gz tar xvfz rtmpdump-c58cfb3e9208c6e6bc1aa18f1b1d650d799084e5.tar.gz cd rtmpdump #-----move all static libs to a separate folder to force compiler to use them #-----http://www.gossamer-threads.com/lists/apache/dev/265052 mkdir /tmp/lib cp /usr/local/x86_64-linux-gnu/lib/*.a /tmp/lib #-----fix Makefile (won't compile without libdl linked) #-----http://forum.luahub.com/index.php?topic=2390.0 sed -i.bak -e '/^LIB_OPENSSL\=/s/lcrypto/lcrypto \-ldl/' Makefile make CROSS_COMPILE=x86_64-linux-gnu- SYS=posix prefix=/usr/local/x86_64-linux-gnu INC=-I/usr/local/x86_64-linux-gnu XLDFLAGS=-L/tmp/lib SHARED= make install prefix=/usr/local/x86_64-linux-gnu SHARED= cd .. #-----gather all static libs again ready for FFmpeg compile cp /usr/local/x86_64-linux-gnu/lib/*.a /tmp/lib #-----remove unsupported URL line from pkgconfig/librtmp.pc #-----pkg-config --exists --print-errors librtmp sed -i -e '/^URL/d' /usr/local/x86_64-linux-gnu/lib/pkgconfig/librtmp.pc export PKG_CONFIG_PATH="${PKG_CONFIG_PATH}:/usr/local/x86_64-linux-gnu/lib/pkgconfig" #-----FFmpeg 0.8.2 (slightly newer than the one at Serviio.org) wget http://dl.dropbox.com/u/1188556/ffmpeg-HEAD-05a2673.tar.gz tar xvfz ffmpeg-HEAD-05a2673.tar.gz cd ffmpeg-HEAD-05a2673 #-----Intel CPU-specific options #-----pkg-config needs to be defined because with cross-prefix it assumes x86_64-linux-gnu-pkg-config which doesn't exist, and then librtmp won't be detected sudo apt-get install yasm ./configure --arch=x86_64 --enable-ssse3 --cross-prefix=x86_64-linux-gnu- --target-os=linux --prefix=/usr/local/x86_64-linux-gnu --extra-cflags='-I/usr/local/x86_64-linux-gnu/include' --extra-ldflags='-L/tmp/lib' --enable-static --disable-shared --disable-ffplay --disable-ffserver --enable-pthreads --enable-libmp3lame --enable-librtmp --pkg-config=pkg-config --extra-version=Serviio make make install
Hi,
Great work! Instructions like this are fanstastic for noobs.
On line 49 you have “ipkg install openssl-dev”
It’s not clear what’s being run where (ubuntu or the synology box)?
line 50 – back to ubuntu again?
thanks
As you’ve no doubt figured out – it’s all to be run on the Ubuntu system. I can’t remember, is that actually wrong? Should it have been sudo apt-get instead of ipkg?
I like to include the web links to the nuggets of information which got me past certain hurdles. Some of them literally took me hours of work to get past :)
that package doesn’t seem to be needed (nor does it exist on ubuntu). another cut/paste error ;-) ?
Hmm. I definitely needed the ia32libs when I did it. Maybe you’re on a newer Ubuntu than the one I used. Definitely 64bit?
no i mean didn’t need “openssl-dev” package at all
Hi me again – you have a typo line 57
Should read “sed -i ‘s/^RANLIB= \/usr\/bin\/ranlib/RANLIB=x86_64-linux-gnu-ranlib/g’ Makefile”
there should be a / only before the RANLIB not an escaped one.
thx
Thanks – fixed. When I was doing it I was keeping notes in a Textedit window so that’s how the error crept in. Did you get it compiled in the end? Out of interest, what are you compiling it for? Serviio for a different NAS, or something else entirely?
Glad you asked. It’s actually got nothing to do with serviio. It does however have to do with my Synology RS2211+ bought recently. I need to get some things compiled for it: eg. mediainfo, mencoder, a newer ffmpeg (like yours) and native mysql ruby drivers. Your instructions provide an insight into how cross-compiling is supposed to work. I got the end ffmpeg binary compiled fine.
Synology are useless, won’t even tell me how to find ‘ldd’ on the synology box and of course they don’t support hacking/optware/etc. So we’re left on our own to work out stuff.
So…I’m looking for a ‘formula’ so that i can compile just about anything for synology. With enough examples like the above i should be able to hack together the modules i set out to compile above?
Cheers,
oh and the forum is great too, but not many examples for the newer intel 64 for RS2211+. Should i be using pineview or bromlow toolchains? Trial and error for me. Ill give the same instructions a go with bromlow t/c.
Not really sure. The weird thing is that the main difference seems to be that Bromolow one is assumed to be 64bit, but all the Pineview chips are 64bit capable too.
Managed to cross compile mediainfo :) Used your zlib static method along with some options provided to mediainfo compile shell. All using the bromlow t/c. Nice.
Great, glad this is helping someone :)