第一种情况:从头开始
第二种情况:编译已有的库
看库的readme,比如ArtNet这个库。
1.用到autoconf,参考生成configuration。
可选, 运行: autoupdate
最初运行结果:
$ libartnet-master % autoconf
如下打印:
configure.ac:21: warning: The preprocessor macro `STDC_HEADERS’ is obsolete.
configure.ac:21: Except in unusual embedded environments, you can safely include all
configure.ac:21: ISO C90 headers unconditionally.
configure.ac:37: warning: Update your code to rely only on HAVE_SYS_TIME_H,
configure.ac:37: then remove this warning and the obsolete code below it.
configure.ac:37: All current systems provide time.h; it need not be checked for.
configure.ac:37: Not all systems provide sys/time.h, but those that do, all allow
configure.ac:37: you to include it and time.h simultaneously.
2.运行:
Building libartnet with mingw-w64:
set up mingw-w64 (and possibly MSYS).
for a 64-bit build: --host=x86_64-w64-mingw32
for a 32-bit build: --host=i686-w64-mingw32
$ ./configure ac_cv_func_malloc_0_nonnull=yes ac_cv_func_realloc_0_nonnull=yes --host=x86_64-w64-mingw32 --prefix=/some/path/prefix
提示错误:configure: error: cannot find required auxiliary files: config.guess config.sub install-sh
尝试下面的方法:
来源:参考1,参考2,参考3。下面是参考3的方法。
brew uninstall autoconf --igonre-dependencies
cd
curl -O -L http://ftpmirror.gnu.org/autoconf/autoconf-2.69.tar.gz
tar -xzf autoconf-2.69.tar.gz
cd autoconf-2.69
./configure
make
sudo make install
用这个方法装完后会提示:(意思是没装autoconf,或者找不到路径。实际路径在:usr/local/share,或者:usr/local/bin,如果需要,用:rm -f INSTALL,来删除,然后再删除整个autoconf文件)
configure.ac:10: error: possibly undefined macro: AM_INIT_AUTOMAKE
If this token and others are legitimate, please use m4_pattern_allow.
See the Autoconf documentation.
configure.ac:17: error: possibly undefined macro: AC_LIBTOOL_WIN32_DLL
configure.ac:18: error: possibly undefined macro: AC_PROG_LIBTOOL
configure.ac:74: error: possibly undefined macro: AM_CONDITIONAL
参考:方案1,
Configure的文件内容:
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.69])
AC_INIT(helloworld.c, 1.0)
AM_INIT_AUTOMAKE
#下面两句运行到后面会提示参数警告
#AC_INIT(helloworld.c)
#AM_INIT_AUTOMAKE(helloworld, 1.0)
AC_PROG_CC
AC_OUTPUT(Makefile)
从头开始创建一个Makefile
1.新建3个文件:
helloworld.c
configure.ac
Makefile.am
2.执行下面一串指令:
$ aclocal; autoconf; automake --add-missing; ./configure; make; ./helloworld
其中brew安装的文件位置,一般是:(Macintosh HD下)
/usr/local/Cellar/xxx
1.没有什么依赖关系的
2.有大量依赖,还要交叉编译的
…待添加