【问题标题】:swig and building project with visual studios 2017 command lineswig 和使用 Visual Studio 2017 命令行构建项目
【发布时间】:2017-08-29 10:23:12
【问题描述】:

我需要从 SWIG 生成的 .cxx 文件创建一个 .pyd。对于 VS2017 和命令行,我有点菜鸟,我希望能得到一点帮助。

这是我到目前为止所做的:

适用于 Windows 的 SWIG 设置

1)。下载anaconda(使用python 3.6 x64版本)

2)。下载VS社区版

- installed all the c++ extensions

3)。下载了 FGDB API(windows 2017):

https://github.com/Esri/file-geodatabase-api/blob/master/FileGDB_API_1.5.1/FileGDB_API_1_5_1-VS2017.zip

4)。设置 Python 环境变量:

PYTHON_INCLUDE: C:\ProgramData\Anaconda3\include

PYTHON_LIB: C:\ProgramData\Anaconda3\libs\python36.lib

5)。下载并解压 Swig

6)。将 swig 路径添加到 PATH 环境变量

7)。从 google 主机或 github 下载 file-geodatabase-api 文件。 https://storage.googleapis.com/google-code-archive-source/v2/code.google.com/file-geodatabase-api-python-wrapper/source-archive.zip

8)。创建文件夹:C:\fgdb_code

  • 文件夹中应该有 .i、.py 和 make 文件

9)。将步骤 7 中的文件放在此文件夹中

10)。将步骤 #3 中的文件解压缩到步骤 #8 的文件夹中

c:\fgdb_code\FGDB

生成 .cxx 文件

11)。以管理员身份打开命令行窗口(可能不需要管理员)

12)。导航到 c:\fgdb_code 文件夹

13)。运行:swig -python -IFGDB/include -c++ filegdbapi.i

This generates a .cxx file

``` 输出消息:

FGDB\include\Util.h(819) : Warning 312: Nested union not currently supported (ignored).
FGDB\include\Util.h(838) : Warning 312: Nested union not currently supported (ignored).
FGDB\include\Util.h(843) : Warning 312: Nested union not currently supported (ignored).
FGDB\include\Util.h(849) : Warning 312: Nested union not currently supported (ignored).
FGDB\include\Geodatabase.h(307) : Warning 503: Can't wrap 'FileGDBAPI::CreateGeodatabase' unless renamed to a valid identifier.
FGDB\include\Geodatabase.h(308) : Warning 503: Can't wrap 'FileGDBAPI::OpenGeodatabase' unless renamed to a valid identifier.
FGDB\include\Geodatabase.h(309) : Warning 503: Can't wrap 'FileGDBAPI::CloseGeodatabase' unless renamed to a valid identifier.
FGDB\include\Geodatabase.h(310) : Warning 503: Can't wrap 'FileGDBAPI::DeleteGeodatabase' unless renamed to a valid identifier.

```

从 VS 2017 生成 .pyd 文件

这就是我卡住的地方。
我尝试创建一个新的 VS 项目来生成 DLL,但我似乎无法让界面正常工作(我发现 VS 工作室的界面有点令人生畏)。有没有办法在不创建项目的情况下通过命令行做到这一点?如果是这样,有人可以就我如何做到这一点提供一些指导吗?
我应该只需要 .i 和 .cxx 文件来编译代码。

更新 从 VS 2017 生成 .pyd 文件

14)。打开 Visual Studios

15)。选择文件 -> 从现有代码

16)。选择c++

17)。输入以下内容:

- Project file location: folder from step #8

- project name: filegdbapi

- Check add files (should be checked by default)

- Click Next

18)。对于项目类型:动态链接库(DLL)项目

19)。按完成

20)。构建项目

失败:

1>------ Build started: Project: filegdbapi, Configuration: Release x64 ------
1>XSD : error : The CodeDom provider type "Microsoft.VisualC.CppCodeProvider, CppCodeProvider, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" could not be located.
1>
1>If you would like more help, please type "xsd /?".
1>Done building project "filegdbapi.vcxproj" -- FAILED.

谢谢

【问题讨论】:

    标签: python c++ windows visual-studio


    【解决方案1】:

    这些库与您的 Visual Studio 版本不兼容

    【讨论】:

    • 你确定吗,上面写着VS2017
    • 我的意思是,使用您的确切版本,例如在旧的 14.1 MSVC 版本中,您无法使您的程序可移植,在这种情况下,库与编译器不兼容
    • 有没有办法弄清楚我需要什么来编译这个东西?
    • 我唯一能告诉你的就是将你的 Visual Studio 更新到最新版本
    猜你喜欢
    • 1970-01-01
    • 2018-04-28
    • 2018-06-02
    • 2011-08-05
    • 1970-01-01
    • 1970-01-01
    • 2019-11-25
    • 2018-03-03
    • 2023-03-08
    相关资源
    最近更新 更多