aliyun / aliyun-oss-cpp-sdk

Aliyun OSS SDK for C++
Other
184 stars 88 forks source link

Mac编译时,遇到Undefined symbol: typeinfo for AlibabaCloud::OSS::OssObjectRequest #66

Closed dataonfirecn closed 4 years ago

dataonfirecn commented 4 years ago

在Mac 10.15 catalina,使用OpenlSSL 1.0.2p打包静态库libalibabacloud-oss-cpp-sdk.a(15.7M)

其中有个方法: bool OSSdeleteObject(const std::string& accessKeyId, const std::string& accessKeySecret, const std::string& endpoint, const std::string& bucketName, const std::string& objName) { std::string ObjectName = objName;

InitializeSdk();

ClientConfiguration conf;
OssClient client(endpoint, accessKeyId, accessKeySecret, conf);

DeleteObjectRequest request(bucketName, ObjectName);

auto outcome = client.DeleteObject(request);

if (!outcome.isSuccess()) {
    std::cout << "DeleteObject fail" <<
        ",code:" << outcome.error().Code() <<
        ",message:" << outcome.error().Message() <<
        ",requestId:" << outcome.error().RequestId() << std::endl;
    ShutdownSdk();
    return false;
}

ShutdownSdk();
return true;

}

在编译案例时(已导入libcrypto.a, libcurl.a, libssl.a),遇到linker错误: Undefined symbols for architecture x86_64: "typeinfo for AlibabaCloud::OSS::OssObjectRequest", referenced from: typeinfo for AlibabaCloud::OSS::DeleteObjectRequest in YEEOss.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

注释掉删除Object方法中的: DeleteObjectRequest request(bucketName, ObjectName);

编辑正常,upload,download功能都没问题。

请教是在哪个环节可能出现错误?谢谢

huiguangjun commented 4 years ago

和 RTTI 的编译选项有关系, 当前版本 默认关闭 rtti ,即构建时增加了 -fno-rtti 选项,所以你的代码编译时,也需要加上 -fno-rtti 。

之后的版本会增加一个 CMake 选项, ENABLE_RTTI, 默认为 ON ,业务方可以根据需求设置。

rongliangtang commented 1 year ago

在Mac 10.15 catalina,使用OpenlSSL 1.0.2p打包静态库libalibabacloud-oss-cpp-sdk.a(15.7M)

其中有个方法: bool OSSdeleteObject(const std::string& accessKeyId, const std::string& accessKeySecret, const std::string& endpoint, const std::string& bucketName, const std::string& objName) { std::string ObjectName = objName;

InitializeSdk();

ClientConfiguration conf;
OssClient client(endpoint, accessKeyId, accessKeySecret, conf);

DeleteObjectRequest request(bucketName, ObjectName);

auto outcome = client.DeleteObject(request);

if (!outcome.isSuccess()) {
  std::cout << "DeleteObject fail" <<
      ",code:" << outcome.error().Code() <<
      ",message:" << outcome.error().Message() <<
      ",requestId:" << outcome.error().RequestId() << std::endl;
  ShutdownSdk();
  return false;
}

ShutdownSdk();
return true;

}

在编译案例时(已导入libcrypto.a, libcurl.a, libssl.a),遇到linker错误: Undefined symbols for architecture x86_64: "typeinfo for AlibabaCloud::OSS::OssObjectRequest", referenced from: typeinfo for AlibabaCloud::OSS::DeleteObjectRequest in YEEOss.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

注释掉删除Object方法中的: DeleteObjectRequest request(bucketName, ObjectName);

编辑正常,upload,download功能都没问题。

请教是在哪个环节可能出现错误?谢谢

你好,请问这个问题您解决了吗,我最近也遇到了这个问题!