Eri*_*tto 3 compiler-construction command-line compilation objective-c
我正在尝试从命令行创建和编译一个简单的Objective-C程序.这是代码:
audio.h
#import <Foundation/Foundation.h>
#include <stdlib.h>
#import "WavReader.h"
int main (int argc, const char *argv[])
{
// LOG ARGUMENTS
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSLog (@"Running....");
NSArray *args = [[NSProcessInfo processInfo] arguments];
NSLog(@"Input File %@.", [args objectAtIndex:1]);
NSLog(@"Output File Name %@.", [args objectAtIndex:2]);
WavReader *wavReader = [[WavReader alloc] init];
[wavReader testPrint];
[pool drain];
return 0;
}
Run Code Online (Sandbox Code Playgroud)
WavReader.h
#import <Foundation/Foundation.h>
@interface WavReader : NSObject {
}
- (void) testPrint;
@end
Run Code Online (Sandbox Code Playgroud)
WavReader.m
#import "WavReader.h"
@implementation WavReader
- (void) testPrint
{
NSLog(@"Test print...");
}
@end
Run Code Online (Sandbox Code Playgroud)
然后我尝试用它编译它
gcc -framework Foundation audio.m -o audio
我收到以下错误:
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_WavReader", referenced from:
objc-class-ref in ccs07gwo.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
Run Code Online (Sandbox Code Playgroud)
我该如何编译?
您需要编译WavReader还
gcc -framework Foundation audio.m WavReader.m -o audio
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
320 次 |
| 最近记录: |