找不到“算法"文件 [英] 'algorithm' file not found

查看:146
本文介绍了找不到“算法"文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用以下库在 Xcode 中创建一个简单的控制台应用程序:

I'm trying to do a simple console app in Xcode using the following library:

https://github.com/marstone/ingress-ios/树/主/s2-几何

我找到了库,但没有找到算法库.

I'm finding the library but its not finding the algorithm library.

示例代码

#import <Foundation/Foundation.h>

#import "S2Geometry.h"

#include "s2.h"
#include "s2cellid.h"
#include "s2latlng.h"
#include "s2latlngrect.h"
#include "s2regioncoverer.h"

int main(int argc, const char * argv[]) {

    @autoreleasepool {

        // insert code here...
        NSLog(@"Hello, World!");

        S2LatLngRect rect = S2LatLngRect(S2LatLng::FromDegrees(MIN(37.78272, 37.781719), MIN(-121.971427, -121.972007)), S2LatLng::FromDegrees(MAX(37.78272,
37.781719), MAX(-121.971427, -121.972007)));
    }
    return 0; }

我收到以下错误:

 ./s2-geometry/s2.h:6:10: fatal error: 'algorithm' file not found

推荐答案

s2-geometry 库是用 Objective-C++ 编写的,但您的示例代码使用的是 Objective-C 编译器.由于algorithm 是Objective-C 不可用的C++ 头文件,因此发生丢失文件的错误.

The s2-geometry library is written in Objective-C++, but your example code is using the Objective-C compiler. The error about the missing file occurred because algorithm is a C++ header that is unavailable to Objective-C.

如果您将示例文件的扩展名从 .m 更改为 .mm,您的代码将使用 Objective-C++ 编译器并且错误应该会消失.

If you change your example file's extension from .m, to .mm, your code will use the Objective-C++ compiler and the error should disappear.

请参阅此处,了解有关混合使用 Objective-C 和 Objective-C++ 的更多信息.

See here for more information on mixing Objective-C and Objective-C++.

这篇关于找不到“算法"文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆