构建期间与 Core Plot 链接时出错

发布于 2024-08-03 18:52:22 字数 3373 浏览 5 评论 0原文

我刚刚根据教程(http://www.switchonthecode.com/tutorials/using-core-plot-in-an-iphone-application)。我已将 Core Plot 绘图代码放入包含 CPLayerHostingView 的窗口的窗口控制器的 windowDidLoad 方法中。该图的代码是:

CPXYPlotSpace *plotSpace = (CPXYPlotSpace *)graph.defaultPlotSpace;
plotSpace.xRange = [CPPlotRange plotRangeWithLocation:CPDecimalFromFloat(-6) 
                                               length:CPDecimalFromFloat(12)];
plotSpace.yRange = [CPPlotRange plotRangeWithLocation:CPDecimalFromFloat(-5) 
                                               length:CPDecimalFromFloat(30)];

CPXYAxisSet *axisSet = (CPXYAxisSet *)graph.axisSet;

CPLineStyle *lineStyle = [CPLineStyle lineStyle];
lineStyle.lineColor = [CPColor blackColor];
lineStyle.lineWidth = 2.0f;

axisSet.xAxis.majorIntervalLength = [[NSDecimalNumber decimalNumberWithString:@"5"] decimalValue];  
axisSet.xAxis.minorTicksPerInterval = 4;
axisSet.xAxis.minorTicksPerInterval = 4;
axisSet.xAxis.majorTickLineStyle = lineStyle;
axisSet.xAxis.minorTickLineStyle = lineStyle;
axisSet.xAxis.axisLineStyle = lineStyle;
axisSet.xAxis.minorTickLength = 5.0f;
axisSet.xAxis.majorTickLength = 7.0f;
axisSet.xAxis.axisLabelOffset = 3.0f;

axisSet.yAxis.majorIntervalLength = [[NSDecimalNumber decimalNumberWithString:@"5"] decimalValue];  
axisSet.yAxis.minorTicksPerInterval = 4;
axisSet.yAxis.minorTicksPerInterval = 4;
axisSet.yAxis.majorTickLineStyle = lineStyle;
axisSet.yAxis.minorTickLineStyle = lineStyle;
axisSet.yAxis.axisLineStyle = lineStyle;
axisSet.yAxis.minorTickLength = 5.0f;
axisSet.yAxis.majorTickLength = 7.0f;
axisSet.yAxis.axisLabelOffset = 3.0f;

CPScatterPlot *xSquaredPlot = [[[CPScatterPlot alloc] 
                                initWithFrame:graph.defaultPlotSpace.bounds] autorelease];
xSquaredPlot.identifier = @"X Squared Plot";
xSquaredPlot.dataLineStyle.lineWidth = 1.0f;
xSquaredPlot.dataLineStyle.lineColor = [CPColor redColor];
xSquaredPlot.dataSource = self;
[graph addPlot:xSquaredPlot];

当我构建时,出现以下错误:

“.objc_class_name_CPPlotRange”,引用自: HistogramWindowController.o“_CPDecimalFromFloat”中的文字指针@__OBJC@__cls_refs@CPPlotRange

,引用自: -HistogramWindowController.o 中的[HistogramWindowController windowDidLoad] -HistogramWindowController.o 中的[HistogramWindowController windowDidLoad] -HistogramWindowController.o 中的[HistogramWindowController windowDidLoad] -HistogramWindowController.o“.objc_class_name_CPLineStyle”中的[HistogramWindowController windowDidLoad]

,引用自: HistogramWindowController.o“.objc_class_name_CPXYGraph”中的文字指针@__OBJC@__cls_refs@CPLineStyle

,引用自: HistogramWindowController.o“.objc_class_name_CPScatterPlot”中的文字指针@__OBJC@__cls_refs@CPXYGraph

,引用自: HistogramWindowController.o“.objc_class_name_CPPlotSymbol”中的文字指针@__OBJC@__cls_refs@CPScatterPlot

,引用自: HistogramWindowController.o“.objc_class_name_CPColor”中的文字指针@__OBJC@__cls_refs@CPPlotSymbol

,引用自: HistogramWindowController.o“.objc_class_name_CPFill”中的文字指针@__OBJC@__cls_refs@CPColor

,引用自: HistogramWindowController.o ld 中的文字指针@__OBJC@__cls_refs@CPFill

:未找到符号 collect2: ld returned 1 exit status

我从来没有遇到过这样的错误。任何人都可以阐明问题可能是什么吗?

干杯

I have just added a Core Plot view to my application based on a tutorial (http://www.switchonthecode.com/tutorials/using-core-plot-in-an-iphone-application). I have put the Core Plot drawing code in the windowDidLoad method of the window controller for the window where I have included the CPLayerHostingView. The code for the plot is:

CPXYPlotSpace *plotSpace = (CPXYPlotSpace *)graph.defaultPlotSpace;
plotSpace.xRange = [CPPlotRange plotRangeWithLocation:CPDecimalFromFloat(-6) 
                                               length:CPDecimalFromFloat(12)];
plotSpace.yRange = [CPPlotRange plotRangeWithLocation:CPDecimalFromFloat(-5) 
                                               length:CPDecimalFromFloat(30)];

CPXYAxisSet *axisSet = (CPXYAxisSet *)graph.axisSet;

CPLineStyle *lineStyle = [CPLineStyle lineStyle];
lineStyle.lineColor = [CPColor blackColor];
lineStyle.lineWidth = 2.0f;

axisSet.xAxis.majorIntervalLength = [[NSDecimalNumber decimalNumberWithString:@"5"] decimalValue];  
axisSet.xAxis.minorTicksPerInterval = 4;
axisSet.xAxis.minorTicksPerInterval = 4;
axisSet.xAxis.majorTickLineStyle = lineStyle;
axisSet.xAxis.minorTickLineStyle = lineStyle;
axisSet.xAxis.axisLineStyle = lineStyle;
axisSet.xAxis.minorTickLength = 5.0f;
axisSet.xAxis.majorTickLength = 7.0f;
axisSet.xAxis.axisLabelOffset = 3.0f;

axisSet.yAxis.majorIntervalLength = [[NSDecimalNumber decimalNumberWithString:@"5"] decimalValue];  
axisSet.yAxis.minorTicksPerInterval = 4;
axisSet.yAxis.minorTicksPerInterval = 4;
axisSet.yAxis.majorTickLineStyle = lineStyle;
axisSet.yAxis.minorTickLineStyle = lineStyle;
axisSet.yAxis.axisLineStyle = lineStyle;
axisSet.yAxis.minorTickLength = 5.0f;
axisSet.yAxis.majorTickLength = 7.0f;
axisSet.yAxis.axisLabelOffset = 3.0f;

CPScatterPlot *xSquaredPlot = [[[CPScatterPlot alloc] 
                                initWithFrame:graph.defaultPlotSpace.bounds] autorelease];
xSquaredPlot.identifier = @"X Squared Plot";
xSquaredPlot.dataLineStyle.lineWidth = 1.0f;
xSquaredPlot.dataLineStyle.lineColor = [CPColor redColor];
xSquaredPlot.dataSource = self;
[graph addPlot:xSquaredPlot];

When I build I get the following errors:

".objc_class_name_CPPlotRange", referenced from:
literal-pointer@__OBJC@__cls_refs@CPPlotRange in HistogramWindowController.o

"_CPDecimalFromFloat", referenced from:
-[HistogramWindowController windowDidLoad] in HistogramWindowController.o
-[HistogramWindowController windowDidLoad] in HistogramWindowController.o
-[HistogramWindowController windowDidLoad] in HistogramWindowController.o
-[HistogramWindowController windowDidLoad] in HistogramWindowController.o

".objc_class_name_CPLineStyle", referenced from:
literal-pointer@__OBJC@__cls_refs@CPLineStyle in HistogramWindowController.o

".objc_class_name_CPXYGraph", referenced from:
literal-pointer@__OBJC@__cls_refs@CPXYGraph in HistogramWindowController.o

".objc_class_name_CPScatterPlot", referenced from:
literal-pointer@__OBJC@__cls_refs@CPScatterPlot in HistogramWindowController.o

".objc_class_name_CPPlotSymbol", referenced from:
literal-pointer@__OBJC@__cls_refs@CPPlotSymbol in HistogramWindowController.o

".objc_class_name_CPColor", referenced from:
literal-pointer@__OBJC@__cls_refs@CPColor in HistogramWindowController.o

".objc_class_name_CPFill", referenced from:
literal-pointer@__OBJC@__cls_refs@CPFill in HistogramWindowController.o

ld: symbol(s) not found
collect2: ld returned 1 exit status

I've never encountered an error like this. Can anyone shed any light on what the problem might be?

Cheers

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

欲拥i 2024-08-10 18:52:22

这意味着您没有正确链接到框架中。您可能刚刚将框架添加到项目中,#import编辑了标头,但忘记确保框架实际上已链接到您的目标。

It means you haven't linked in the framework correctly. You've probably just added the framework to your project, #imported the header, but forgot to make sure that the framework is actually getting linked into your target.

在风中等你 2024-08-10 18:52:22

此 Wiki 页面上提供了一些有关将该框架合并到 Mac 中的说明项目。如果遵循这些,您应该能够避免框架中链接的任何问题。

There are some instructions on this wiki page for incorporating the framework into Mac projects. If you follow those, you should be able to avoid any problems with linking in the framework.

_蜘蛛 2024-08-10 18:52:22

我遇到了完全相同的链接错误。对我来说,问题是我试图在模拟器中运行我的应用程序。我不知道我是否错过了某些地方,但我只能在设备上运行。一旦我开始这样做,就没有链接错误。

I experienced the exact same link errors. For me, the problem was I was trying to run my application in the simulator. I don't know if I missed something somewhere, but I could only run on a device. Once I started to do that, no link errors.

﹉夏雨初晴づ 2024-08-10 18:52:22

您还可以检查您的应用程序目标是否设置为包含 64 位支持以及框架是否具有此类支持(使用 file(1) 命令用于后一部分)。如果您正在构建支持 64 位的应用程序,但尝试链接到不支持 64 位的框架,则链接器在尝试链接应用程序的 64 位部分时将抛出类似的错误,而 32 位部分将会成功。

You might also check whether your application target is set to include 64-bit support and whether the framework has such support (use the file(1) command for the latter part). If you're building your app with 64-bit support, but try to link against a framework that doesn't have 64-bit support, the linker will throw errors like that when it tries to link the 64-bit portion of your app, while the 32-bit portions will succeed.

荭秂 2024-08-10 18:52:22

确保您还添加了 QuarzCore 框架。这修复了我的链接错误。

Make sure you add the QuarzCore framework as well. This fixed my linking errors.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文