下载源码
通过GitHub下载源码
https://github.com/libuv/libuv
编译安装源码
$ sh autogen.sh
$ ./configure --prefix=/opt/armlib_mipsel/libuv --host=mipsel-openwrt-linux CC=mipsel-openwrt-linux-gcc
$ make
$ make check//该步骤可以省略,只是校验一下,直接安装,由于运行平台不同check会报错
$ make install
全过程问题记录
$ sh autogen.sh
autogen.sh: 1: autogen.sh: automake: not found
autogen.sh: 33: test: Illegal number:
autogen.sh: 34: test: Illegal number:
+ libtoolize --copy
autogen.sh: 43: autogen.sh: libtoolize: not found
问题:缺少工具,通过apt安装
$ apt install automake
$ apt install libtool
$ make check
make test/run-tests
make[1]: Entering directory '/opt/armsrc/libuv'
make[1]: 'test/run-tests' is up to date.
make[1]: Leaving directory '/opt/armsrc/libuv'
make check-TESTS
make[1]: Entering directory '/opt/armsrc/libuv'
./test/run-tests: line 117: /opt/armsrc/libuv/test/.libs/lt-run-tests: cannot execute binary file: Exec format error
./test/run-tests: line 117: /opt/armsrc/libuv/test/.libs/lt-run-tests: Success
FAIL: test/run-tests
======================================================
1 of 1 test failed
Please report to https://github.com/libuv/libuv/issues
======================================================
Makefile:4481: recipe for target 'check-TESTS' failed
make[1]: *** [check-TESTS] Error 1
make[1]: Leaving directory '/opt/armsrc/libuv'
Makefile:4737: recipe for target 'check-am' failed
make: *** [check-am] Error 2
问题:由于交叉编译产生的test/run-tests测试程序无法运行,可以忽略该错误,直接编译安装即可。
扩展说明
configure的–prefix 作用:
设置安装目录。如果不配置该选项,安装后可执行文件默认放在/usr/local/bin,库文件默认放在/usr/local/lib,配置文件默认放在/usr/local/etc,其它的资源文件放在/usr/local/share。