centos7如何编译Java,CentOS7 上的 ZThread 库编译

ZThread是一个跨平台的多线程库,其最新版本是05年发布的 2.3.2版本。由于年久失修,编译就会出现很多问题。我在CentOS 6上编译时,使用一个 fpermissive 选项就可以使用经典的 configure-->make-->make install 流程构建了,但在CentOS 7上行不通。查了一天多,终于在根本解决了该问题。

按照经典的构建流程,执行 configure,中止并报如下错误:

checking for ranlib... ranlib

checking for strip... strip

checking for correct ltmain.sh version... grep: character class syntax is [[:space:]], not [:space:]

no

*** Gentoo sanity check failed! ***

*** libtool.m4 and ltmain.sh have a version mismatch! ***

*** (libtool.m4 = 1.5.10, ltmain.sh = ) ***

Please run:

libtoolize --copy --force

if appropriate, please contact the maintainer of this

package (or your distribution) for help.

根据提示执行 libtoolize --copy --force 之后,再重新执行 ./configure 还是不行。

根据当前的情况,在网上查到一篇blog,介绍通过修改 configure 脚本来适应当前系统,我觉得是一个思路,但有风险。也是受这篇博客启发,发现ZThread源码目录下有configure.ac 和 Makefile.am 这个文件,这不是用来生成 configure 的文件嘛!如果能根据本地环境特征重新生成一个configure 脚本,那是最好的了。

但刚执行了一个 aclocal 就报了一堆warning,如下

configure.ac:59: warning: macro 'AM_ACLOCAL_INCLUDE' not found in library

configure.ac:68: warning: macro 'AM_DETECT_PTHREAD' not found in library

configure.ac:69: warning: macro 'AM_WITH_DOXYGEN' not found in library

configure.ac:71: warning: macro 'AM_ENABLE_ATOMIC_LINUX' not found in library

configure.ac:72: warning: macro 'AM_ENABLE_ATOMIC_GCC' not found in library

configure.ac:73: warning: macro 'AM_DETECT_FTIME' not found in library

一看是warning,也没理会,继续执行 autoconf,这回warning升级成 error了:

[root@localhost ZThread-2.3.2]# autoconf

configure.ac:59: error: possibly undefined macro: AM_ACLOCAL_INCLUDE

If this token and others are legitimate, please use m4_pattern_allow.

See the Autoconf documentation.

configure.ac:68: error: possibly undefined macro: AM_DETECT_PTHREAD

configure.ac:69: error: possibly undefined macro: AM_WITH_DOXYGEN

configure.ac:71: error: possibly undefined macro: AM_ENABLE_ATOMIC_LINUX

configure.ac:72: error: possibly undefined macro: AM_ENABLE_ATOMIC_GCC

configure.ac:73: error: possibly undefined macro: AM_DETECT_FTIME

显然,这些error就是 aclocal 造成的。返回到 aclocal 这一步,研究如何把这些warning消除。

在网上查的结果是让看看 其他目录,如/usr/local 下有没有相关的 *.m4 文件,拷到 /usr/share/aclocal 或 /usr/share/aclocal- 目录下。不幸的是,并没有找到相关的 *.m4 文件。然后又试图 通过 aclocal 的 --verbose选项来观察具体原因。搜索 AM_ACLOCAL_INCLUDE 等报出的未定义宏也没有搜到。

到这卡了很长时间,机缘巧合之下,发现ZThread源码目录下有个share目录,这个目录下就是和aclocal报出的未定义宏相关的 *.m4 文件!赶紧执行 aclocal -I share/,未定义宏的警告消失啦!但又有新的警告!

[root@localhost ZThread-2.3.2]# aclocal -I share/

share/zthread.m4:34: warning: underquoted definition of AM_PATH_ZTHREAD

share/zthread.m4:34: run info Automake 'Extending aclocal'

share/zthread.m4:34: or see http://www.gnu.org/software/automake/manual/automake.html#Extending-aclocal

又一次选择无视 warning,又一次被 warning给怼回来了。这次是执行到make才回头的,其报错如下:

[root@localhost ZThread-2.3.2]# make

Making all in src

make[1]: 进入目录“/home/mengnan.li/ZThread/ZThread-2.3.2/src”

make all-recursive

make[2]: 进入目录“/home/mengnan.li/ZThread/ZThread-2.3.2/src”

Making all in .

make[3]: 进入目录“/home/mengnan.li/ZThread/ZThread-2.3.2/src”

/bin/sh ../libtool --tag=CXX --mode=compile g++ -DHAVE_CONFIG_H -I. -I../include -fpermissive -Wall -DNDEBUG -fpermissive -Wall -DNDEBUG -MT AtomicCount.lo -MD -MP -MF .deps/AtomicCount.Tpo -c -o AtomicCount.lo AtomicCount.cxx

../libtool: line 852: X--tag=CXX: command not found

../libtool: line 885: libtool: ignoring unknown tag : command not found

../libtool: line 852: X--mode=compile: command not found

../libtool: line 1002: *** Warning: inferring the mode of operation is deprecated.: command not found

../libtool: line 1003: *** Future versions of Libtool will require -mode=MODE be specified.: command not found

../libtool: line 1146: Xg++: command not found

../libtool: line 1146: X-DHAVE_CONFIG_H: command not found

../libtool: line 1146: X-I.: command not found

../libtool: line 1146: X-I../include: No such file or directory

../libtool: line 1146: X-fpermissive: command not found

../libtool: line 1146: X-Wall: command not found

../libtool: line 1146: X-DNDEBUG: command not found

../libtool: line 1146: X-fpermissive: command not found

../libtool: line 1146: X-Wall: command not found

../libtool: line 1146: X-DNDEBUG: command not found

../libtool: line 1146: X-MT: command not found

../libtool: line 1146: XAtomicCount.lo: command not found

../libtool: line 1146: X-MD: command not found

../libtool: line 1146: X-MP: command not found

../libtool: line 1146: X-MF: command not found

../libtool: line 1146: X.deps/AtomicCount.Tpo: No such file or directory

../libtool: line 1146: X-c: command not found

../libtool: line 1194: XAtomicCount.lo: command not found

../libtool: line 1199: libtool: compile: cannot determine name of library object from `': command not found

make[3]: *** [AtomicCount.lo] 错误 1

make[3]: 离开目录“/home/mengnan.li/ZThread/ZThread-2.3.2/src”

make[2]: *** [all-recursive] 错误 1

make[2]: 离开目录“/home/mengnan.li/ZThread/ZThread-2.3.2/src”

make[1]: *** [all] 错误 2

make[1]: 离开目录“/home/mengnan.li/ZThread/ZThread-2.3.2/src”

make: *** [all-recursive] 错误 1

(如果在make之前没执行过 automake,make会先执行automake,automake的报错没有在上面的代码段中。)这次看到这么多 libtool 的报错,我想起了之前直接执行configure脚本报错时提示的 “libtoolize --copy --force”命令,在aclocal之后(或之前)执行一下这个命令,就OK了!至此,ZThread构建成功!

总结一下构建流程:

在源代码目录下执行以下命令生成新的configure脚本、aclocal.m4 和 Makefile.in

libtoolize --copy --force

aclocal -I share/

autoconf

automake

在构建目录下执行如下命令,构建ZThread库

/configure --prefix=  CXXFLAGS="$CXXFLAGS -fpermissive"

make

make install

其中,虽然执行了libtoolize,但alocal 仍然有警告,不过无所谓了,不会导致中止构建流程了。

参考文章

https://blog.csdn.net/stwstw0123/article/details/49276839

https://www.cnblogs.com/bugutian/p/5560548.html

https://www.cnblogs.com/caosiyang/archive/2012/11/26/2788769.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值