什么是armv6和i386之间的区别?

时间:2010-09-24 22:33:58

标签: iphone arm cpu-architecture i386 libssh

我正在尝试将libssh2.dylib(由Matthew Wilkinson编译的第三方库,使用来自http://www.libssh2.org的libssh2库)链接到我的xcode项目,但是当我尝试以下代码时:

const char * libssh2_version(int required_version);
printf("libssh2 version: %s", libssh2_version(0));

这是我得到的错误:

ld: warning: in /iaN's Work/Developer/Apple/iPhone/apps/PortScanner/libssh2.1.dylib,    file was built for armv6 which is not the architecture being linked (i386)
Undefined symbols:
"_libssh2_version", referenced from:
-[Request connect] in Request.o
ld: symbol(s) not found
collect2: ld returned 1 exit status

我在尝试任何libssh2 API时遇到此错误。任何人都有任何线索来解决这个问题?这些是我链接到项目的文件:

// SSH Librarys 
#include "libssh2_config.h"
#include "libssh2.h"
#include "libssh2_sftp.h"

#ifdef HAVE_WINDOWS_H
#include <windows.h>
#endif
#ifdef HAVE_WINSOCK2_H
#include <winsock2.h>
#endif

#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
# ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif

#include <sys/types.h>
#include <fcntl.h>
#include <errno.h>
#include <stdio.h>
#include <ctype.h>

我还将libssh2.dylib文件链接到框架,并在Build选项卡上将“Search Header Files”的递归路径添加到文件libssh2.a,libgcrypt.a,libgpg-error.a。

2 个答案:

答案 0 :(得分:3)

它们是完全不同的CPU架构。如果你试图使用一个预编译的库,那么你就不能在另一个上使用它,你需要找到一个针对你想要的平台的预编译库 - armv6 for iPhone,i386 for Mac。

由于您标记了iPhone,因此您可能拥有正确的库但却搞砸了您的项目设置 - 请确保正确设置Base SDK(在撰写本文时为4.1)。一旦这是正确的,它可能根本不会向您显示i386目标选项,并且一旦您选择4.1 SDK,它将默认为“armv6 armv7”。

答案 1 :(得分:0)

看起来这个库是为armv6构建的(在设备上运行),你试图将它链接到i386应用程序(在模拟器上运行)。这显然不起作用。