构建mongo-swift-driver时如何解决“错误:使用无法解析的标识符”

时间:2019-07-09 00:11:51

标签: c swift mongodb bson

我正在尝试从我的Swift应用程序连接到MongoDB(实际上使用的是Vapor MongoDB library,但这似乎不是问题的根源)。一切在我的MacBook上都可以正常运行,但是当我尝试在生产环境中构建mongo-swift-driver时,无法通过多次使用未解析的标识符“ X”来构建。注意:你的意思是?错误。

我正在Ubuntu 18.04服务器(在Heroku上运行的VM)上运行Swift 5.0.1。该软件包无法构建,称为MongoSwift,我尝试在Ubuntu 16.04服务器上安装该软件包,但是即使安装了libmongoc,该软件包也无法使用libmongoc.h:1:10: error: 'mongoc.h' file not found进行构建。我想知道它是否拉错了libmongoc-devlibbson-dev的版本,因此Swift库正在尝试使用在版本之间删除的函数。但是,我不确定如何确定该问题,或者不确定如何安装正确的版本。我认为我的MacBook运行的是1.13.0版,但它可能使用的是mongo-c-driver而不是libmongoc,因为它是Mac,而不是Ubuntu。

libbson-dev
libmongoc-dev

是我正在使用apt-get安装的2个软件包(我自己没有运行apt-get是因为我无法修改VM,但是我正在使用this buildpack来安装它们构建应用程序。)

构建输出为

/tmp/build_32195d602f07b06986e284c8bb971238/.apt/usr/include/libbson-1.0/bson-version.h:63:26: error: invalid suffix '.2' on floating constant
#define BSON_VERSION (1.9.2)
                         ^
/tmp/build_32195d602f07b06986e284c8bb971238/.build/checkouts/mongo-swift-driver/Sources/MongoSwift/BSON/Overwritable.swift:68:58: error: use of unresolved identifier 'bson_iter_overwrite_oid'; did you mean 'bson_iter_overwrite_bool'?
            iter.withMutableBSONIterPointer { iterPtr in bson_iter_overwrite_oid(iterPtr, oidPtr) }
                                                         ^~~~~~~~~~~~~~~~~~~~~~~
                                                         bson_iter_overwrite_bool
bson.bson_iter_overwrite_bool:1:13: note: 'bson_iter_overwrite_bool' declared here
public func bson_iter_overwrite_bool(_ iter: OpaquePointer!, _ value: Bool)
            ^
/tmp/build_32195d602f07b06986e284c8bb971238/.build/checkouts/mongo-swift-driver/Sources/MongoSwift/BSON/Overwritable.swift:76:13: error: use of unresolved identifier 'bson_iter_overwrite_timestamp'
            bson_iter_overwrite_timestamp(iterPtr, self.timestamp, self.increment)
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bson.bson_iter_overwrite_int32:1:13: note: did you mean 'bson_iter_overwrite_int32'?
public func bson_iter_overwrite_int32(_ iter: OpaquePointer!, _ value: Int32)
            ^
bson.bson_iter_overwrite_int64:1:13: note: did you mean 'bson_iter_overwrite_int64'?
public func bson_iter_overwrite_int64(_ iter: OpaquePointer!, _ value: Int64)
            ^
/tmp/build_32195d602f07b06986e284c8bb971238/.build/checkouts/mongo-swift-driver/Sources/MongoSwift/BSON/Overwritable.swift:84:13: error: use of unresolved identifier 'bson_iter_overwrite_date_time'; did you mean 'bson_iter_overwrite_double'?
            bson_iter_overwrite_date_time(iterPtr, self.msSinceEpoch)
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            bson_iter_overwrite_double
bson.bson_iter_overwrite_double:1:13: note: 'bson_iter_overwrite_double' declared here
public func bson_iter_overwrite_double(_ iter: OpaquePointer!, _ value: Double)

具体来说,找不到bson_iter_overwrite_oidbson_iter_overwrite_timestampbson_iter_overwrite_date_time函数。我检查了我的本地副本,并且肯定会调用这些函数,但是它们似乎存在于底层C库中,因此在我的MacBook上不会出错。

0 个答案:

没有答案