gpt4 book ai didi

objective-c - 在mac终端上编译Objective-C代码

转载 作者:行者123 更新时间:2023-12-02 04:11:55 25 4
gpt4 key购买 nike

我刚刚开始学习 Objective-C,我陷入了一个非常简单的问题。我编写了一个小程序,并尝试使用以下命令通过 Mac 终端编译它:

clang -framework Foundation main.m -o prog

它工作正常,直到我在 main.m 中编写以下代码

Calculator *calculator = [[Calculator alloc]initWithExpression:expressionArray];

它开始给我以下错误:

Undefined symbols for architecture x86_64:  "_OBJC_CLASS_$_Calculator", referenced from:      objc-class-ref in main-a39d3a.old: symbol(s) not found for architecture x86_64clang: error: linker command failed with exit code 1 (use -v to see invocation)

How to tell compiler to import calculator.h file although I have included the following line in main.m:

#import "Calculator.h"

最佳答案

如果源文件中有“Calculator.m”文件,则编译命令必须类似于

clang -framework Foundation Calculator.m main.m -o prog

关于objective-c - 在mac终端上编译Objective-C代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36230494/

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