我在这个特定文件的Stack Overflow上没有看到任何内容。我从http://www.ftdichip.com/Drivers/D2XX.htm为OS X 10.7下载并安装了FTDI serial-usb适配器的驱动程序。现在,我试图从名为" Simple"的文件夹中获取示例代码。在包含的样本内。我创建了一个新的XCODE(4.5)项目并导入了必要的项目。
我收到以下编译错误:
Ld / Users / availableimac / Library / Developer / Xcode / DerivedData / SerialTest-djxlngfrdsbhhdacorrnmcgxxdpc / Build / Products / Debug / SerialTest normal x86_64 cd / Users / availableimac / Documents / HardwareDev / SerialTest setenv MACOSX_DEPLOYMENT_TARGET 10.7 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10。 8.sdk -L / Users / availableimac / Library / Developer / Xcode / DerivedData / SerialTest-djxlngfrdsbhhdacorrnmcgxxdpc / Build / Products / Debug -F / Users / availableimac / Library / Developer / Xcode / DerivedData / SerialTest-djxlngfrdsbhhdacorrnmcgxxdpc / Build / Products / Debug -filelist /Users/availableimac/Library/Developer/Xcode/DerivedData/SerialTest-djxlngfrdsbhhdacorrnmcgxxdpc/Build/Intermediates/SerialTest.build/Debug/SerialTest.build/Objects-normal/x86_64/SerialTest.LinkFileList -mmacosx-version-min = 10.7 -o / Users / availableimac / Library / Developer / Xcode / DerivedData / SerialTest-djxlngfrdsbhhdacorrnmcgxxdpc / Build / Products / Debug / SerialTest
架构x86_64的未定义符号: " _FT_Close",引自: _main在main.o中 " _FT_GetQueueStatus",引自: _main在main.o中 " _FT_ListDevices",引自: _main在main.o中 " _FT_OpenEx",引自: _main在main.o中 " _FT_Read",引自: _main在main.o中 " _FT_SetBaudRate",引自: _main在main.o中 " _FT_Write",引自: _main在main.o中 ld:找不到架构x86_64的符号 clang:错误:链接器命令失败,退出代码为1(使用-v查看调用)
您可以在此处获取项目文件夹:https://drive.google.com/file/d/0B602Cy_Ktj0BdUVxZ3JrUVdpZlU/view?usp=sharing
makefile不是xCode项目的一部分。它是原始示例代码的一部分。我不知道如何解决这个问题。我很感激任何帮助!
main.c中:
/*
Simple example to open a maximum of 4 devices - write some data then read it back.
Shows one method of using list devices also.
Assumes the devices have a loopback connector on them and they also have a serial number
To build use the following gcc statement
(assuming you have the d2xx library in the /usr/local/lib directory).
gcc -o simple main.c -L. -lftd2xx -Wl,-rpath /usr/local/lib
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "ftd2xx.h"
#define BUF_SIZE 0x10
#define MAX_DEVICES 5
int iDevicesOpen;
static void dumpBuffer(unsigned char *buffer, int elements)
{
int j;
printf(" [");
for (j = 0; j < elements; j++)
{
if (j > 0)
printf(", ");
printf("0x%02X", (unsigned int)buffer[j]);
}
printf("]\n");
}
int main()
{
unsigned char cBufWrite[BUF_SIZE];
unsigned char * pcBufRead = NULL;
char * pcBufLD[MAX_DEVICES + 1];
char cBufLD[MAX_DEVICES][64];
DWORD dwRxSize = 0;
DWORD dwBytesWritten, dwBytesRead;
FT_STATUS ftStatus;
FT_HANDLE ftHandle[MAX_DEVICES];
int iNumDevs = 0;
int i, j;
for(i = 0; i < MAX_DEVICES; i++) {
pcBufLD[i] = cBufLD[i];
}
pcBufLD[MAX_DEVICES] = NULL;
ftStatus = FT_ListDevices(pcBufLD, &iNumDevs, FT_LIST_ALL | FT_OPEN_BY_SERIAL_NUMBER);
if(ftStatus != FT_OK) {
printf("Error: FT_ListDevices(%d)\n", (int)ftStatus);
return 1;
}
for(i = 0; ( (i <MAX_DEVICES) && (i < iNumDevs) ); i++) {
printf("Device %d Serial Number - %s\n", i, cBufLD[i]);
}
for(j = 0; j < BUF_SIZE; j++) {
cBufWrite[j] = j;
}
for(i = 0; ( (i <MAX_DEVICES) && (i < iNumDevs) ) ; i++) {
/* Setup */
if((ftStatus = FT_OpenEx(cBufLD[i], FT_OPEN_BY_SERIAL_NUMBER, &ftHandle[i])) != FT_OK){
/*
This can fail if the ftdi_sio driver is loaded
use lsmod to check this and rmmod ftdi_sio to remove
also rmmod usbserial
*/
printf("Error FT_OpenEx(%d), device %d\n", (int)ftStatus, i);
printf("Use lsmod to check if ftdi_sio (and usbserial) are present.\n");
printf("If so, unload them using rmmod, as they conflict with ftd2xx.\n");
return 1;
}
printf("Opened device %s\n", cBufLD[i]);
iDevicesOpen++;
if((ftStatus = FT_SetBaudRate(ftHandle[i], 9600)) != FT_OK) {
printf("Error FT_SetBaudRate(%d), cBufLD[i] = %s\n", (int)ftStatus, cBufLD[i]);
break;
}
printf("Calling FT_Write with this write-buffer:\n");
dumpBuffer(cBufWrite, BUF_SIZE);
/* Write */
ftStatus = FT_Write(ftHandle[i], cBufWrite, BUF_SIZE, &dwBytesWritten);
if (ftStatus != FT_OK) {
printf("Error FT_Write(%d)\n", (int)ftStatus);
break;
}
if (dwBytesWritten != (DWORD)BUF_SIZE) {
printf("FT_Write only wrote %d (of %d) bytes\n",
(int)dwBytesWritten,
BUF_SIZE);
break;
}
sleep(1);
/* Read */
dwRxSize = 0;
while ((dwRxSize < BUF_SIZE) && (ftStatus == FT_OK)) {
ftStatus = FT_GetQueueStatus(ftHandle[i], &dwRxSize);
}
if(ftStatus == FT_OK) {
pcBufRead = realloc(pcBufRead, dwRxSize);
memset(pcBufRead, 0xFF, dwRxSize);
printf("Calling FT_Read with this read-buffer:\n");
dumpBuffer(pcBufRead, dwRxSize);
ftStatus = FT_Read(ftHandle[i], pcBufRead, dwRxSize, &dwBytesRead);
if (ftStatus != FT_OK) {
printf("Error FT_Read(%d)\n", (int)ftStatus);
break;
}
if (dwBytesRead != dwRxSize) {
printf("FT_Read only read %d (of %d) bytes\n",
(int)dwBytesRead,
(int)dwRxSize);
break;
}
printf("FT_Read read %d bytes. Read-buffer is now:\n",
(int)dwBytesRead);
dumpBuffer(pcBufRead, (int)dwBytesRead);
if (0 != memcmp(cBufWrite, pcBufRead, BUF_SIZE)) {
printf("Error: read-buffer does not match write-buffer.\n");
break;
}
printf("%s test passed.\n", cBufLD[i]);
}
else {
printf("Error FT_GetQueueStatus(%d)\n", (int)ftStatus);
}
}
iDevicesOpen = i;
/* Cleanup */
for(i = 0; i < iDevicesOpen; i++) {
FT_Close(ftHandle[i]);
printf("Closed device %s\n", cBufLD[i]);
}
if(pcBufRead)
free(pcBufRead);
return 0;
}