views:

85

answers:

2

I am trying to link libssh2.dylib (a 3rd party library compiled by Matthew Wilkinson using libssh2 library from http://www.libssh2.org) to my xcode project but when I try the following code:

const char * libssh2_version(int required_version);

printf("libssh2 version: %s", libssh2_version(0) );

Heres the error I get:

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

I get this error when I try any libssh2 API. Anybody have any clue to whats the problem? These are the files I've linked to the project:

// 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>

I have also linked the libssh2.dylib file to the frameworks and added a recursive path to "Search Header Files" on Build Tab to the files libssh2.a, libgcrypt.a, libgpg-error.a.

Please help.

+2  A: 

They are completely different CPU architectures. If you are trying to use a precompiled library targeted to one then you cannot use it on the other, you need to find a precompiled library targeted to the platform you want - armv6 for iPhone, i386 for Mac.

Since you tagged iPhone you might have the right library but have your project settings screwed up - make sure Base SDK is set correctly (4.1 at time of writing). Once this is correct it will probably not present you with the i386 target option at all, and will default to "armv6 armv7" as soon as you select 4.1 SDK.

Adam Eberbach
I am trying to run it on the iPhone Simulator at the time. I guess it won't work on the simulator so maybe I should try it on the device huh?
iiyanx7
No, you build for the simulator as if it were a real device - arm, not i386.
Adam Eberbach
A: 

It looks like the library's built for armv6 (to run on the device) and you're trying to link it into an i386 app (to run on the simulator). This obviously isn't going to work.

tc.