搭建环境并编译WinSCP的具体流程

一 环境准备

  1. 下载地址(以5.13.4为例):https://github.com/winscp/winscp/archive/5.13.4.zip
  2. 拿到 5.13.4.zip 源码包后解压解压源码
  3. 下载 nasm 工具和 Object file converter 工具,并将其放到源码根目录下的 buildtools/tools 目录

    nasm & Object file converter

    nasm & Object file converter

  4. 安装 Embarcadero C++ Builder XE6 Professional
  5. 安装 Build Tools and Agents for Visual Studio 2017 (for C# 7.0)

二 编译 MFC 库

  1. 新建目录C:Program Files (x86)EmbarcaderoStudio14.0sourcemfc
  2. 新建目录C:Program Files (x86)EmbarcaderoStudio14.0includemfc
  3. 拷贝 5.13.4winscp-5.13.4libsmfcsource 到目录C:Program Files (x86)EmbarcaderoStudio14.0sourcemfc
  4. 拷贝 5.13.4winscp-5.13.4libsmfcinclude到目录C:Program Files (x86)EmbarcaderoStudio14.0includemfc
  5. 使用命令“make -f borland.mak NO_WARNINGS=1”或“make -f borland.mak NO_WARNINGS=1 -DDEBUG”编译 mfc 库文件,无视警告即可,编译后生成mfc的dll库

    mfc-dll

    mfc-dll

三 执行build.bat

  1. 执行源码根目录下的 build.bat 命令

    build_bat

    build_bat

  2. 遇到 PuTTYVS 错误

    PuTTYVS

    PuTTYVS

  3. 使用VS2017打开 PuTTYVS 解决方案,重定向项目,生成项目
    PuTTYVS-relocate

    PuTTYVS-relocate

    PuTTYVS-build

    PuTTYVS-build

  4.  再次执行 build.bat,生成所需的lib

    execute-build-bat

    execute-build-bat

  5. 可在 5.13.4winscp-5.13.4libslib 目录查看生成的 lib

    build-out-libs

    build-out-libs

四 使用 XE6 编译 WinSCP

  1. 打开 C++Builder XE6, 将 5.13.4winscp-5.13.4sourceWinSCP.groupproj 拖进去

    xe6-winscp

    xe6-winscp

  2. 修改所有的子项目的配置,选中子项目右键单击选择 Options,将 BPI/LIB output目录 Final output directory目录Library path目录 设置为 5.13.4winscp-5.13.4output 目录;其中 WinSCP.exe 项目的 Library path 额外包含刚编译出来的 mfc 的dll库所在的目录
    xe6-options

    xe6-options

    Project-Options-Settings

    Project-Options-Settings

    Library-path

    Library-path

     

  3. Build all

    build-all-winscp

    build-all-winscp

  4. 编译成功

    winscp-build-success

    winscp-build-success

  5. 查看 5.13.4winscp-5.13.4output 目录下生成的 WinSCP.exe

    checkout-winscp

    checkout-winscp

Advertisements

分类:Development

Tagged as:

发表评论

Fill in your details below or click an icon to log in:

WordPress.com 徽标

You are commenting using your WordPress.com account. Log Out /  更改 )

Google+ photo

You are commenting using your Google+ account. Log Out /  更改 )

Twitter picture

You are commenting using your Twitter account. Log Out /  更改 )

Facebook photo

You are commenting using your Facebook account. Log Out /  更改 )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.