gpt4 book ai didi

c++ - 未找到架构 i386 的 Objective-C 和 C++ 符号

转载 作者:搜寻专家 更新时间:2023-10-31 01:04:48 25 4
gpt4 key购买 nike

<分区>

我有 Objective-C 函数和 C++ 文件,我将其重命名为 .mm 并连接到我的项目,我需要在 C++ 文件中使用 Objective-C 函数,但 Xcode 给了我:

Undefined symbols for architecture i386: "maxRadiusFinder(double*, int, int)", referenced from: Fun(int, double, double*, double*, int, double (*) [2], int, int) in RALG.o

我的代码 Objective-C 代码:

 double maxRadiusFinder(double* algoPoints1,int count,int numberC)
{
NSMutableArray* algoPoints=[[NSMutableArray alloc] init];
for (int i=0; i<count; i++) {
Points *temp=[[Points alloc] init];
[temp setXCor:algoPoints1[i]];
[temp setYCor:algoPoints1[i+count]];
[algoPoints addObject:temp];

}
int howMany = (kDefaultGraphWidth - kOffsetX) / kStepX;
int howManyHorizontal = (kGraphBottom - kGraphTop - kOffsetY) / kStepY;
NSMutableArray *distancesKCover=[[NSMutableArray alloc]init];
for (NSUInteger j=0; j<=howManyHorizontal; j++) {
for (NSUInteger i=0; i<=howMany; i++) {
Points *temp=[[Points alloc] init];
[temp setXCor:i*kStepX];
[temp setYCor:j*kStepY];
NSMutableArray *distances=[[NSMutableArray alloc]init];
for(NSUInteger i1=0;i<[algoPoints count];i++)
{
float temp1=MAX(fabsf([[algoPoints objectAtIndex:i1] xCor]-[temp xCor]),fabsf([[algoPoints objectAtIndex:i1] yCor]-[temp yCor]));
[distances addObject:[NSNumber numberWithFloat:temp1]];
}
NSArray *sortedDistances=[distances sortedArrayUsingSelector:@selector(compare:)];
[distancesKCover addObject:[sortedDistances objectAtIndex:numberC]];
}
}
double max = [[distancesKCover valueForKeyPath:@"@max.doubleValue"] doubleValue];
return max;
}

并且在 .mm 文件中对该函数的 C++ 调用:

  rd += maxRadiusFinder(g, 10, 10);

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com