windows 使用mingw编译静态qssh

Note: 将mingw32的bit目录放到环境变量中

1. 编译botan

下载botan2.14.0(https://github.com/randombit/botan/tags), 其他botan版本兼容没试, 或许你可以试试, 高版本编译语句一样, 只是1.几的版本编译语句稍微自己研究下, 没记录

1) 生成Makefile

    python configure.py --os=mingw --cpu=x86_32 --cc-bin=i686-w64-mingw32-g++.exe --ar-command=i686-w64-mingw32-gcc-ar

2) 编译

mingw32-make 

3) 编译安装

提前修改Makefile, 将里面的\Mingw 替换成./Mingw 即安装目录为当前目录的mingw, 再直行下面指令,产生如下图文件目录

mingw32-make install

windows 使用mingw编译静态qssh

2. qssh环境搭建

下载源码 https://github.com/lvklabs/QSsh 

1)新建botan目录, 将一种产生的文件全部放进去, 再创建Qt project include文件(.pri)

windows 使用mingw编译静态qssh

##botan.pri 内容
INCLUDEPATH += $$PWD/include/botan-2
DEPENDPATH  += $$PWD/include/botan-2

LIBS += -L$$PWD/lib -llibbotan-2

2) 将下载的源码库的libs内的源码全部拷贝到一个新的目录, 例如取名叫qssh

windows 使用mingw编译静态qssh

##ssh.pri文件内容
INCLUDEPATH += $$PWD
include($$PWD/botan/botan.pri)

HEADERS += \
    $$PWD/sftpchannel.h \
    $$PWD/sftpchannel_p.h \
    $$PWD/sftpdefs.h \
    $$PWD/sftpfilesystemmodel.h \
    $$PWD/sftpincomingpacket_p.h \
    $$PWD/sftpoperation_p.h \
    $$PWD/sftpoutgoingpacket_p.h \
    $$PWD/sftppacket_p.h \
    $$PWD/ssh_global.h \
    $$PWD/sshbotanconversions_p.h \
    $$PWD/sshcapabilities_p.h \
    $$PWD/sshchannel_p.h \
    $$PWD/sshchannelmanager_p.h \
    $$PWD/sshconnection.h \
    $$PWD/sshconnection_p.h \
    $$PWD/sshconnectionmanager.h \
    $$PWD/sshcryptofacility_p.h \
    $$PWD/ssherrors.h \
    $$PWD/sshexception_p.h \
    $$PWD/sshincomingpacket_p.h \
    $$PWD/sshkeyexchange_p.h \
    $$PWD/sshkeygenerator.h \
    $$PWD/sshkeypasswordretriever_p.h \
    $$PWD/sshoutgoingpacket_p.h \
    $$PWD/sshpacket_p.h \
    $$PWD/sshpacketparser_p.h \
    $$PWD/sshpseudoterminal.h \
    $$PWD/sshremoteprocess.h \
    $$PWD/sshremoteprocess_p.h \
    $$PWD/sshremoteprocessrunner.h \
    $$PWD/sshsendfacility_p.h

SOURCES += \
    $$PWD/sftpchannel.cpp \
    $$PWD/sftpdefs.cpp \
    $$PWD/sftpfilesystemmodel.cpp \
    $$PWD/sftpincomingpacket.cpp \
    $$PWD/sftpoperation.cpp \
    $$PWD/sftpoutgoingpacket.cpp \
    $$PWD/sftppacket.cpp \
    $$PWD/sshcapabilities.cpp \
    $$PWD/sshchannel.cpp \
    $$PWD/sshchannelmanager.cpp \
    $$PWD/sshconnection.cpp \
    $$PWD/sshconnectionmanager.cpp \
    $$PWD/sshcryptofacility.cpp \
    $$PWD/sshincomingpacket.cpp \
    $$PWD/sshkeyexchange.cpp \
    $$PWD/sshkeygenerator.cpp \
    $$PWD/sshkeypasswordretriever.cpp \
    $$PWD/sshoutgoingpacket.cpp \
    $$PWD/sshpacket.cpp \
    $$PWD/sshpacketparser.cpp \
    $$PWD/sshremoteprocess.cpp \
    $$PWD/sshremoteprocessrunner.cpp \
    $$PWD/sshsendfacility.cpp

3. ssh源码内要去除 QSSH_EXPORT, 不然编译报错

windows 使用mingw编译静态qssh

 

Note:

1. SOURCES 和 HEADERS不要使用 *.h 和 *.cpp 进行包含,要一个个文件包含,不然编译时出错;

参考文章

win10系统下Qssh mater(支持sftps协议)包括依赖库的下载和编译

https://blog.csdn.net/aclcla/article/details/107137690

 

上一篇:Qt配置OpenCV时mingw32-make反复出错的原因


下一篇:2021-04-27 gcc 发布 gcc-11.1.0