libssh-0.10.5 on CentOS 5.8
- 홈페이지 : https://www.libssh.org/
1. 준비작업
1.1. 다운로드
https://www.libssh.org/files/ 에서 다운로드 한다.
CentOS 5.8 에서 직접 다운로드 할 수 없고, 다른 장비에서 다운로드 한 파일을 sftp 따위로 올려야 한다.
curl -O -L https://www.libssh.org/files/0.10/libssh-0.10.5.tar.xz
다만, 필자가 작성한 다른 글에 따라 wget 을 설치했다면, 다음과 같이 할 수도 있다.
/opt/wget-1.21.4/bin/wget \ --no-check-certificate \ https://www.libssh.org/files/0.10/libssh-0.10.5.tar.xz
1.2. make, gcc, gcc-c++ 및 xz 설치
yum install make gcc gcc-c++ xz -y
1.3. openssl-1.1.1u 혹은 libgcrypt-1.8.10( + libgpg-error-1.47) 설치
openssl-1.1.1u 혹은 libgcrypt-1.8.10( + libgpg-error-1.47) 이 있어야 한다.
openssl-1.1.1u 은 openssl-3.0.9 이나 openssl-3.1.1 으로 대체될 수 있다.
이런 것들의 설치방법은 필자가 작성한 다른 글들을 참조한다.
1.4. cmake-3.9.6 설치
설치방법은 필자가 작성한 다른 글들을 참조한다.
2. 컴파일 및 설치
설치 디렉토리(-DCMAKE_INSTALL_PREFIX
) 는 알아서 변경한다.
대부분의 Linux 배포판들은 /usr 이 설치 디렉토리(
-DCMAKE_INSTALL_PREFIX
)이지만, 컴파일해서 설치하는 것들은 /usr/local 이나 /opt 아래에 두는 경우가 많다.
$ mkdir -p logs/libssh-0.10.5 $ unxz -k libssh-0.10.5.tar.xz $ tar xvf libssh-0.10.5.tar > logs/libssh-0.10.5/tar.`date +%Y%m%d.%H%M%S`.log 2>&1 $ cd libssh-0.10.5 $ mkdir build $ cd build $ LDFLAGS="-L/opt/libgcrypt-1.8.10/lib -lgcrypt" \ CFLAGS="-I/opt/libgpg-error-1.47/include" \ cmake .. \ -DCMAKE_INSTALL_PREFIX=/opt/libssh-0.10.5 \ -DGCRYPT_ROOT_DIR=/opt/libgcrypt-1.8.10 \ -DGCRYPT_LIBRARY=/opt/libgcrypt-1.8.10/lib \ -DGCRYPT_ERROR_LIBRARY=/opt/libgpg-error-1.47/lib \ -DCMAKE_BUILD_TYPE=Release \ -DWITH_GCRYPT=ON \ -DWITH_SERVER=OFF > ../../logs/libssh-0.10.5/config.`date +%Y%m%d.%H%M%S`.log 2>&1
만약 openssl 을 사용하려면 cmake 부분을 다음과 같이 변경한다.
$ cmake .. \ -DCMAKE_INSTALL_PREFIX=/opt/libssh-0.10.5 \ -DOPENSSL_ROOT_DIR=/opt/openssl-1.1.1u \ -DCMAKE_BUILD_TYPE=Release \ -DWITH_SERVER=OFF > ../../logs/libssh-0.10.5/config.`date +%Y%m%d.%H%M%S`.log 2>&1
make 를 하기 전에 config.h 에서 #define HAVE_STRNDUP 1
을 삭제한다.
sed -i '/^#define HAVE_STRNDUP 1$/d' config.h
make 를 수행한다.
$ make > ../logs/libssh-0.10.5/make.`date +%Y%m%d.%H%M%S`.log 2>&1 $ make install > ../logs/libssh-0.10.5/install.`date +%Y%m%d.%H%M%S`.log 2>&1
3. 적용
3.1. 현재 환경에 적용
현재 환경에서는 다음과 같이 적용한다.
$ export LD_LIBRARY_PATH=/opt/libssh-0.10.5/lib64:${LD_LIBRARY_PATH}
pkg-config 를 사용하는 경우 다음의 내용도 추가할 수 있다.
export PKG_CONFIG_PATH=${PKG_CONFIG_PATH}:/opt/libssh-0.10.5/lib64/pkgconfig
3.2. 현재 로그인한 사용자에게 적용
현재 로그인한 사용자에게 적용하려면, ".bash_profile" 파일의 끝에 위의 내용을 추가한다.
3.3. 시스템 전체에 적용
3.3.1. 환경변수 변경
"/etc/bashrc" 파일의 끝에 위의 내용을 추가한다.
4. 문제해결
4.1. cmake 를 찾을수 없다는 에러
-bash: cmake: command not found
cmake-3.9.6 을 설치하고, PATH 환경변수를 추가한다.
4.2. strndup 함수 에러
libssh-0.10.5/src/dh.c: In function ‘ssh_get_b64_unpadded’: libssh-0.10.5/src/dh.c:719: error: implicit declaration of function ‘strndup’ libssh-0.10.5/src/dh.c:719: warning: incompatible implicit declaration of built-in function ‘strndup’ make[2]: *** [src/CMakeFiles/ssh.dir/dh.c.o] Error 1 make[1]: *** [src/CMakeFiles/ssh.dir/all] Error 2 make: *** [all] Error 2
make 를 하기 전에 config.h 에서 #define HAVE_STRNDUP 1
을 삭제한다.
sed -i '/^#define HAVE_STRNDUP 1$/d' config.h
4.3. 알수 없는 에러
-- Performing Test HAVE_MSC_THREAD_LOCAL_STORAGE - Failed CMake Error at ConfigureChecks.cmake:326 (string): string does not recognize sub-command APPEND Call Stack (most recent call first): CMakeLists.txt:116 (include) CMake Error at ConfigureChecks.cmake:332 (string): string does not recognize sub-command APPEND Call Stack (most recent call first): CMakeLists.txt:116 (include)
다음이 누락되었다.
$ mkdir build $ cd build
4.4. gpg-error.h 파일이 없다는 에러
gcrypt.h:31:23: error: gpg-error.h: No such file or directory In file included from include/libssh/libgcrypt.h:28, from include/libssh/wrapper.h:29, from include/libssh/packet.h:24, from include/libssh/session.h:28, from src/agent.c:60: gcrypt.h:136: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gcry_error_t’ gcrypt.h:137: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gcry_err_code_t’ gcrypt.h:138: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gcry_err_source_t’ gcrypt.h:140: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gcry_error_t’ gcrypt.h:152: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gcry_error_t’ gcrypt.h:158: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gcry_err_code_t’ gcrypt.h:165: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gcry_err_source_t’ gcrypt.h:173: error: expected ‘)’ before ‘err’ gcrypt.h:177: error: expected ‘)’ before ‘err’ gcrypt.h:182: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gcry_err_code_from_errno’ gcrypt.h:186: error: expected ‘)’ before ‘code’ gcrypt.h:190: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gcry_err_make_from_errno’ gcrypt.h:193: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gcry_error_from_errno’ gcrypt.h:340: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gcry_control’ gcrypt.h:367: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gcry_sexp_new’ gcrypt.h:373: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gcry_sexp_create’ gcrypt.h:379: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gcry_sexp_sscan’ gcrypt.h:384: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gcry_sexp_build’ gcrypt.h:389: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gcry_sexp_build_array’ gcrypt.h:398: error: expected declaration specifiers or ‘...’ before ‘gcry_error_t’ gcrypt.h:522: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gcry_sexp_extract_param’ gcrypt.h:616: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gcry_mpi_scan’ gcrypt.h:625: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gcry_mpi_print’ gcrypt.h:634: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gcry_mpi_aprint’ gcrypt.h:726: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gcry_mpi_ec_new’ gcrypt.h:737: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gcry_mpi_ec_set_mpi’ gcrypt.h:741: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gcry_mpi_ec_set_point’ gcrypt.h:745: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gcry_mpi_ec_decode_point’ gcrypt.h:996: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gcry_cipher_open’ gcrypt.h:1003: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gcry_cipher_ctl’ gcrypt.h:1007: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gcry_cipher_info’ gcrypt.h:1011: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gcry_cipher_algo_info’ gcrypt.h:1032: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gcry_cipher_encrypt’ gcrypt.h:1037: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gcry_cipher_decrypt’ gcrypt.h:1042: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gcry_cipher_setkey’ gcrypt.h:1047: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gcry_cipher_setiv’ gcrypt.h:1051: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gcry_cipher_authenticate’ gcrypt.h:1055: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gcry_cipher_gettag’ gcrypt.h:1059: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gcry_cipher_checktag’ gcrypt.h:1083: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gcry_cipher_setctr’ gcrypt.h:1131: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gcry_pk_encrypt’ gcrypt.h:1136: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gcry_pk_decrypt’ gcrypt.h:1141: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gcry_pk_sign’ gcrypt.h:1145: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gcry_pk_verify’ gcrypt.h:1149: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gcry_pk_testkey’ gcrypt.h:1154: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gcry_pk_genkey’ gcrypt.h:1157: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gcry_pk_ctl’ gcrypt.h:1160: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gcry_pk_algo_info’ gcrypt.h:1193: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gcry_pubkey_get_sexp’ gcrypt.h:1282: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gcry_md_open’ gcrypt.h:1288: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gcry_md_enable’ gcrypt.h:1291: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gcry_md_copy’ gcrypt.h:1297: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gcry_md_ctl’ gcrypt.h:1311: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gcry_md_extract’ gcrypt.h:1323: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gcry_md_hash_buffers’ gcrypt.h:1342: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gcry_md_info’ gcrypt.h:1346: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gcry_md_algo_info’ gcrypt.h:1360: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gcry_md_setkey’ gcrypt.h:1466: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gcry_mac_open’ gcrypt.h:1473: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gcry_mac_ctl’ gcrypt.h:1477: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gcry_mac_algo_info’ gcrypt.h:1481: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gcry_mac_setkey’ gcrypt.h:1485: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gcry_mac_setiv’ gcrypt.h:1490: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gcry_mac_write’ gcrypt.h:1494: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gcry_mac_read’ gcrypt.h:1497: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gcry_mac_verify’ gcrypt.h:1545: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gcry_kdf_derive’ gcrypt.h:1588: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gcry_random_add_bytes’ gcrypt.h:1654: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gcry_prime_generate’ gcrypt.h:1667: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gcry_prime_group_generator’ gcrypt.h:1678: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gcry_prime_check’
다음이 누락되었다.
CFLAGS="-I/opt/libgpg-error-1.47/include"
4.5. undefined reference 에러
../lib/libssh.so.4.9.5: undefined reference to `gcry_mpi_test_bit' ../lib/libssh.so.4.9.5: undefined reference to `gcry_mpi_ec_decode_point' ../lib/libssh.so.4.9.5: undefined reference to `gcry_pk_sign' ../lib/libssh.so.4.9.5: undefined reference to `gcry_mpi_mul_ui' ../lib/libssh.so.4.9.5: undefined reference to `gcry_mpi_cmp' ../lib/libssh.so.4.9.5: undefined reference to `gcry_md_close' ../lib/libssh.so.4.9.5: undefined reference to `gcry_cipher_setiv' ../lib/libssh.so.4.9.5: undefined reference to `gcry_check_version' ../lib/libssh.so.4.9.5: undefined reference to `gcry_pk_genkey' ../lib/libssh.so.4.9.5: undefined reference to `gcry_md_read' ../lib/libssh.so.4.9.5: undefined reference to `gcry_sexp_find_token' ../lib/libssh.so.4.9.5: undefined reference to `gcry_pk_get_nbits' ../lib/libssh.so.4.9.5: undefined reference to `gcry_mpi_div' ../lib/libssh.so.4.9.5: undefined reference to `gcry_mpi_point_new' ../lib/libssh.so.4.9.5: undefined reference to `gcry_md_get_algo' ../lib/libssh.so.4.9.5: undefined reference to `gcry_cipher_setkey' ../lib/libssh.so.4.9.5: undefined reference to `gcry_mpi_point_snatch_get' ../lib/libssh.so.4.9.5: undefined reference to `gcry_mpi_cmp_ui' ../lib/libssh.so.4.9.5: undefined reference to `gcry_mpi_set_ui' ../lib/libssh.so.4.9.5: undefined reference to `gcry_sexp_extract_param' ../lib/libssh.so.4.9.5: undefined reference to `gcry_mpi_scan' ../lib/libssh.so.4.9.5: undefined reference to `gcry_mpi_new' ../lib/libssh.so.4.9.5: undefined reference to `gcry_cipher_setctr' ../lib/libssh.so.4.9.5: undefined reference to `gcry_mac_verify' ../lib/libssh.so.4.9.5: undefined reference to `gcry_mac_write' ../lib/libssh.so.4.9.5: undefined reference to `gcry_pk_encrypt' ../lib/libssh.so.4.9.5: undefined reference to `gcry_mac_close' ../lib/libssh.so.4.9.5: undefined reference to `gcry_md_setkey' ../lib/libssh.so.4.9.5: undefined reference to `gcry_md_get_algo_dlen' ../lib/libssh.so.4.9.5: undefined reference to `gcry_mpi_copy' ../lib/libssh.so.4.9.5: undefined reference to `gcry_cipher_checktag' ../lib/libssh.so.4.9.5: undefined reference to `gcry_pk_verify' ../lib/libssh.so.4.9.5: undefined reference to `gcry_sexp_release' ../lib/libssh.so.4.9.5: undefined reference to `gcry_mpi_add_ui' ../lib/libssh.so.4.9.5: undefined reference to `gcry_md_write' ../lib/libssh.so.4.9.5: undefined reference to `gcry_mpi_powm' ../lib/libssh.so.4.9.5: undefined reference to `gcry_randomize' ../lib/libssh.so.4.9.5: undefined reference to `gcry_strerror' ../lib/libssh.so.4.9.5: undefined reference to `gpg_strerror' ../lib/libssh.so.4.9.5: undefined reference to `gcry_mpi_aprint' ../lib/libssh.so.4.9.5: undefined reference to `gcry_mpi_set_bit' ../lib/libssh.so.4.9.5: undefined reference to `gcry_mpi_print' ../lib/libssh.so.4.9.5: undefined reference to `gcry_cipher_gettag' ../lib/libssh.so.4.9.5: undefined reference to `gcry_cipher_authenticate' ../lib/libssh.so.4.9.5: undefined reference to `gcry_mac_read' ../lib/libssh.so.4.9.5: undefined reference to `gcry_cipher_open' ../lib/libssh.so.4.9.5: undefined reference to `gcry_cipher_close' ../lib/libssh.so.4.9.5: undefined reference to `gcry_cipher_decrypt' ../lib/libssh.so.4.9.5: undefined reference to `gcry_sexp_build' ../lib/libssh.so.4.9.5: undefined reference to `gcry_mpi_randomize' ../lib/libssh.so.4.9.5: undefined reference to `gcry_mac_open' ../lib/libssh.so.4.9.5: undefined reference to `gcry_sexp_nth_mpi' ../lib/libssh.so.4.9.5: undefined reference to `gcry_mpi_get_nbits' ../lib/libssh.so.4.9.5: undefined reference to `gcry_cipher_encrypt' ../lib/libssh.so.4.9.5: undefined reference to `gcry_mpi_sub' ../lib/libssh.so.4.9.5: undefined reference to `gcry_md_open' ../lib/libssh.so.4.9.5: undefined reference to `gcry_mpi_release' ../lib/libssh.so.4.9.5: undefined reference to `gcry_mac_setkey' ../lib/libssh.so.4.9.5: undefined reference to `gcry_mpi_mod' ../lib/libssh.so.4.9.5: undefined reference to `gcry_control' ../lib/libssh.so.4.9.5: undefined reference to `gcry_md_ctl' ../lib/libssh.so.4.9.5: undefined reference to `gcry_sexp_nth_data' ../lib/libssh.so.4.9.5: undefined reference to `gcry_md_hash_buffer'
다음이 누락되었다.
LDFLAGS="-L/opt/libgcrypt-1.8.10/lib -lgcrypt"