Xcode编译错误 - 架构armv7找不到ld:symbol(s)
问题描述:
我最近将文件Serial.c
和Serial.h
添加到我的Xcode项目中。Xcode编译错误 - 架构armv7找不到ld:symbol(s)
为Serial.c
的代码如下,
#include <stdio.h> /* Standard input/output definitions */
#include <stdlib.h>
#include <string.h> /* String function definitions */
#include <unistd.h> /* UNIX standard function definitions */
#include <fcntl.h> /* File control definitions */
#include <errno.h> /* Error number definitions */
#include <termios.h> /* POSIX terminal control definitions */
/*
* 'open_port()' - Open serial port on dock connector pins 13RX/12TX
*
* Returns the file descriptor on success or -1 on error.
*/
int open_port(void)
{
int fd = -1; /* File descriptor for the port */
struct termios options;
fd = open("/dev/tty.iap", O_RDWR | O_NOCTTY | O_NDELAY); // O_NOCTTY - don't be controlling terminal, O_NODELAY don't care about DCD signal state
if (fd == -1)
{
// couldn't open the port
perror("open_port: Unable to open /dev/tty.iap - ");
}
else
fcntl(fd, F_SETFL, 0);
tcgetattr(fd, &options); // get current options for the port
// set the baud rate
cfsetispeed(&options, B2400);
cfsetospeed(&options, B2400);
// enable the receiver and set local mode
options.c_cflag |= (CLOCAL | CREAD);
// set the new options for the port
tcsetattr(fd, TCSANOW, &options);
return (fd);
}
的serial.h
文件,
NSInteger openPort();
我试图让串行RX数据流从iPhone输出成NSLog语句。
我呼吁在ViewControllerSerialConsole.m
文件
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
#if !TARGET_IPHONE_SIMULATOR
NSInteger serial = openPort();
NSLog(@"The serial data is %d",serial);
//_serialView.text = serial;
#endif
}
程序编译罚款的iPhone模拟器,但在iPhone上没有编译OpenPort
功能。
我得到以下的错误消息,
为架构的ARMv7未定义符号: “_openPort”,从引用: - [ViewControllerSerialConsole viewDidLoad中]在ViewControllerSerialConsole.o LD:符号(多个)未找到架构ARMv7的 铛:错误:连接命令,退出代码1失败(使用-v看到调用)
LD:符号(S)未找到的ARMv7架构
上troubleshooti任何帮助这个问题将不胜感激。
答
你的应用程序编译好的模拟器,因为你不是指缺少的“open_port
”或“openPort
”符号**。
在您的Xcode项目中,在文件列表中(沿着工作区的左边缘)选择您的“Serial.m
”文件,并查看该文件的文件检查器。
确保复选框ON在“目标会员”的设置项目。
**,而我们关于这个问题,是你的函数你Serial.m & Serial.h文件之间的正确命名?我在其中一个看到“open_port
”,而在另一个看到“openPort
”。
在上面的代码中,您有一个名为'open_port()'的函数,但在调用代码中,您调用'openPort()'(注意缺少下划线)。那是故意的吗? – user1118321 2012-08-04 00:40:33