最近由于工作需要用到ODBC,这里做个记录
下载
这个地址很容易搜到 https://www.unixodbc.org/
编译
[root@localhost ~]# ls unixODBC-2.3.12.tar.gz
unixODBC-2.3.12.tar.gz
[root@localhost ~]# tar -zxvf unixODBC-2.3.12.tar.gz
[root@localhost ~]# cd unixODBC-2.3.12
[root@localhost unixODBC-2.3.12]# ./configure --disable-shared
[root@localhost unixODBC-2.3.12]# make
[root@localhost unixODBC-2.3.12]# make install
由于我在C里面用,需要用到静态库,所以编译静态版本
也可以指定其他参数,详细看configure --help
./configure --prefix=/usr/local/unixODBC-2.2.1 --includedir=/usr/include --libdir=/usr/lib64 -bindir=/usr/bin --sysconfdir=/etc --disable-shared
到这里一切顺利
问题
由于在其他地方用到,直接拷贝到对应目录然后重新编译时编译不过
[root@localhost ~]# cp unixODBC-2.3.12 unixODBC -r
[root@localhost ~]# cd unixODBC
[root@localhost unixODBC]# ./configure --disable-shared
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking for gawk... (cached) gawk
checking for bison... bison -y
checking whether make supports the include directive... yes (GNU style)
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
然后make的时候报错了
[root@localhost unixODBC]# make
CDPATH="${ZSH_VERSION+.}:" && cd . && /bin/sh /root/unixODBC/missing aclocal-1.16 -I m4
/root/unixODBC/missing:行81: aclocal-1.16: 未找到命令
WARNING: 'aclocal-1.16' is missing on your system.
You should only need it if you modified 'acinclude.m4' or
'configure.ac' or m4 files included by 'configure.ac'.
The 'aclocal' program is part of the GNU Automake package:
<http://www.gnu.org/software/automake>
It also requires GNU Autoconf, GNU m4 and Perl in order to run:
<http://www.gnu.org/software/autoconf>
<http://www.gnu.org/software/m4/>
<http://www.perl.org/>
make: *** [aclocal.m4] 错误 127
编译 unixODBC时报错 aclocal-1.16不存在,这次编译和上次用的是同一台机,只是拷贝了一份,肯定不是aclocal的问题,这时候可以make -d看下编译详情
我这里对比了一下正常编译和报错情况的日志
那只能改一下对应文件的时间戳试试
[root@localhost unixODBC]# touch -t 202012020202 m4/*
[root@localhost unixODBC]# touch -t 202012020202 configure.ac
[root@localhost unixODBC]# touch -t 202012020202 acinclude.m4
[root@localhost unixODBC]# touch -t 202112020202 aclocal.m4
这时候再来编译,很顺畅就通过了