1、lua5.3.1源码下载与打补丁
打补丁:
源码包解压后,cd lua -5.3.1,
patch -Np1 -i ../lua-5.3.1-shared_library-1.patch &&
sed -i '/#define LUA_ROOT/s:/usr/local/:/usr/:' src/luaconf.h
2、lua5.3.1源码做一个修改,具体如下:
(1) 修改顶层Makefile:
TO_LIB= liblua.a liblua-$V.so
# Convenience platforms targets.
PLATS= aix bsd c89 freebsd generic linux arm-linux macosx mingw posix solaris
(2) 修改src/Makefile:
修改src/Makefile文件
CC= $(CROSS_COMPILE)gcc -march=armv7-a -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a9 --sysroot=/home/imhqq/share/huqiqiao/toolchain/sysroots/cortexa9hf-neon-poky-linux-gnueabi
LUA_SO= liblua-$V.so
AR= $(CROSS_COMPILE)ar rcu
RANLIB= $(CROSS_COMPILE)ranlib
MYCFLAGS=-I/home/imhqq/share/huqiqiao/nfs_new/usr/include
LUA_SO= liblua-$V.so
还有,和顶层Makefile一样PLATS变量里加入 arm-linux
PLATS= aix bsd c89 freebsd generic linux arm-linux macosx mingw posix solaris
targets里加入arm-linux平台的编译命令.
arm-linux:
$(MAKE) $(ALL) CC="arm-poky-linux-gnueabi-gcc -march=armv7-a -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a9 --sysroot=/home/imhqq/share/huqiqiao/toolchain/sysroots/cortexa9hf-neon-poky-linux-gnueabi" AR="arm-poky-linux-gnueabi-ar rcu" RANLIB="arm-poky-linux-gnueabi-ranlib" \
SYSCFLAGS="-DLUA_USE_LINUX -DLUA_USE_ARM_LINUX" SYSLIBS="-Wl,-E -ldl"
此处自己加了一个编译开关LUA_ARM_LINUX,目的是去掉readline头文件。
(3)修改src/luaconf.h文件:
#if defined(LUA_USE_LINUX)
#define LUA_USE_POSIX
#define LUA_USE_DLOPEN /* needs an extra library: -ldl */
#if !defined(LUA_USE_ARM_LINUX)
#define LUA_USE_READLINE /* needs some extra libraries */
#endif
#endif
3、配置好交叉编译环境变量,再在顶层目录执行 make arm-linux 编译。
source /home/imhqq/share/huqiqiao/toolchain/environment-setup-cortexa9hf-neon-poky-linux-gnueabi
cd /home/imhqq/share/huqiqiao/vlc-2.2.1
export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:/home/imhqq/share/huqiqiao/vlc-2.2.1-plugin/lib/ffmpeg/lib/pkgconfig:/home/imhqq/share/huqiqiao/vlc-2.2.1-plugin/lib/alsa/lib/pkgconfig:/home/imhqq/share/huqiqiao/vlc-2.2.1-plugin/lib/libmad/lib/pkgconfig:/home/imhqq/share/huqiqiao/vlc-2.2.1-plugin/lib/libgpg-error/lib/pkgconfig:/home/imhqq/share/huqiqiao/vlc-2.2.1-plugin/lib/libgcrypt/lib/pkgconfig:/home/imhqq/share/huqiqiao/vlc-2.2.1-plugin/lib/x264/lib/pkgconfig:/home/imhqq/share/huqiqiao/vlc-2.2.1-plugin/lib/madplay/lib/pkgconfig:/home/imhqq/share/huqiqiao/vlc-2.2.1-plugin/lib/libogg/lib/pkgconfig:/home/imhqq/share/huqiqiao/vlc-2.2.1-plugin/lib/libvorbis/lib/pkgconfig:/home/imhqq/share/huqiqiao/vlc-2.2.1-plugin/lib/vorbis-tools/lib/pkgconfig:/home/imhqq/share/huqiqiao/vlc-2.2.1-plugin/lib/libxml2/lib/pkgconfig"
export LDFLAGS="-ggdb3 -L/home/imhqq/share/huqiqiao/vlc-2.2.1-plugin/lib/ffmpeg/lib -L/home/imhqq/share/huqiqiao/vlc-2.2.1-plugin/lib/x264/lib -L/home/imhqq/share/huqiqiao/vlc-2.2.1-plugin/lib/alsa/lib -L/home/imhqq/share/huqiqiao/vlc-2.2.1-plugin/lib/libgcrypt/lib -L/home/imhqq/share/huqiqiao/vlc-2.2.1-plugin/lib/libgpg-error/lib -L/home/imhqq/share/huqiqiao/vlc-2.2.1-plugin/lib/libmad/lib -L/home/imhqq/share/huqiqiao/vlc-2.2.1-plugin/lib/madplay/lib -L/home/imhqq/share/huqiqiao/vlc-2.2.1-plugin/lib/libogg/lib -L/home/imhqq/share/huqiqiao/vlc-2.2.1-plugin/lib/libvorbis/lib -L/home/imhqq/share/huqiqiao/vlc-2.2.1-plugin/lib/vorbis-tools/lib -L/home/imhqq/share/huqiqiao/vlc-2.2.1-plugin/lib/libxml2/lib -L/home/imhqq/share/huqiqiao/vlc-2.2.1-plugin/lib/lua/lib"
export dependency_libs=' -L/home/imhqq/share/huqiqiao/vlc-2.2.1-plugin/lib/ffmpeg/lib -L/home/imhqq/share/huqiqiao/vlc-2.2.1-plugin/lib/x264/lib -L/home/imhqq/share/huqiqiao/vlc-2.2.1-plugin/lib/alsa/lib -L/home/imhqq/share/huqiqiao/vlc-2.2.1-plugin/lib/libgcrypt/lib -L/home/imhqq/share/huqiqiao/vlc-2.2.1-plugin/lib/libgpg-error/lib -L/home/imhqq/share/huqiqiao/vlc-2.2.1-plugin/lib/libmad/lib -L/home/imhqq/share/huqiqiao/vlc-2.2.1-plugin/lib/madplay/lib -L/home/imhqq/share/huqiqiao/vlc-2.2.1-plugin/lib/libogg/lib -L/home/imhqq/share/huqiqiao/vlc-2.2.1-plugin/lib/libvorbis/lib -L/home/imhqq/share/huqiqiao/vlc-2.2.1-plugin/lib/vorbis-tools/lib -L/home/imhqq/share/huqiqiao/vlc-2.2.1-plugin/lib/libxml2/lib /home/imhqq/share/huqiqiao/vlc-2.2.1/src/libvlccore.la -lrt -ldl -lm=/home/imhqq/share/huqiqiao/vlc-2.2.1-plugin/lib/libogg/lib/libogg.la -L/home/imhqq/share/huqiqiao/vlc-2.2.1-plugin/lib/lua/lib'
export CFLAGS="-ggdb3 -O0 -O2 -pipe -g -I/home/imhqq/share/huqiqiao/vlc-2.2.1-plugin/lib/libmad/include -I/home/imhqq/share/huqiqiao/vlc-2.2.1-plugin/lib/ffmpeg/include -I/home/imhqq/share/huqiqiao/vlc-2.2.1-plugin/lib/x264/include -I/home/imhqq/share/huqiqiao/vlc-2.2.1-plugin/lib/alsa/include -I/home/imhqq/share/huqiqiao/vlc-2.2.1-plugin/lib/libgcrypt/include -I/home/imhqq/share/huqiqiao/vlc-2.2.1-plugin/lib/libgpg-error/include -I/home/imhqq/share/huqiqiao/vlc-2.2.1-plugin/lib/madplay/include -I/home/imhqq/share/huqiqiao/vlc-2.2.1-plugin/lib/libxml2/include -I/home/imhqq/share/huqiqiao/vlc-2.2.1-plugin/lib/lua/include"
./configure -C --build=x86_64-linux-gnu --target=arm-poky-linux-gnueabi --host=arm-poky-linux-gnueabi --prefix=/home/imhqq/share/huqiqiao/vlc-2.2.1/arm_vlc_build1 --enable-run-as-root --enable-vlc --enable-avformat --enable-mad --enable-httpd --enable-realrtsp --enable-sout --enable-libass --enable-optimizations --disable-postproc --disable-mod --disable-debug --disable-dbus --disable-sdl --disable-sdl-image --disable-swscale --disable-xcb --disable-qt --disable-a52 --disable-gles2 --disable-gles1 --disable-screen --disable-live555 --disable-macosx --disable-macosx-dialog-provider --disable-macosx-qtkit --disable-macosx-eyetv --disable-macosx-vlc-app --disable-altivec --disable-coverage --disable-taglib --disable-dvdread --disable-dvdnav --disable-dvbpsi --disable-v4l2 --disable-vcdx --disable-vcd --disable-dca --disable-tremor --disable-gme --disable-faad --disable-flac --disable-speex --disable-theora --disable-schroedinger --disable-png --disable-telx --disable-kate --disable-xvideo --disable-freetype --disable-fribidi --disable-fontconfig --disable-libgcrypt --disable-ncurses --disable-bonjour --disable-atmo --disable-gnutls --disable-skins2 --disable-lirc --disable-opencv --disable-silent-rules --disable-neon --disable-dc1394 --disable-vlm --disable-gnomevfs --disable-twolame --disable-sftp --disable-notify --disable-shout --disable-aa --disable-caca --disable-jack --disable-merge-ffmpeg --disable-libva --disable-dxva2 --disable-shine --disable-zvbi --disable-tiger --disable-maintainer-mode --disable-dependency-tracking --disable-gprof --disable-cprof --disable-libcddb --disable-wma-fixed --disable-omxil --disable-quicktime --disable-fluidsynth --disable-svg --disable-directfb --disable-upnp --disable-goom --disable-projectm --disable-udev --disable-mtp --disable-update-check --disable-linsys --disable-bluray --disable-smbclient --disable-decklink --disable-vnc --disable-freerdp --disable-macosx-avfoundation --disable-asdcp --disable-avcodec --disable-avformat --disable-a52 --disable-libgcrypt --enable-pulse --disable-x264 --disable-glspectrum --enable-lua
3.1 lua交叉编译错误解决
root@imhqq-B360M-D3V:/home/imhqq/share/huqiqiao/vlc-2.2.1-plugin/lua-5.3.1# make arm-linux
cd src && make arm-linux V=5.3 R=5.3.1
make[1]: Entering directory '/home/imhqq/share/huqiqiao/vlc-2.2.1-plugin/lua-5.3.1/src'
make all CC="arm-poky-linux-gnueabi-gcc" AR="arm-poky-linux-gnueabi-ar rcu" RANLIB="arm-poky-linux-gnueabi-ranlib" \
SYSCFLAGS="-DLUA_USE_LINUX -DLUA_USE_ARM_LINUX" SYSLIBS="-Wl,-E -ldl"
make[2]: Entering directory '/home/imhqq/share/huqiqiao/vlc-2.2.1-plugin/lua-5.3.1/src'
arm-poky-linux-gnueabi-gcc -fPIC -O2 -Wall -Wextra -DLUA_COMPAT_5_2 -DLUA_USE_LINUX -DLUA_USE_ARM_LINUX -c -o lapi.o lapi.c
lapi.c:14:20: fatal error: string.h: No such file or directory
compilation terminated.
: recipe for target 'lapi.o' failed
make[2]: *** [lapi.o] Error 1
make[2]: Leaving directory '/home/imhqq/share/huqiqiao/vlc-2.2.1-plugin/lua-5.3.1/src'
Makefile:135: recipe for target 'arm-linux' failed
make[1]: *** [arm-linux] Error 2
make[1]: Leaving directory '/home/imhqq/share/huqiqiao/vlc-2.2.1-plugin/lua-5.3.1/src'
Makefile:55: recipe for target 'arm-linux' failed
make: *** [arm-linux] Error 2
原因分析:
找不到string.h头文件。
解决办法:
在src/Makefile中修改:
MYCFLAGS=-I/home/imhqq/share/huqiqiao/nfs_new/usr/include
再执行make arm-linux,编译成功。
3.2 修改顶层Makefile,
INSTALL_TOP= /home/imhqq/share/huqiqiao/vlc-2.2.1-plugin/lib/lua
make install OK. 编译出来的lua安装到了/home/imhqq/share/huqiqiao/vlc-2.2.1-plugin/lib/lua路径下。
root@imhqq-B360M-D3V:/home/imhqq/share/huqiqiao/vlc-2.2.1-plugin/lua-5.3.1# make install
cd src && mkdir -p /home/imhqq/share/huqiqiao/vlc-2.2.1-plugin/lib/lua/bin /home/imhqq/share/huqiqiao/vlc-2.2.1-plugin/lib/lua/include /home/imhqq/share/huqiqiao/vlc-2.2.1-plugin/lib/lua/lib /home/imhqq/share/huqiqiao/vlc-2.2.1-plugin/lib/lua/man/man1 /home/imhqq/share/huqiqiao/vlc-2.2.1-plugin/lib/lua/share/lua/5.3 /home/imhqq/share/huqiqiao/vlc-2.2.1-plugin/lib/lua/lib/lua/5.3
cd src && install -p -m 0755 lua luac /home/imhqq/share/huqiqiao/vlc-2.2.1-plugin/lib/lua/bin
cd src && install -p -m 0644 lua.h luaconf.h lualib.h lauxlib.h lua.hpp /home/imhqq/share/huqiqiao/vlc-2.2.1-plugin/lib/lua/include
cd src && install -p -m 0644 liblua.a /home/imhqq/share/huqiqiao/vlc-2.2.1-plugin/lib/lua/lib
cd doc && install -p -m 0644 lua.1 luac.1 /home/imhqq/share/huqiqiao/vlc-2.2.1-plugin/lib/lua/man/man1