Xcode 链接OpenSSL的LLVM 6错误
Xcode 6 GM及其LLVM 6给出了以下链接错误:Xcode 链接OpenSSL的LLVM 6错误,xcode,openssl,xcode6gm,Xcode,Openssl,Xcode6gm,Xcode 6 GM及其LLVM 6给出了以下链接错误: Undefined symbols for architecture i386: "_fopen$UNIX2003", referenced from: _BIO_new_file in libcrypto.a(bss_file.o) _file_ctrl in libcrypto.a(bss_file.o) _open_console in libcrypto.a(ui_openssl.o) "_fputs$UNIX2003
Undefined symbols for architecture i386:
"_fopen$UNIX2003", referenced from:
_BIO_new_file in libcrypto.a(bss_file.o)
_file_ctrl in libcrypto.a(bss_file.o)
_open_console in libcrypto.a(ui_openssl.o)
"_fputs$UNIX2003", referenced from:
_write_string in libcrypto.a(ui_openssl.o)
_read_string in libcrypto.a(ui_openssl.o)
"_fwrite$UNIX2003", referenced from:
_send_fp_chars in libcrypto.a(a_strex.o)
_write_fp in libcrypto.a(b_dump.o)
_file_write in libcrypto.a(bss_file.o)
_file_puts in libcrypto.a(bss_file.o)
"_strerror$UNIX2003", referenced from:
_ERR_load_ERR_strings in libcrypto.a(err.o)
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
现在,建议添加一个特别的.c
文件,对于上述情况,该文件将是:
#include <stdio.h>
#include <string.h>
FILE *fopen$UNIX2003( const char *filename, const char *mode )
{
return fopen(filename, mode);
}
size_t fwrite$UNIX2003( const void *a, size_t b, size_t c, FILE *d )
{
return fwrite(a, b, c, d);
}
void fputs$UNIX2003(const char *restrict c, FILE *restrict f)
{
fputs(c, f);
}
char *strerror$UNIX2003(int errnum)
{
return strerror(errnum);
}
#包括
#包括
文件*fopen$UNIX2003(常量字符*文件名,常量字符*模式)
{
返回fopen(文件名、模式);
}
大小写入$UNIX2003(常量无效*a、大小b、大小c、文件*d)
{
返回fwrite(a、b、c、d);
}
无效fputs$UNIX2003(常量字符*限制c,文件*限制f)
{
fputs(c,f);
}
字符*strerror$UNIX2003(int errnum)
{
返回strerror(errnum);
}
它“有效”,但这是最好的(甚至是可取的)方法吗?正如您所猜测的,不,这不是解决Xcode 6中LLVM链接器问题的可取方法。相反,假设您正在为iOS开发,您需要做的是为新的iOS 8 SDK重建OpenSSL。这将有助于您做到这一点。如果这可以节省任何人的时间,我发现可以解决此特定链接器问题(将此添加到任何cpp文件):
extern "C"{
size_t fwrite$UNIX2003( const void *a, size_t b, size_t c, FILE *d )
{
return fwrite(a, b, c, d);
}
char* strerror$UNIX2003( int errnum )
{
return strerror(errnum);
}
time_t mktime$UNIX2003(struct tm * a)
{
return mktime(a);
}
double strtod$UNIX2003(const char * a, char ** b) {
return strtod(a, b);
}
}