从 上下载的许多源码的编译和安装过程非常简单,压缩后需要的操作只有三步:
./configure
make
make install
即我们只要运行 这个例子和其中用到的方法,转自http://www.linuxcomputer.cn/,我在做这个例子的过程中,依据遇到的问题做一些修改。 我们操作这个例子的环境是: 我们从大家最常使用的例子程序helloworld.c configure.in Makefile.a 然后执行: aclocal; autoconf; automake –add-missing; ./configure; make; ./helloworld
就可以看到$ mkdir helloword
$ cd helloworl
2. helloworld.c
int main(int argc, char** argv){
printf(“%s”, ‘Hello, Linux World!n”);
return 0;
}
完成后保存退出$ autoscan
$ ls
configure.scan helloworld.
执行后在# Process this file with autoconf to produce a configure script.
AC_INIT(helloworld.c)
AM_INIT_AUTOMAKE(helloworld, 1.0)
# Checks for programs.
AC_PROG_CC
# Checks for libraries.
# Checks for header files.
# Checks for typedefs, structures, and compiler characteristics.
# Checks for library functions.
AC_OUTPUT(Makefile)
然后执行命令$ aclocal
$ls
aclocal.m4 configure.in helloworld.c
$ autoconf
$ ls
aclocal.m4 autom4te.cache configure configure.in helloworld.
大家可以看到$ vi Makefile.am
内容如下AUTOMAKE_OPTIONS=foreign
bin_PROGRAMS=helloworld
helloworld_SOURCES=helloworld.
$ automake –add-missing
configure.in: installing `./install-sh’
configure.in: installing `./mkinstalldirs’
configure.in: installing `./missing’
Makefile.am: installing `./depcomp’
$./configure
$ ls -l Makefile
你可以看到$make
运行$ ./helloworld
Hello, Linux World!
这样GNU Compiler Collection (GCC): Suite of compilers for several programming languages;
GNU Binutils: Suite of tools including linker, assembler and other tools;
GNU Bison: Parser generator
GNU m4: m4 macro processor
GNU Debugger (GDB): Code debugging tool;
GNU build system (autotools):
Autoconf
Autoheader
Automake
Libtool
可以看到,
会初始化表示AUTOMAKE_OPTIONS
这个是bin_PROGRAMS
这个是指定我们所要产生的可执行文件的文件名。如果你要产生多个可执行文件,那么在各个名字间用空格隔开。
helloworld_SOURCES
这个是指定产生
声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!