Compiling libssh2 in Windows with MinGW-builds

Unlike libssh, which uses cmake, libssh2 forces you to use Linux-like environment even in Windows, which eventually makes you to install MSYS on your system. You can find many ways are to build libssh2 in Windows on the net, but most of them requires you to manually edit configuration files in some way.

OK, here goes the opposite…… You’ll NOT MAKE ANY CHANGES in the source code.

First, the requirements:

  1. MSYS
  2. MinGW-w64 based build. I used two variants: MinGW-builds 64bit-winthreads-SEH exception build, but TDM-GCC 64bit also works
  3. libssh2 source codes(of course! :P)
And the procedure:
  1. Decompress the source code.
  2. The most important step: force to add OpenSSL and Win32 libraries OpenSSL needs on configure step, something like this:
    ./configure –with-libs-prefix=“/d/Components/openssl” –with-libssl-prefix=“/d/Components/z” LDFLAGS=“-L/d/Components/openssl/lib -lssl -l crypto -lgdi32 -lws2_32”
  3. [Optional] If you’re building 64bit binary, dont forget to add –build=amd64 before LDFLAGS, like this:
    ./configure –with-libs-prefix=“/d/Components/openssl” –with-libssl-prefix=“/d/Components/z” –build=amd64 LDFLAGS=“-L/d/Components/openssl/lib -lssl -l crypto -lgdi32 -lws2_32”
  4. run make and enjoy. :)
  5. PROFIT!
Hope this helps some lost sheeps who want to build libssh2 in his/her own.

No comments:

Post a Comment

블로그를 이전합니다

뭐, 이런 작은 변방의 블로그에 관심있으신 분들은 아무도 없으시리라 생각합니다만...... (웃음) 블로그 플랫폼을 블로거에서 dev.to로 옮겼습니다. 새 URL은 아래와 같습니다: https://dev.to/teminian 새로운 거처에서 뵙겠습니...

Popular in Code{nested}