我最近將文件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()'(注意缺少下劃線)。那是故意的嗎? – user1118321 2012-08-04 00:40:33