kylin x86编译libodbc.a

有个模块UniDBTool链接了odbc的动态库,某天架构组要求提供一个不依赖的版本供他们使用。

//环境信息
[root@kylin:/mnt/hgfs/work/UniDBTool/default]$ cat /etc/os-release
NAME="Kylin"
VERSION="银河麒麟桌面操作系统V10 (SP1)"
VERSION_US="Kylin Linux Desktop V10 (SP1)"
ID=kylin
ID_LIKE=debian
PRETTY_NAME="Kylin V10 SP1"
VERSION_ID="v10"
HOME_URL="http://www.kylinos.cn/"
SUPPORT_URL="http://www.kylinos.cn/support/technology.html"
BUG_REPORT_URL="http://www.kylinos.cn/"
PRIVACY_POLICY_URL="http://www.kylinos.cn"
VERSION_CODENAME=kylin
UBUNTU_CODENAME=kylin
PROJECT_CODENAME=v10sp1
[root@kylin:/mnt/hgfs/work/UniDBTool/default]$ uname -a
Linux kylin 5.4.18-27-generic #13-KYLINOS SMP Thu May 13 03:06:58 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux


//kylin x86编译libodbc.a
//下载unixodbc源码
1)wget https://www.unixodbc.org/unixODBC-2.3.9.tar.gz

//执行configure 添加相关选项
2)./configure --enable-static --prefix=/usr/local/unixodbc

//执行make遇到了问题,kylin x86 要求automake版本为1.5
3)make
[root@kylin:~]$ cd /mnt/hgfs/work/unixODBC-2.3.9/
[root@kylin:/mnt/hgfs/work/unixODBC-2.3.9]$ make
CDPATH="${ZSH_VERSION+.}:" && cd . && /bin/bash /mnt/hgfs/work/unixODBC-2.3.9/missing aclocal-1.15 -I m4
/mnt/hgfs/work/unixODBC-2.3.9/missing:行81: aclocal-1.15:未找到命令
WARNING: 'aclocal-1.15' 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: *** [Makefile:485:aclocal.m4] 错误 127

//查看automake版本
[root@kylin:/mnt/hgfs/work/unixODBC-2.3.9]$ automake --version
automake (GNU automake) 1.16.1
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv2+: GNU GPL version 2 or later <https://gnu.org/licenses/gpl-2.0.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Tom Tromey <[email protected]>
       and Alexandre Duret-Lutz <[email protected]>.

//卸载automake
[root@kylin:/mnt/hgfs/work/unixODBC-2.3.9]$ apt-get remove automake
正在读取软件包列表... 完成
正在分析软件包的依赖关系树
正在读取状态信息... 完成
下列软件包是自动安装的并且现在不需要了:
  archdetect-deb cryptsetup cryptsetup-bin hplip-data libdebian-installer4 libsane-hpaio libyaml-cpp0.6 localechooser-data
  minizip python3-pexpect python3-ptyprocess user-setup
使用'apt autoremove'来卸载它(它们)。
下列软件包将被【卸载】:
  automake
升级了 0 个软件包,新安装了 0 个软件包,要卸载 1 个软件包,有 26 个软件包未被升级。
解压缩后将会空出 1,582 kB 的空间。
您希望继续执行吗? [Y/n] y
(正在读取数据库 ... 系统当前共安装有 208460 个文件和目录。)
正在卸载 automake (1:1.16.1-4kylin6) ...
正在处理用于 install-info (6.7.0.dfsg.2-5kylin0k2~rc1) 的触发器 ...
正在处理用于 man-db (2.9.1-1kylin0k1) 的触发器 ...

//安装指定版本automake
[root@kylin:/mnt/hgfs/work/unixODBC-2.3.9]$ apt-get install automake-1.15
正在读取软件包列表... 完成
正在分析软件包的依赖关系树
正在读取状态信息... 完成
下列软件包是自动安装的并且现在不需要了:
  archdetect-deb cryptsetup cryptsetup-bin hplip-data libdebian-installer4 libsane-hpaio libyaml-cpp0.6 localechooser-data
  minizip python3-pexpect python3-ptyprocess user-setup
使用'apt autoremove'来卸载它(它们)。
建议安装:
  autoconf-doc gnu-standards
下列【新】软件包将被安装:
  automake-1.15
升级了 0 个软件包,新安装了 1 个软件包,要卸载 0 个软件包,有 26 个软件包未被升级。
需要下载 525 kB 的归档。
解压缩后会消耗 1,589 kB 的额外空间。
获取:1 http://archive.kylinos.cn/kylin/KYLIN-ALL 10.1/main amd64 automake-1.15 all 1:1.15.1-5kylin2 [525 kB]
已下载 525 kB,耗时 0(2,221 kB/s)
正在选中未选择的软件包 automake-1.15。
(正在读取数据库 ... 系统当前共安装有 208331 个文件和目录。)
准备解压 .../automake-1.15_1%3a1.15.1-5kylin2_all.deb  ...
正在解压 automake-1.15 (1:1.15.1-5kylin2) ...
正在设置 automake-1.15 (1:1.15.1-5kylin2) ...
update-alternatives: 使用 /usr/bin/automake-1.15 来在自动模式中提供 /usr/bin/automake (automake)
正在处理用于 install-info (6.7.0.dfsg.2-5kylin0k2~rc1) 的触发器 ...
正在处理用于 man-db (2.9.1-1kylin0k1) 的触发器 ...

//查看版本符合要求接着make
[root@kylin:/mnt/hgfs/work/UniDBTool/default]$ automake --version
automake (GNU automake) 1.15.1
Copyright (C) 2017 Free Software Foundation, Inc.
License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl-2.0.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Tom Tromey <[email protected]>
       and Alexandre Duret-Lutz <[email protected]>.
	   
//执行make install
4)make install

5)编译完的静态库位置 unixODBC-2.3.9/DriverManager/.libs/libodbc.a

6)
//编译的项目中将SYSLIB中原先链接的方式由动态改为静态

CC= g++ -std=c++11
MAIN_PATH=../
BS_PATH=../../BlowSnow/source
VPATH =$(MAIN_PATH):$(BS_PATH)
SOURCE=$(wildcard ../*.cpp)
SNOTDIR=$(notdir $(SOURCE))
SOURCE_C=$(wildcard *.c $(BS_PATH)/DES.c)
SNOTDIR_C=$(notdir $(SOURCE_C))
OBJS=$(patsubst %.cpp, %.o, $(SNOTDIR) )
OBJS_C=$(patsubst %.c,%.o,$(SNOTDIR_C) )
#SYSLIB=-lrt -pthread -lodbc -ldl
SYSLIB=-lrt -pthread -ldl
OTHERLIB= ../../BlowSnow/source/libblowsnow_db.a /mnt/hgfs/work/unixODBC-2.3.9/DriverManager/.libs/libodbc.a
CFLAGS= -O2 -c -Werror -D_GNU_SOURCE -DUNIARC_SOURCE_LINK -I. -I/usr/include -I/usr/local/include -I$(MAIN_PATH) -I$(BS_PATH)
TARGET= ./build/UniDBTool

[root@kylin:/mnt/hgfs/work/UniDBTool/default/build]$ ldd UniDBTool
        linux-vdso.so.1 (0x00007ffdeeb44000)
        libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fbfe97aa000)
        libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fbfe95c8000)
        libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fbfe95ad000)
        libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fbfe958a000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fbfe9398000)
        /lib64/ld-linux-x86-64.so.2 (0x00007fbfe9ae3000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fbfe9249000)
[root@kylin:/mnt/hgfs/work/UniDBTool/default/build]$ nm -A UniDBTool |grep -i "rlogon*"
UniDBTool:000000000009d100 W _ZN8otl_conn6rlogonEPKci
[root@kylin:/mnt/hgfs/work/UniDBTool/default/build]$ c++filt _ZN8otl_conn6rlogonEPKci
otl_conn::rlogon(char const*, int)
[root@kylin:/mnt/hgfs/work/UniDBTool/default/build]$

//随后提供给架构组同事 验证通过

你可能感兴趣的:(kylin,大数据)