我试图将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文件链接到框架,并在“构建”选项卡上将“搜索头文件”的递归路径添加到文件libssh2.a,libgcrypt.a,libgpg-error.a。

最佳答案

它们是完全不同的CPU体系结构。如果您尝试使用针对一个平台的预编译库,那么就不能在另一个平台上使用它,则需要查找针对您想要的平台的预编译库-iPhone的armv6,Mac的i386。

由于标记了iPhone,因此您可能拥有正确的库,但搞错了项目设置-确保正确设置了Base SDK(在编写本文时为4.1)。一旦正确,它可能根本不会为您提供i386 target选项,并且在选择4.1 SDK后将默认为“ armv6 armv7”。

关于iphone - armv6和i386有什么区别?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/3791498/

10-11 18:20