红联Linux门户
Linux帮助

linux用autoconf系列工具生成makefile和可执行文件

发布时间:2017-06-02 11:34:22来源:linux网站作者:dong_beijing
进入xx.cpp的目录,运行shell指令:
dpkg --configure -a  
apt-get install autoconf  
autoscan  
cp configure.scan configure.ac  
vim configure.ac
 
在configure.ac中,需要添加AM_INIT_AUTOMAKE宏,send_rtp是最后生成的文件名,别的不用管,xx.cpp有一个就行,例如:
AC_PREREQ([2.69])  
AC_INIT(send_rtp, 1.0, dongzy08@163.com)  
AM_INIT_AUTOMAKE(send_rtp,1.0)  
AC_CONFIG_SRCDIR([H264Encoder.cpp])  
AC_CONFIG_HEADERS([config.h])
# Checks for programs.  
AC_PROG_CXX  
AC_PROG_CC  
 
还有一处,指定输出的名称为Makefile
AC_OUTPUT(Makefile)  
 
继续执行shell指令:
aclocal  
autoconf   
autoheader  
vim Makefile.am  
 
对于Makefile.am,需要编辑一下,如下:
AUTOMAKE_OPTIONS=foreign  
bin_PROGRAMS=send_rtp  
send_rtp_SOURCES=H264Encoder.cpp inttypes.h rtpframe.h H264Encoder.h main.cpp h264frame.cxx h264frame.h  
 
其中bin_PROGRAMS是最后生成的文件名,send_rtp_SOURCES是所有的源文件名。
 
继续执行shell指令:
automake --add-missing  
./configure   
make  
make all  
 
最后就能生成send_rtp的可执行文件了。
 
本文永久更新地址:http://www.linuxdiyf.com/linux/31222.html