3

我刚刚根据教程 ( http://www.switchonthecode.com/tutorials/using-core-plot-in-an-iphone-application ) 在我的应用程序中添加了一个 Core Plot 视图。我已将 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 中的literal-pointer@__OBJC@__cls_refs@CPPlotRange

“_CPDecimalFromFloat”,引用自: -[HistogramWindowController windowDidLoad] in HistogramWindowController.o -[HistogramWindowController windowDidLoad] in HistogramWindowController.o -[HistogramWindowController windowDidLoad] in HistogramWindowController.o -[HistogramWindowController windowDidLoad] in HistogramWindowController.o

“.objc_class_name_CPLineStyle”,引用自:HistogramWindowController.o 中的literal-pointer@__OBJC@__cls_refs@CPLineStyle

“.objc_class_name_CPXYGraph”,引用自:HistogramWindowController.o 中的literal-pointer@__OBJC@__cls_refs@CPXYGraph

“.objc_class_name_CPScatterPlot”,引用自:HistogramWindowController.o 中的literal-pointer@__OBJC@__cls_refs@CPScatterPlot

“.objc_class_name_CPPlotSymbol”,引用自:HistogramWindowController.o 中的literal-pointer@__OBJC@__cls_refs@CPPlotSymbol

“.objc_class_name_CPColor”,引用自:HistogramWindowController.o 中的literal-pointer@__OBJC@__cls_refs@CPColor

“.objc_class_name_CPFill”,引用自:HistogramWindowController.o 中的literal-pointer@__OBJC@__cls_refs@CPFill

ld:未找到符号 collect2:ld 返回 1 个退出状态

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

干杯

4

5 回答 5

3

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

于 2009-09-04T05:05:06.097 回答
1

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

于 2009-09-06T18:06:58.900 回答
1

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.

于 2011-03-21T01:05:48.297 回答
0

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

于 2009-09-04T08:12:15.253 回答
0

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

于 2011-06-07T18:39:00.730 回答