objective-c - 使用 C 库的架构 x86_64 的 undefined symbol

标签 objective-c c xcode macos

我遇到了很多链接器错误。我确保通过 macports 安装了我需要的所有库。我整理了所有包含错误,但现在还剩下很多链接器错误。

HEADER_SEARCH_PATHS =/opt/local/include/usr/include/opt/local/include/json LIBRARY_SEARCH_PATHS =/opt/local/lib/usr/local/lib

Build target PianoLounge

Ld /Users/jordan/Library/Developer/Xcode/DerivedData/PianoLounge-ajgojrzszrergafgvyuliphwxcpg/Build/Products/Debug/PianoLounge.app/Contents/MacOS/PianoLounge normal x86_64
    cd /Users/jordan/Projects/Cocoa/PianoLounge
    setenv MACOSX_DEPLOYMENT_TARGET 10.8
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk -L/Users/jordan/Library/Developer/Xcode/DerivedData/PianoLounge-ajgojrzszrergafgvyuliphwxcpg/Build/Products/Debug -L/opt/local/lib -L/usr/local/lib -F/Users/jordan/Library/Developer/Xcode/DerivedData/PianoLounge-ajgojrzszrergafgvyuliphwxcpg/Build/Products/Debug -filelist /Users/jordan/Library/Developer/Xcode/DerivedData/PianoLounge-ajgojrzszrergafgvyuliphwxcpg/Build/Intermediates/PianoLounge.build/Debug/PianoLounge.build/Objects-normal/x86_64/PianoLounge.LinkFileList -mmacosx-version-min=10.8 -fobjc-arc -fobjc-link-runtime -framework Cocoa -o /Users/jordan/Library/Developer/Xcode/DerivedData/PianoLounge-ajgojrzszrergafgvyuliphwxcpg/Build/Products/Debug/PianoLounge.app/Contents/MacOS/PianoLounge

Undefined symbols for architecture x86_64:
  "_gcry_cipher_close", referenced from:
      _PianoDestroyPartner in piano.o
  "_gcry_cipher_decrypt", referenced from:
      _PianoDecryptString in crypt.o
  "_gcry_cipher_encrypt", referenced from:
      _PianoEncryptString in crypt.o
  "_gcry_cipher_open", referenced from:
      _PianoInit in piano.o
  "_gcry_cipher_setkey", referenced from:
      _PianoInit in piano.o
  "_gnutls_bye", referenced from:
      _WaitressFetchCall in waitress.o
  "_gnutls_certificate_allocate_credentials", referenced from:
      _WaitressFetchCall in waitress.o
  "_gnutls_certificate_free_credentials", referenced from:
      _WaitressFetchCall in waitress.o
  "_gnutls_certificate_get_peers", referenced from:
      _WaitressTlsVerify in waitress.o
  "_gnutls_certificate_type_get", referenced from:
      _WaitressTlsVerify in waitress.o
  "_gnutls_credentials_set", referenced from:
      _WaitressFetchCall in waitress.o
  "_gnutls_deinit", referenced from:
      _WaitressFetchCall in waitress.o
  "_gnutls_handshake", referenced from:
      _WaitressConnect in waitress.o
  "_gnutls_init", referenced from:
      _WaitressFetchCall in waitress.o
  "_gnutls_record_recv", referenced from:
      _WaitressGnutlsRead in waitress.o
  "_gnutls_record_send", referenced from:
      _WaitressGnutlsWrite in waitress.o
  "_gnutls_set_default_priority", referenced from:
      _WaitressFetchCall in waitress.o
  "_gnutls_transport_set_ptr", referenced from:
      _WaitressFetchCall in waitress.o
  "_gnutls_transport_set_pull_function", referenced from:
      _WaitressFetchCall in waitress.o
  "_gnutls_transport_set_push_function", referenced from:
      _WaitressFetchCall in waitress.o
  "_gnutls_x509_crt_deinit", referenced from:
      _WaitressTlsVerify in waitress.o
  "_gnutls_x509_crt_get_fingerprint", referenced from:
      _WaitressTlsVerify in waitress.o
  "_gnutls_x509_crt_import", referenced from:
      _WaitressTlsVerify in waitress.o
  "_gnutls_x509_crt_init", referenced from:
      _WaitressTlsVerify in waitress.o
  "_json_object_array_add", referenced from:
      _PianoRequest in request.o
  "_json_object_array_get_idx", referenced from:
      _PianoResponse in response.o
  "_json_object_array_length", referenced from:
      _PianoResponse in response.o
  "_json_object_get_boolean", referenced from:
      _PianoResponse in response.o
      _PianoJsonParseStation in response.o
  "_json_object_get_double", referenced from:
      _PianoResponse in response.o
  "_json_object_get_int", referenced from:
      _PianoResponse in response.o
  "_json_object_get_object", referenced from:
      _PianoResponse in response.o
  "_json_object_get_string", referenced from:
      _PianoResponse in response.o
      _PianoJsonStrdup in response.o
  "_json_object_new_array", referenced from:
      _PianoRequest in request.o
  "_json_object_new_boolean", referenced from:
      _PianoRequest in request.o
  "_json_object_new_int", referenced from:
      _PianoRequest in request.o
  "_json_object_new_object", referenced from:
      _PianoRequest in request.o
  "_json_object_new_string", referenced from:
      _PianoRequest in request.o
  "_json_object_object_add", referenced from:
      _PianoRequest in request.o
  "_json_object_object_get", referenced from:
      _PianoResponse in response.o
      _PianoJsonStrdup in response.o
      _PianoJsonParseStation in response.o
  "_json_object_put", referenced from:
      _PianoRequest in request.o
      _PianoResponse in response.o
  "_json_object_to_json_string", referenced from:
      _PianoRequest in request.o
  "_json_tokener_parse", referenced from:
      _PianoResponse in response.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

最佳答案

看起来您缺少链接所需的库 gnutls、gcrypt 和 json。除非你告诉 Xcode 要链接哪些库,否则它不会有任何想法。它看起来像这样:

-lgnutls -lgcrypt -ljson

(这是一个例子,我不确定具体需要哪些库)。

您需要将它们添加为额外的库以链接到您的 Xcode 项目中。

关于objective-c - 使用 C 库的架构 x86_64 的 undefined symbol ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12717942/

相关文章:

ios - 如何在 iOS 的 UITableView 中显示可点击的 WordPress 博客文章标题?

ios - 在 map 上移动合法按钮 (iOS 6)

objective-c - 在Xcode中查看facebook用户的ProfilePicture

objective-c - 通过 UISplitViewController 的 iOS 7 导航栏显示褪色的灰色 View

objective-c - __weak typeof(self)weakSelf = self或__weak MyObject * weakSelf = self?

c - C 中的字符串解析

检查数组中的某个字符是否是某个字符

ios - Swift 中的“使用未解析的标识符”

swift - Inception V3 CoreML 输出标签翻译语言

c - 给定 char *p = "string",为什么修改会导致未定义的行为?