2018년 4월 17일 화요일

import ibm_db 시의 "libibmc++.so.1: cannot open shared object file" error 해결 방법

앞선 posting에서 정리한 IBM DB2 client 설치 후 "import ibm_db"를 할 때 다음과 같은 error를 겪을 수 있습니다.

user01@lcia-minsky01:~$ python3
>>> import ibm_db
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: libibmc++.so.1: cannot open shared object file: No such file or directory

이 "libibmc++.so.1: cannot open shared object file: No such file or directory" error는 pip install과는 무관한 것으로서, 서버에 IBM XL C/C++ compiler가 설치되어 있지 않기 때문에 발생하는 것입니다.  (아래 link 참조)

https://www-01.ibm.com/support/docview.wss?uid=swg21249819

문제는 이 XL C/C++ compiler가 유료 SW라는 점입니다.  다행인 점은 이 SW의 무료 Community Edition도 있고 그 download link도 (아래 link 참조) 있다는 것이고요.

아래 link에 따라 진행하면 됩니다.

https://www.ibm.com/developerworks/community/blogs/572f1638-121d-4788-8bbb-c4529577ba7d/entry/Download_XL_Fortran_for_Linux_V15_1_6_Community_Edition_a_no_charge_fully_functional_unlimited_production_use_compiler?lang=en

http://public.dhe.ibm.com/software/server/POWER/Linux/xl-compiler/eval/ppc64le/README.html


먼저 아래와 같이 IBM site인 http://public.dhe.ibm.com에 대해 trusted key를 업데이트 해줍니다.  이걸 해주면 /etc/apt/trusted.gpg key 값이 갱신됩니다.

minsky@minsky:~$ wget -q http://public.dhe.ibm.com/software/server/POWER/Linux/xl-compiler/eval/ppc64le/ubuntu/public.gpg -O- | sudo apt-key add -
OK

minsky@minsky:~$ ls -l /etc/apt/trusted.gpg
-rw-r--r-- 1 root root 20740 Apr 16 21:55 /etc/apt/trusted.gpg

다만, 위에서 보시는 바와 같이 이는 sudo 권한이 필요하며, 또 회사 정책에 따라 이런 작업을 못하게 되어 있을 수도 있습니다.  그런 경우 좌절하지 마시고 위 과정은 그냥 pass 하셔도 됩니다.  이를 안 해주면 나중에 apt-get update를 해줄 때마다 http://public.dhe.ibm.com에 대해서 "The repository is not signed"라는 warning이 귀찮게 나오지만, 그렇다고 설치가 안 되는 것은 아닙니다.

아래와 같이 apt repository를 새로 만듭니다.

minsky@minsky:~$ cd /etc/apt/sources.list.d/

minsky@minsky:/etc/apt/sources.list.d$ sudo vi xlc.list
deb [arch=ppc64el] http://public.dhe.ibm.com/software/server/POWER/Linux/xl-compiler/eval/ppc64le/ubuntu xenial main

그리고 apt repository를 갱신해줍니다.  아까 말씀드렸듯이, 만약 위의 trusted key를 갱신하지 않으면 아래처럼 warning이 나오는데, 무시하셔도 됩니다.

minsky@minsky:/etc/apt/sources.list.d$ sudo apt-get update
...
W: GPG error: http://public.dhe.ibm.com/software/server/POWER/Linux/xl-compiler/eval/ppc64le/ubuntu xenial InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 4B19F6F50761C815
W: The repository 'http://public.dhe.ibm.com/software/server/POWER/Linux/xl-compiler/eval/ppc64le/ubuntu xenial InRelease' is not signed.
N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.

이제 아래와 같이 XLC compiler Community Edition을 설치합니다.   역시 trusted key를 갱신하지 않으면 아래처럼 warning이 나오는데 무시하시고 Y를 눌러 진행하십시요.

minsky@minsky:/etc/apt/sources.list.d$ sudo apt-get install xlc.13.1.6 libxlc-devel.13.1.6 xlc-license-community.13.1.6
...
WARNING: The following packages cannot be authenticated!
  libxlc libxlc-devel.13.1.6 libxlmass-devel.8.1.6 libxlsmp libxlsmp-devel.4.1.6
  xlc-license-community.13.1.6 xlc.13.1.6
Install these packages without verification? [y/N] y
...
Setting up libxlc (13.1.6.1-171213) ...
Setting up libxlc-devel.13.1.6 (13.1.6.1-171213) ...
Setting up libxlmass-devel.8.1.6 (8.1.6.0-171201) ...
Setting up libxlsmp (4.1.6.1-171213) ...
Setting up libxlsmp-devel.4.1.6 (4.1.6.1-171213) ...
Setting up xlc-license-community.13.1.6 (13.1.6.1-171213) ...
Note: XL C/C++ Community Edition is a no-charge product and does not include official IBM support.
You can provide feedback at the XL on POWER C/C++ Community Edition forum (http://ibm.biz/xlcpp-linux-ce).
For information about a fully supported XL C/C++ compiler,
visit XL C/C++ for Linux (http://ibm.biz/xlcpp-linux).
Setting up xlc.13.1.6 (13.1.6.1-171213) ...
Run 'sudo /opt/ibm/xlC/13.1.6/bin/xlc_configure' to review the license and configure the compiler.

이제 설치가 끝났습니다.  설치되는 directory는 /opt/ibm 입니다.  아래와 같이 찾아보면 /opt/ibm/lib/libibmc++.so.1 이 존재하는 것을 보실 수 있습니다.

minsky@minsky:~$ sudo find /opt -name libibmc++.so.1
/opt/ibm/lib/profiled/libibmc++.so.1
/opt/ibm/lib/libibmc++.so.1

이제 다음과 같이 ibm_db를 import 할 때 아무 문제가 없는 것을 보실 수 있습니다.

minsky@minsky:~$ python
Python 3.6.4 |Anaconda, Inc.| (default, Feb 11 2018, 08:19:13)
[GCC 7.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ibm_db
>>>


** 아마 별도로 LD_LIBRARY_PATH를 안 줘도 될텐데 (저같은 경우는 안 줘도 되더군요), 혹시 error가 나면 LD_LIBRARY_PATH에 위 directory를 첨가해주시면 됩니다.

$ export LD_LIBRARY_PATH=/opt/ibm/lib:$LD_LIBRARY_PATH

** 이 XLC/C++ compiler는 어디까지나 Community Edition으로서, 별도의 기술/장애 지원이 안 되는 무료 SW라는 점을 유의하시기 바랍니다.

댓글 없음:

댓글 쓰기