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", 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);
}
它“有效”,但这是最好的(甚至是可取的)方法吗?