天天看點

SUSE Linux上源碼安裝libssh2

緣起

  • 要給測試支援一下,在SUSE Linux上安裝libssh2,環境上有了openssl-1.0.1g和libssh2-1.8.0。
    • uname -a

      還看不了發行版本。隻能使用

      cat /etc/issue

      lsb_release -a

      檢視。

解決過程

第一步

  • 之前沒有安裝過,于是搜尋一番。linux環境編譯libssh2
    • 有且隻找到一個合适的,當時一直卡在

      -fPIC

      參數的問題,雖解決./config的問題,但make時又報錯。
  • 沒招了,跟同僚回報了一下,給了一份簡要的指導
    • ./config --prefix=/home/openssl-1.0.1g --openssldir=/home/openssl-1.0.1g/ssl

      ,根據文檔裡的這個指令改成源碼的路徑。
    • 執行報錯 Makefile:548: recipe for target 'install_sw' failed,根據提示,重新配置了一下,make OK。

第二步

  • 移交給測試後,她試了一下還是報錯。fatal error:libssh2_config.h:No such file or directory。
    • 這個大機率就是路徑沒有配置正确。

      -I/src -I/include

    • .profile

      export LIBSSH2_HOME=/usr/local/libssh2

      ,執行

      source .profile

      後,編譯代碼路徑下的

      Makefile.incl.platform

      就能得值,執行就OK。

第三步

  • 說是HP和SUSE的還不太一樣,HP的還需要再修改值。被勉勵了 要自己多思考和定位,而不要總想着現成的。
  • 想到了之前更新GCC6的時候,其實也這麼配過,但沒想過這麼多,當時就是照着抄了。
  • 源代碼編譯時,要抽象出一些方法論來,确實思路都差不多。

内容

cd openssl-1.0.1s/
  ./config --prefix=/usr/local/openssl --openssldir=/usr/local/openssl/ssl
  make && make install
  ./config shared --prefix=/usr/local/openssl --openssldir=/usr/local/openssl/ssl
  make clean
  make && make install


cd libssh2-1.8.0/
  ./configure --prefix=/usr/local/libssh2 --with-openssl CPPFLAGS="-I/usr/local/openssl/include" LDFLAGS="-L/usr/local/openssl/lib"
  make clean
  make && make install
           

其它

  • 20190128安裝的,20190129整理。

繼續閱讀