【问题标题】:Xcode5: link aws4c libraryXcode5:链接 aws4c 库
【发布时间】:2023-03-27 19:35:01
【问题描述】:

我在 Xcode 中有 C++ 项目

我想在其中使用 C 库 aws4c https://code.google.com/p/aws4c/

这是我的 apn.cpp 文件:

#include "aws4c.h"

...

int main(int argc, char *argv[])
{

     aws_init(); 

     ...
}

在 Xcode 中看起来不错,但是当我尝试构建时 - 出现错误

Undefined symbols for architecture x86_64:
  "aws_init()", referenced from:
      _main in apn.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

在 Xcode5 中将 C 库链接到 C++ 项目的正确方法是什么?

【问题讨论】:

    标签: c++ c xcode xcode5 aws4c


    【解决方案1】:

    解决了这个问题

    添加

    #ifdef __cplusplus
    extern "C" {
    #endif
    

    #ifdef __cplusplus
    }
    #endif
    

    到 aws4c.h 文件,它可以工作

    【讨论】:

    • 如果我使用linux呢?我已经试过了,但它仍然给我这个错误
    • 这也适用于 Linux。我为 Linux 编译了我的最终应用程序
    猜你喜欢
    • 2014-02-04
    • 2014-08-12
    • 1970-01-01
    • 1970-01-01
    • 2014-07-31
    • 1970-01-01
    • 2011-09-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多