aliyun / aliyun-oss-cpp-sdk Goto Github PK
View Code? Open in Web Editor NEWAliyun OSS SDK for C++
License: Other
Aliyun OSS SDK for C++
License: Other
Windows
Enter build folder, open alibabacloud-oss-cpp-sdk.sln with Visual Studio.
现在我们使用的是aliyun-oss-c-sdk
这个repo是oss sdk的cpp版本,但并没有在阿里云SDK 文档简介
中看到相关说明,希望确认两个问题:
谢谢
运行在xp sp3,oss-cpp-sdk静态编译,支持v140_xp方式编译,调用ResumableUploadObject时,报错如下:
error_code:ValidateError, error_msg:Open upload file failed., request_id:, host:
在调用ResumableUploadObject之前检查过文件存在且对文件具备读写权限,win10下正常运行
PutObject fail,code:InvalidArgument,message:The characters encoding must be utf-8
"PutObject fail, code ClientError:200052, message Server returned nothing (no headers, no data), requestId:"
项目组统一开发环境在msys2(https://www.msys2.org )下面,尝试使用mingw64-gcc编译时出错。
gcc版本(9.2.0)
gcc -v结果如下:
Using built-in specs.
COLLECT_GCC=C:\msys64\mingw64\bin\gcc.exe
COLLECT_LTO_WRAPPER=C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: ../gcc-9.2.0/configure --prefix=/mingw64 --with-local-prefix=/mingw64/local --build=x86_64-w64-mingw32 --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --with-native-system-header-dir=/mingw64/x86_64-w64-mingw32/include --libexecdir=/mingw64/lib --enable-bootstrap --with-arch=x86-64 --with-tune=generic --enable-languages=c,lto,c++,fortran,ada,objc,obj-c++ --enable-shared --enable-static --enable-libatomic --enable-threads=posix --enable-graphite --enable-fully-dynamic-string --enable-libstdcxx-filesystem-ts=yes --enable-libstdcxx-time=yes --disable-libstdcxx-pch --disable-libstdcxx-debug --disable-isl-version-check --enable-lto --enable-libgomp --disable-multilib --enable-checking=release --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --enable-plugin --with-libiconv --with-system-zlib --with-gmp=/mingw64 --with-mpfr=/mingw64 --with-mpc=/mingw64 --with-isl=/mingw64 --with-pkgversion='Rev2, Built by MSYS2 project' --with-bugurl=https://sourceforge.net/projects/msys2 --with-gnu-as --with-gnu-ld
Thread model: posix
gcc version 9.2.0 (Rev2, Built by MSYS2 project)
Windows版本
C:\Users\Spring>systeminfo
Host Name: DESKTOP-NDNVDO9
OS Name: Microsoft Windows 10 Pro
OS Version: 10.0.18363 N/A Build 18363
OS Manufacturer: Microsoft Corporation
OS Configuration: Standalone Workstation
OS Build Type: Multiprocessor Free
Registered Owner: Spring
Registered Organization: N/A
Product ID: 00330-80000-00000-AA870
Original Install Date: 12/19/2019, 9:43:32 AM
System Boot Time: 2/3/2020, 9:43:58 AM
System Manufacturer: ASUS
System Model: All Series
System Type: x64-based PC
Processor(s): 1 Processor(s) Installed.
[01]: Intel64 Family 6 Model 60 Stepping 3 GenuineIntel ~3401 Mhz
BIOS Version: American Megatrends Inc. 1802, 1/28/2014
Windows Directory: C:\Windows
System Directory: C:\Windows\system32
Boot Device: \Device\HarddiskVolume3
System Locale: zh-cn;Chinese (China)
Input Locale: en-us;English (United States)
Time Zone: (UTC+08:00) Beijing, Chongqing, Hong Kong, Urumqi
Total Physical Memory: 16,255 MB
Available Physical Memory: 7,219 MB
Virtual Memory: Max Size: 22,872 MB
Virtual Memory: Available: 10,486 MB
Virtual Memory: In Use: 12,386 MB
Page File Location(s): C:\pagefile.sys
Domain: WORKGROUP
Logon Server: \\DESKTOP-NDNVDO9
mkdir build && cd build
cmake ../aliyun-oss-cpp-sdk-1.7.0 -G "Unix Makefiles"
make
官方例子中并没有多线程下使用的最佳实践。请问多线程下是一个线程使用一个Client;还是多个线程可以使用同一个Client实例,不需要加锁?还是有其他更好的实现?
之前在ue4.21里面运行是偶尔崩溃,ue4.24里面运行不了,一开就崩溃。不知道有无人试过在unrealengine 4里面用?
我使用了oss-cpp 1.1.0版本的代码,然后依赖的openssl是1.1.0版本,依赖的curl是7.55.1版本,在中标麒麟系统上运行时提示:/usr/lib64/libc.so.6: version `GLIBC_2.25' not found
alibabacloud-oss-cpp-sdk.lib(Utils.obj) : error LNK2019: 无法解析的外部符号 EVP_MD_CTX_init,该符号在函数 "class std::basic_string<char,struct std::char_traits,class std::allocator > __cdecl AlibabaCloud::OSS::ComputeContentMD5(class std::basic_istream<char,struct std::char_traits > &)" (?ComputeContentMD5@OSS@AlibabaCloud@@ya?AV?$basic_string@DU?$char_traits@D@std@@v?$allocator@D@2@@std@@aeav?$basic_istream@DU?$char_traits@D@std@@@4@@z) 中被引用
alibabacloud-oss-cpp-sdk.lib(CurlHttpClient.obj) : error LNK2019: 无法解析的外部符号 __imp_curl_global_init,该符号在函数 "public: static void __cdecl AlibabaCloud::OSS::CurlHttpClient::initGlobalState(void)" (?initGlobalState@CurlHttpClient@OSS@AlibabaCloud@@SAXXZ) 中被引用
请问出现200006是什么情况?
libCurl更新成7.67版本后,重新编译成果物,上传图片直接超时
class membuf : public std::streambuf {
public:
membuf(char* p, size_t n) {
setg(p, p, p + n);
}
};
auto buf = new membuf(new char[n], n);
auto content = std::make_sharedstd::iostream(buf);
AlibabaCloud::OSS::PutObjectRequest request(BucketName, Key, content);
client.PutObject(request);
返回的信息是code:ParseXMLError,msg:XML_ERROR_MISMATCHED_ELEMENT
我尝试直接用stringstream上传字符串是正常的,但是不知道这个二进制上传哪里出的问题
In multipart upload api, why no async Initiate, Abort, Complete ?
你好 我是需要用Qt开发项目在windows环境中,mingw的版本为7.3.0 64位,请问怎么利用cmake在windows下利用mingw编译源码?利用VS编译我已经弄好了,现在需要用mingw编译,谢谢指导
hope to support socket API ,because our requirement is that the log files of nginx be stored directly on oss,Is there an API for that
sdk 1.4.0版本 CurlHttpClient.cc(518行)
ss << proxyScheme_ << "://" << proxyHost_;
proxyScheme_是一个枚举型,std::stringstream默认识别为整型,导致ss的结果是0://10.10.10.10
修正:
ss << OSS::Http::SchemeToString(proxyScheme_) << "://" << proxyHost_;
修改验证结果可行。
以下是崩溃的堆栈信息
1 #00 pc 0004a988 /system/lib/libc.so (tgkill+12) [armeabi-v7a]
2 #1 pc 0004806b /system/lib/libc.so (pthread_kill+34) [armeabi-v7a]
3 #2 pc 0001dacd /system/lib/libc.so (raise+10) [armeabi-v7a]
4 #3 pc 000194c5 /system/lib/libc.so (__libc_android_abort+34) [armeabi-v7a]
5 #4 pc 00017520 /system/lib/libc.so (abort+4) [armeabi-v7a]
6 #5 pc 012d5e8f /data/app/com.lj.ljshell-1/lib/arm/libcocos2dcpp.so (Json::Value::asInt() const+210) [armeabi-v7a]
7 #6 pc 012d5b1b /data/app/com.lj.ljshell-1/lib/arm/libcocos2dcpp.so (Json::CharReaderBuilder::newCharReader() const+118) [armeabi-v7a]
8 #7 pc 012d7111 /data/app/com.lj.ljshell-1/lib/arm/libcocos2dcpp.so (Json::parseFromStream(Json::CharReader::Factory const&, std::__ndk1::basic_istream<char, std::__ndk1::char_traits >&, Json::Value*, std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator >)+224) [armeabi-v7a]
9 #8 pc 0130b3eb /data/app/com.lj.ljshell-1/lib/arm/libcocos2dcpp.so (AlibabaCloud::OSS::ResumableUploader::loadRecord()+214) [armeabi-v7a]
10 #9 pc 012ffa3d /data/app/com.lj.ljshell-1/lib/arm/libcocos2dcpp.so (AlibabaCloud::OSS::ResumableBaseWorker::validate(AlibabaCloud::OSS::OssError&)+84) [armeabi-v7a]
11 #10 pc 01309623 /data/app/com.lj.ljshell-1/lib/arm/libcocos2dcpp.so (AlibabaCloud::OSS::ResumableUploader::Upload()+42) [armeabi-v7a]
12 #11 pc 012fb809 /data/app/com.lj.ljshell-1/lib/arm/libcocos2dcpp.so (AlibabaCloud::OSS::OssClientImpl::ResumableUploadObject(AlibabaCloud::OSS::UploadObjectRequest const&) const+260) [armeabi-v7a]
13 #12 pc 012ec8ad /data/app/com.lj.ljshell-1/lib/arm/libcocos2dcpp.so (AlibabaCloud::OSS::OssClient::ResumableUploadObject(AlibabaCloud::OSS::UploadObjectRequest const&) const+8) [armeabi-v7a]
14 #13 pc 00af4f49 /data/app/com.lj.ljshell-1/lib/arm/libcocos2dcpp.so (ljUploadCache::uploadFileItem(ljUploadResourceFileItem, char const*, char const*, char const*)+1000) [armeabi-v7a]
15 #14 pc 00af47e9 /data/app/com.lj.ljshell-1/lib/arm/libcocos2dcpp.so (ljUploadCache::uploadFile(ljUploadResourceFileItem*)+126) [armeabi-v7a]
16 #15 pc 00af4699 /data/app/com.lj.ljshell-1/lib/arm/libcocos2dcpp.so (ljUploadCache::threadFunc(bool)+64) [armeabi-v7a]
17 #16 pc 00af4641 /data/app/com.lj.ljshell-1/lib/arm/libcocos2dcpp.so [armeabi-v7a]
18 #17 pc 00047b3f /system/lib/libc.so (__pthread_start(void*)+22) [armeabi-v7a]
19 #18 pc 00019f21 /system/lib/libc.so (__start_thread+6) [armeabi-v7a]
目标安卓打包出来的静态库是目标Mac打出来的5倍大,解压静态库取出相同一个.o对比,elf 格式比 mach-o 大5倍
在Mac 上打包,采用Mac 系统打包方式
cmake -DOPENSSL_ROOT_DIR=/usr/local/Cellar/[email protected]/1.1.1g
-DOPENSSL_LIBRARIES=/usr/local/Cellar/[email protected]/1.1.1g/lib
-DOPENSSL_INCLUDE_DIRS=/usr/local/Cellar/[email protected]/1.1.1g/include/ ..
make
打包出来19MB
给安卓打包
cmake -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK/build/cmake/android.toolchain.cmake
-DANDROID_NDK=$ANDROID_NDK
-DANDROID_ABI=arm64-v8a
-DANDROID_TOOLCHAIN=clang
-DANDROID_PLATFORM=android-23
-DANDROID_STL=c++_shared ..
make
打包出来有104MB,用gstrip 去掉debug info之后还有46MB
编译32位无错,32位库写文档中的例子也无错
只有编译64位有错,是否不支持64位?
cmake 生成64位解决方案
然后运行:msbuild ALL_BUILD.vcxproj
"D:\maiqi\thirdPart\OSS\aliyun-oss-cpp-sdk-master\aliyun-oss-cpp-sdk-master\build64\ALL_BUILD.vcxproj" (default target
) (1) ->
"D:\maiqi\thirdPart\OSS\aliyun-oss-cpp-sdk-master\aliyun-oss-cpp-sdk-master\build64\sample\cpp-sdk-sample.vcxproj" (de
fault target) (4) ->
(Link target) ->
alibabacloud-oss-cpp-sdk.lib(CurlHttpClient.obj) : error LNK2019: unresolved external symbol __imp_curl_global_init
referenced in function "public: static void __cdecl AlibabaCloud::OSS::CurlHttpClient::initGlobalState(void)" (?initGl
obalState@CurlHttpClient@OSS@AlibabaCloud@@SAXXZ) [D:\maiqi\thirdPart\OSS\aliyun-oss-cpp-sdk-master\aliyun-oss-cpp-sdk
-master\build64\sample\cpp-sdk-sample.vcxproj]
alibabacloud-oss-cpp-sdk.lib(CurlHttpClient.obj) : error LNK2019: unresolved external symbol __imp_curl_global_clean
up referenced in function "public: static void __cdecl AlibabaCloud::OSS::CurlHttpClient::cleanupGlobalState(void)" (?
cleanupGlobalState@CurlHttpClient@OSS@AlibabaCloud@@SAXXZ) [D:\maiqi\thirdPart\OSS\aliyun-oss-cpp-sdk-master\aliyun-os
s-cpp-sdk-master\build64\sample\cpp-sdk-sample.vcxproj]
alibabacloud-oss-cpp-sdk.lib(CurlHttpClient.obj) : error LNK2019: unresolved external symbol __imp_curl_slist_append
referenced in function "public: virtual class std::shared_ptr __cdecl AlibabaC
loud::OSS::CurlHttpClient::makeRequest(class std::shared_ptr const &)" (?makeReq
uest@CurlHttpClient@OSS@AlibabaCloud@@UEAA?AV?$shared_ptr@VHttpResponse@OSS@AlibabaCloud@@@std@@aebv?$shared_ptr@VHttp
Request@OSS@AlibabaCloud@@@5@@z) [D:\maiqi\thirdPart\OSS\aliyun-oss-cpp-sdk-master\aliyun-oss-cpp-sdk-master\build64\s
ample\cpp-sdk-sample.vcxproj]
alibabacloud-oss-cpp-sdk.lib(CurlHttpClient.obj) : error LNK2019: unresolved external symbol __imp_curl_slist_free_a
ll referenced in function "public: virtual class std::shared_ptr __cdecl Alibab
aCloud::OSS::CurlHttpClient::makeRequest(class std::shared_ptr const &)" (?makeR
equest@CurlHttpClient@OSS@AlibabaCloud@@UEAA?AV?$shared_ptr@VHttpResponse@OSS@AlibabaCloud@@@std@@aebv?$shared_ptr@VHt
tpRequest@OSS@AlibabaCloud@@@5@@z) [D:\maiqi\thirdPart\OSS\aliyun-oss-cpp-sdk-master\aliyun-oss-cpp-sdk-master\build64
\sample\cpp-sdk-sample.vcxproj]
alibabacloud-oss-cpp-sdk.lib(CurlHttpClient.obj) : error LNK2019: unresolved external symbol __imp_curl_easy_strerro
r referenced in function "public: virtual class std::shared_ptr __cdecl Alibaba
Cloud::OSS::CurlHttpClient::makeRequest(class std::shared_ptr const &)" (?makeRe
quest@CurlHttpClient@OSS@AlibabaCloud@@UEAA?AV?$shared_ptr@VHttpResponse@OSS@AlibabaCloud@@@std@@aebv?$shared_ptr@VHtt
pRequest@OSS@AlibabaCloud@@@5@@z) [D:\maiqi\thirdPart\OSS\aliyun-oss-cpp-sdk-master\aliyun-oss-cpp-sdk-master\build64
sample\cpp-sdk-sample.vcxproj]
alibabacloud-oss-cpp-sdk.lib(CurlHttpClient.obj) : error LNK2019: unresolved external symbol __imp_curl_easy_init re
ferenced in function "private: bool __cdecl AlibabaCloud::OSS::CurlContainer::growPool(void)" (?growPool@CurlContainer
@oss@AlibabaCloud@@AEAA_NXZ) [D:\maiqi\thirdPart\OSS\aliyun-oss-cpp-sdk-master\aliyun-oss-cpp-sdk-master\build64\sampl
e\cpp-sdk-sample.vcxproj]
alibabacloud-oss-cpp-sdk.lib(CurlHttpClient.obj) : error LNK2019: unresolved external symbol __imp_curl_easy_setopt
referenced in function "public: virtual class std::shared_ptr __cdecl AlibabaCl
oud::OSS::CurlHttpClient::makeRequest(class std::shared_ptr const &)" (?makeRequ
est@CurlHttpClient@OSS@AlibabaCloud@@UEAA?AV?$shared_ptr@VHttpResponse@OSS@AlibabaCloud@@@std@@aebv?$shared_ptr@VHttpR
equest@OSS@AlibabaCloud@@@5@@z) [D:\maiqi\thirdPart\OSS\aliyun-oss-cpp-sdk-master\aliyun-oss-cpp-sdk-master\build64\sa
mple\cpp-sdk-sample.vcxproj]
alibabacloud-oss-cpp-sdk.lib(CurlHttpClient.obj) : error LNK2019: unresolved external symbol __imp_curl_easy_perform
referenced in function "public: virtual class std::shared_ptr __cdecl AlibabaC
loud::OSS::CurlHttpClient::makeRequest(class std::shared_ptr const &)" (?makeReq
uest@CurlHttpClient@OSS@AlibabaCloud@@UEAA?AV?$shared_ptr@VHttpResponse@OSS@AlibabaCloud@@@std@@aebv?$shared_ptr@VHttp
Request@OSS@AlibabaCloud@@@5@@z) [D:\maiqi\thirdPart\OSS\aliyun-oss-cpp-sdk-master\aliyun-oss-cpp-sdk-master\build64\s
ample\cpp-sdk-sample.vcxproj]
alibabacloud-oss-cpp-sdk.lib(CurlHttpClient.obj) : error LNK2019: unresolved external symbol __imp_curl_easy_cleanup
referenced in function "public: __cdecl AlibabaCloud::OSS::CurlContainer::~CurlContainer(void)" (??1CurlContainer@OSS
@AlibabaCloud@@qeaa@XZ) [D:\maiqi\thirdPart\OSS\aliyun-oss-cpp-sdk-master\aliyun-oss-cpp-sdk-master\build64\sample\cpp
-sdk-sample.vcxproj]
alibabacloud-oss-cpp-sdk.lib(CurlHttpClient.obj) : error LNK2019: unresolved external symbol __imp_curl_easy_getinfo
referenced in function "public: virtual class std::shared_ptr __cdecl AlibabaC
loud::OSS::CurlHttpClient::makeRequest(class std::shared_ptr const &)" (?makeReq
uest@CurlHttpClient@OSS@AlibabaCloud@@UEAA?AV?$shared_ptr@VHttpResponse@OSS@AlibabaCloud@@@std@@aebv?$shared_ptr@VHttp
Request@OSS@AlibabaCloud@@@5@@z) [D:\maiqi\thirdPart\OSS\aliyun-oss-cpp-sdk-master\aliyun-oss-cpp-sdk-master\build64\s
ample\cpp-sdk-sample.vcxproj]
alibabacloud-oss-cpp-sdk.lib(CurlHttpClient.obj) : error LNK2019: unresolved external symbol __imp_curl_easy_reset r
eferenced in function "public: virtual class std::shared_ptr __cdecl AlibabaClo
ud::OSS::CurlHttpClient::makeRequest(class std::shared_ptr const &)" (?makeReque
st@CurlHttpClient@OSS@AlibabaCloud@@UEAA?AV?$shared_ptr@VHttpResponse@OSS@AlibabaCloud@@@std@@aebv?$shared_ptr@VHttpRe
quest@OSS@AlibabaCloud@@@5@@z) [D:\maiqi\thirdPart\OSS\aliyun-oss-cpp-sdk-master\aliyun-oss-cpp-sdk-master\build64\sam
ple\cpp-sdk-sample.vcxproj]
alibabacloud-oss-cpp-sdk.lib(Utils.obj) : error LNK2019: unresolved external symbol EVP_MD_CTX_init referenced in fu
nction "class std::basic_string<char,struct std::char_traits,class std::allocator > __cdecl AlibabaCloud::
OSS::ComputeContentETag(class std::basic_istream<char,struct std::char_traits > &)" (?ComputeContentETag@OSS@Ali
babaCloud@@ya?AV?$basic_string@DU?$char_traits@D@std@@v?$allocator@D@2@@std@@aeav?$basic_istream@DU?$char_traits@D@std
@@@4@@z) [D:\maiqi\thirdPart\OSS\aliyun-oss-cpp-sdk-master\aliyun-oss-cpp-sdk-master\build64\sample\cpp-sdk-sample.vcx
proj]
alibabacloud-oss-cpp-sdk.lib(Utils.obj) : error LNK2019: unresolved external symbol EVP_MD_CTX_create referenced in
function "class std::basic_string<char,struct std::char_traits,class std::allocator > __cdecl AlibabaCloud
::OSS::ComputeContentETag(class std::basic_istream<char,struct std::char_traits > &)" (?ComputeContentETag@OSS@A
libabaCloud@@ya?AV?$basic_string@DU?$char_traits@D@std@@v?$allocator@D@2@@std@@aeav?$basic_istream@DU?$char_traits@D@s
td@@@4@@z) [D:\maiqi\thirdPart\OSS\aliyun-oss-cpp-sdk-master\aliyun-oss-cpp-sdk-master\build64\sample\cpp-sdk-sample.v
cxproj]
alibabacloud-oss-cpp-sdk.lib(Utils.obj) : error LNK2019: unresolved external symbol EVP_MD_CTX_destroy referenced in
function "class std::basic_string<char,struct std::char_traits,class std::allocator > __cdecl AlibabaClou
d::OSS::ComputeContentETag(class std::basic_istream<char,struct std::char_traits > &)" (?ComputeContentETag@OSS@
AlibabaCloud@@ya?AV?$basic_string@DU?$char_traits@D@std@@v?$allocator@D@2@@std@@aeav?$basic_istream@DU?$char_traits@D@
std@@@4@@z) [D:\maiqi\thirdPart\OSS\aliyun-oss-cpp-sdk-master\aliyun-oss-cpp-sdk-master\build64\sample\cpp-sdk-sample.
vcxproj]
alibabacloud-oss-cpp-sdk.lib(Utils.obj) : error LNK2019: unresolved external symbol EVP_MD_CTX_set_flags referenced
in function "class std::basic_string<char,struct std::char_traits,class std::allocator > __cdecl AlibabaCl
oud::OSS::ComputeContentETag(class std::basic_istream<char,struct std::char_traits > &)" (?ComputeContentETag@OS
S@AlibabaCloud@@ya?AV?$basic_string@DU?$char_traits@D@std@@v?$allocator@D@2@@std@@aeav?$basic_istream@DU?$char_traits@
D@std@@@4@@z) [D:\maiqi\thirdPart\OSS\aliyun-oss-cpp-sdk-master\aliyun-oss-cpp-sdk-master\build64\sample\cpp-sdk-sampl
e.vcxproj]
alibabacloud-oss-cpp-sdk.lib(Utils.obj) : error LNK2019: unresolved external symbol EVP_DigestInit_ex referenced in
function "class std::basic_string<char,struct std::char_traits,class std::allocator > __cdecl AlibabaCloud
::OSS::ComputeContentETag(class std::basic_istream<char,struct std::char_traits > &)" (?ComputeContentETag@OSS@A
libabaCloud@@ya?AV?$basic_string@DU?$char_traits@D@std@@v?$allocator@D@2@@std@@aeav?$basic_istream@DU?$char_traits@D@s
td@@@4@@z) [D:\maiqi\thirdPart\OSS\aliyun-oss-cpp-sdk-master\aliyun-oss-cpp-sdk-master\build64\sample\cpp-sdk-sample.v
cxproj]
alibabacloud-oss-cpp-sdk.lib(Utils.obj) : error LNK2019: unresolved external symbol EVP_DigestUpdate referenced in f
unction "class std::basic_string<char,struct std::char_traits,class std::allocator > __cdecl AlibabaCloud:
:OSS::ComputeContentETag(class std::basic_istream<char,struct std::char_traits > &)" (?ComputeContentETag@OSS@Al
ibabaCloud@@ya?AV?$basic_string@DU?$char_traits@D@std@@v?$allocator@D@2@@std@@aeav?$basic_istream@DU?$char_traits@D@st
d@@@4@@z) [D:\maiqi\thirdPart\OSS\aliyun-oss-cpp-sdk-master\aliyun-oss-cpp-sdk-master\build64\sample\cpp-sdk-sample.vc
xproj]
alibabacloud-oss-cpp-sdk.lib(Utils.obj) : error LNK2019: unresolved external symbol EVP_DigestFinal_ex referenced in
function "class std::basic_string<char,struct std::char_traits,class std::allocator > __cdecl AlibabaClou
d::OSS::ComputeContentETag(class std::basic_istream<char,struct std::char_traits > &)" (?ComputeContentETag@OSS@
AlibabaCloud@@ya?AV?$basic_string@DU?$char_traits@D@std@@v?$allocator@D@2@@std@@aeav?$basic_istream@DU?$char_traits@D@
std@@@4@@z) [D:\maiqi\thirdPart\OSS\aliyun-oss-cpp-sdk-master\aliyun-oss-cpp-sdk-master\build64\sample\cpp-sdk-sample.
vcxproj]
alibabacloud-oss-cpp-sdk.lib(Utils.obj) : error LNK2019: unresolved external symbol EVP_EncodeBlock referenced in fu
nction "class std::basic_string<char,struct std::char_traits,class std::allocator > __cdecl AlibabaCloud::
OSS::ComputeContentMD5(class std::basic_istream<char,struct std::char_traits > &)" (?ComputeContentMD5@OSS@Aliba
baCloud@@ya?AV?$basic_string@DU?$char_traits@D@std@@v?$allocator@D@2@@std@@aeav?$basic_istream@DU?$char_traits@D@std@@
@4@@z) [D:\maiqi\thirdPart\OSS\aliyun-oss-cpp-sdk-master\aliyun-oss-cpp-sdk-master\build64\sample\cpp-sdk-sample.vcxpr
oj]
alibabacloud-oss-cpp-sdk.lib(HmacSha1Signer.obj) : error LNK2001: unresolved external symbol EVP_EncodeBlock [D:\mai
qi\thirdPart\OSS\aliyun-oss-cpp-sdk-master\aliyun-oss-cpp-sdk-master\build64\sample\cpp-sdk-sample.vcxproj]
alibabacloud-oss-cpp-sdk.lib(Utils.obj) : error LNK2019: unresolved external symbol EVP_md5 referenced in function "
class std::basic_string<char,struct std::char_traits,class std::allocator > __cdecl AlibabaCloud::OSS::Com
puteContentETag(class std::basic_istream<char,struct std::char_traits > &)" (?ComputeContentETag@OSS@AlibabaClou
d@@ya?AV?$basic_string@DU?$char_traits@D@std@@v?$allocator@D@2@@std@@aeav?$basic_istream@DU?$char_traits@D@std@@@4@@z)
[D:\maiqi\thirdPart\OSS\aliyun-oss-cpp-sdk-master\aliyun-oss-cpp-sdk-master\build64\sample\cpp-sdk-sample.vcxproj]
alibabacloud-oss-cpp-sdk.lib(Utils.obj) : error LNK2019: unresolved external symbol MD5 referenced in function "clas
s std::basic_string<char,struct std::char_traits,class std::allocator > __cdecl AlibabaCloud::OSS::Compute
ContentETag(char const *,unsigned __int64)" (?ComputeContentETag@OSS@AlibabaCloud@@ya?AV?$basic_string@DU?$char_traits
@d@std@@v?$allocator@D@2@@std@@PEBD_K@Z) [D:\maiqi\thirdPart\OSS\aliyun-oss-cpp-sdk-master\aliyun-oss-cpp-sdk-master\b
uild64\sample\cpp-sdk-sample.vcxproj]
alibabacloud-oss-cpp-sdk.lib(HmacSha1Signer.obj) : error LNK2019: unresolved external symbol EVP_sha1 referenced in
function "public: virtual class std::basic_string<char,struct std::char_traits,class std::allocator > __cd
ecl AlibabaCloud::OSS::HmacSha1Signer::generate(class std::basic_string<char,struct std::char_traits,class std::
allocator > const &,class std::basic_string<char,struct std::char_traits,class std::allocator > cons
t &)const " (?generate@HmacSha1Signer@OSS@AlibabaCloud@@ueba?AV?$basic_string@DU?$char_traits@D@std@@v?$allocator@D@2@
@std@@AEBV45@0@Z) [D:\maiqi\thirdPart\OSS\aliyun-oss-cpp-sdk-master\aliyun-oss-cpp-sdk-master\build64\sample\cpp-sdk-s
ample.vcxproj]
alibabacloud-oss-cpp-sdk.lib(HmacSha1Signer.obj) : error LNK2019: unresolved external symbol HMAC referenced in func
tion "public: virtual class std::basic_string<char,struct std::char_traits,class std::allocator > __cdecl
AlibabaCloud::OSS::HmacSha1Signer::generate(class std::basic_string<char,struct std::char_traits,class std::allo
cator > const &,class std::basic_string<char,struct std::char_traits,class std::allocator > const &)
const " (?generate@HmacSha1Signer@OSS@AlibabaCloud@@ueba?AV?$basic_string@DU?$char_traits@D@std@@v?$allocator@D@2@@std
@@AEBV45@0@Z) [D:\maiqi\thirdPart\OSS\aliyun-oss-cpp-sdk-master\aliyun-oss-cpp-sdk-master\build64\sample\cpp-sdk-sampl
e.vcxproj]
D:\maiqi\thirdPart\OSS\aliyun-oss-cpp-sdk-master\aliyun-oss-cpp-sdk-master\build64\sample\Release\cpp-sdk-sample.exe
: fatal error LNK1120: 23 unresolved externals [D:\maiqi\thirdPart\OSS\aliyun-oss-cpp-sdk-master\aliyun-oss-cpp-sdk-m
aster\build64\sample\cpp-sdk-sample.vcxproj]
12 Warning(s)
25 Error(s)
oss从内存上传图片的sample是错的...
#include "oss_api.h"
#include "aos_http_io.h"
const char *endpoint = "<yourEndpoint>";
const char *access_key_id = "<yourAccessKeyId>";
const char *access_key_secret = "<yourAccessKeySecret>";
void init_options(oss_request_options_t *options)
{
options->config = oss_config_create(options->pool);
/* 用char*类型的字符串初始化aos_string_t类型。*/
aos_str_set(&options->config->endpoint, endpoint);
aos_str_set(&options->config->access_key_id, access_key_id);
aos_str_set(&options->config->access_key_secret, access_key_secret);
/* 是否使用了CNAME。0表示不使用。*/
options->config->is_cname = 0;
/* 用于设置网络相关参数,其中这个函数的第二个参数表示ctl的归属,默认为0。*/
options->ctl = aos_http_controller_create(options->pool, 0);
/* 设置链接超时,默认是10秒。*/
options->ctl->options->connect_timeout = 10;
/* 设置DNS超时,默认是60秒。*/
options->ctl->options->dns_cache_timeout = 60;
/*
设置请求超时:
通过设置speed_limit的值控制能容忍的最小速率,默认是1024,即1KB/s。
通过设置speed_time的值控制能容忍的最长时间,默认是15秒。
表示如果传输速率连续15秒小于1KB/s,则超时。
*/
options->ctl->options->speed_limit = 1024;
options->ctl->options->speed_time = 15;
}
我在 ubunt 16.04 系统下按照官方的指导,下载 oss 源码,编译,安装后(均无报错),再使用官方的示例代码,在编译的时候,libalibabacloud-oss-cpp-sdk.a 找不到 curl 相关函数的定义,检测 sdk 目录下的 CMakeLists.txt 文件,发现只有当 BUILD_SHARED_LIBS 开关打开后才会将 curl 相关的库链接进去,而 BUILD_SHARED_LIBS 开关在主目录下的 CMakeLists.txt 中默认是关闭的。
所以,要么在 cmake 的时候打开 BUILD_SHARED_LIBS ,要么在 CMakeLists.txt 中默认将 BUILD_SHARED_LIBS 打开。
mac下,生成dylib后,链接到程序提示链接不到符号,看了下符号表
没办法,改了
#if !defined(ALIBABACLOUD_DECL_EXPORT)
# define ALIBABACLOUD_DECL_EXPORT __attribute__((visibility("default")))
#endif
if(CMAKE_HOST_UNIX) 确定在mac下这里不会跑偏到“LINUX”???
set(PLATFORM_LINUX 1)
set(TARGET_OS "LINUX")
elseif(CMAKE_HOST_WIN32)
set(PLATFORM_WINDOWS 1)
set(TARGET_OS "WINDOWS")
elseif(CMAKE_HOST_APPLE)
set(PLATFORM_APPLE 1)
set(TARGET_OS "APPLE")
else()
message(FATAL_ERROR "Do not support unknown host OS")
endif()
当最后一个part快下载完成时退出系统调用disableRequest,最后一个part下载完成后返回ClientError:100002", "Disable all requests by upper. 下次进入系统后读取上次的下载记录, 因为所有的part都已经下载完成partsToDownload会是空,不会产生请求, 在执行auto meta = outcomes[0].result().Metadata();会崩溃
aliyun-oss-cpp-sdk/sdk/src/utils/FileSystemUtils.cc:125:30: error: cannot bind non-const lvalue reference of type ‘time_t&’ {aka ‘long int&’} to an rvalue of type ‘time_t’ {aka ‘long int’}
return GetPathInfo(file, size,t);
fix patch
--- a/sdk/src/utils/FileSystemUtils.cc
+++ b/sdk/src/utils/FileSystemUtils.cc
@@ -121,7 +121,7 @@ bool AlibabaCloud::OSS::IsFileExist(const std::string& file)
{
std::streamsize size;
time_t t;
OssClient
是一个指向实现 OssClientImpl
的类,其实现通过委托构造函数,最终在一个构造函数内 new OssClientImpl(...)
,在析构函数中 delete client_
。这并 没有阻止用户对 OssClient
的对象进行拷贝,如果用户这么做是危险的。
比如现在我就遇到了该问题,我想拆分 OssClient
函数集,让用户面向资源的方式去操作,所以让 OssClient
做为配置选项传递资源管理器就撞上了。
class COssClient final
{
private:
AlibabaCloud::OSS::OssClient proxy_;
};
class COssObject
{
explicit COssObject(COssClient const& oss_client) : oss_client_(oss_client) {}
private:
COssClient oss_client_;
};
class COssUpload : public COssObject
{
};
socket 编程可以指定网卡,我有eth0, eth1 两个网卡,想要指定eth1, 此sdk 上层函数有没有指定网口的功能
提供的有关上传数据的接口参数为 std::shared_ptr<std::iostream>
,如果遇上传的数据来源于程序产生,那么使用如下方式解决:
using byte_t = unsigned char;
bool COssUpload::UploadPart(int iPartNumber
, byte_t const* pkbyContent
, std::uint64_t ui64ContentLength
, COssError& rError)
{
std::string const kstrContent((char*)pkbyContent
, static_cast<std::string::size_type>(ui64ContentLength));
std::shared_ptr<std::iostream> piosContent = std::make_shared<std::stringstream>
( kstrContent
, std::ios::in|std::ios::binary);
return UploadPart(iPartNumber, piosContent, ui64ContentLength, rError);
}
示例中,存在损耗性能的方面:
构建 std::string const kstrContent
将裸数据构建 std::string
动态分配内存空间。
构建 std::stringstream
对象
从 std::string
构建 std::stringstream
将导致 std::string_buf
通过 std::allocator
再次动态分配内存。
智能指针的引用管理
对于一个大的文件循环上传分片,由 std::shared_ptr
不断的引用管理,存在一定的计算。
可见,一块内存数据被反复折腾,而不是以较少代价的方式被处理。
可以给一个使用线程池进行异步上传文件的demo吗
因上层调用需要判断http的状态码,能否在OssErrror类中 增加该变量,谢谢。
GetObjectRequest request(BucketName, ObjectName);
auto outcome = client.GetObject(request);
if (outcome.isSuccess()) {
std::cout << "getObjectToBuffer" << " success, Content-Length:" << outcome.result().Metadata().ContentLength() << std::endl;
/打印下载内容/
std::string content;
*(outcome.result().Content()) >> content;
std::cout << "getObjectToBuffer" << "content:" << content << std::endl;
}
else {
/异常处理/
std::cout << "getObjectToBuffer fail" <<
",code:" << outcome.error().Code() <<
",message:" << outcome.error().Message() <<
",requestId:" << outcome.error().RequestId() << std::endl;
ShutdownSdk();
return -1;
}
*(outcome.result().Content()) >> content;content中的内容很可能不全,如果有换行符之类的
看到 C 语言版本的 OSS SDK 已经加入到 vcpkg ports 里了,有计划将 C++ 版本加入吗?
另外不直接将依赖库包含在工程中是不是更利于用户集成(可以对库版本有一定要求)?用户可以通过 vcpkg 等工具自己管理依赖库。
谢谢!
下载过程中,由于网络信号弱,或者不想继续等待下载了,请问可否取消下载,等下次有时间了再下载。
GetObjectRequest request(BucketName, ObjectName);
auto outcome = client.GetObject(request);
if (outcome.isSuccess()) {
std::cout << "getObjectToBuffer" << " success, Content-Length:" << outcome.result().Metadata().ContentLength() << std::endl;
/打印下载内容/
std::string content;
*(outcome.result().Content()) >> content;
std::cout << "getObjectToBuffer" << "content:" << content << std::endl;
}
this example only suit to files,but how to download a pic into memory?
因为要做一个插件,希望把openssl转成静态库,避免手动导入Dll文件。
编译过程是没问题的,分别编译出libeay32.lib(13MB)和ssleay32.lib(2MB),单独测试也是成功的。OpenSSL的版本是1.0.2p。
但是替换了lib为静态库后,我在程序目录删除libeay32.dll和sslyea32.dll,运行时提示未找到LIBEAY.DLL。
请教是否oss的sdk本身不支持这样使用openssl静态库的操作。
谢谢
获取存储对象当 设置请求范围 时,返回 Failure when receiving data from the peer
,示例如下:
bool COssDownload::DownloadPart(int iPartNumber
, std::shared_ptr<std::iostream>& rpiosContent
, std::int64_t& ri64ContentLength
, COssError& rError)
{
GetObjectRequest request(GetBucket(), GetKey());
std::int64_t const ki64Start = (iPartNumber - 1) * GetPartSize();
std::int64_t const ki64Amt = GetContentLength() - ki64Start;
std::int64_t const ki64End = ki64Start + (GetPartSize() < ki64Amt ? GetPartSize() : ki64Amt);
request.setRange(ki64Start, ki64End); // FAILED
request.setResponseStreamFactory([&rpiosContent]() { return rpiosContent; });
auto res = GetProxy()->GetObject(request);
if (res.isSuccess())
{
return true;
}
rError = res.error();
return false;
}
- 不调用
setRange
可正常返回结果。- 环境: Windows 7 + VS2015
- 区域: oss-cn-shenzhen
Hi,
I have downloaded the Alibaba C++ SDK and trying to generate code using cmake generate command and getting error "CMake Error at /CMakeLists.txt:8 (compileAsC99):
Unknown CMake command "compileAsC99"." please let me know if this is known error.
RT 带有中文名字的文件传不上去,显示参数非法
报错" error LNK2019: 无法解析的外部符号 "public: class AlibabaCloud::OSS::Outcome<class AlibabaCloud::OSS::OssError,class AlibabaCloud::OSS::GetObjectResult> __cdecl AlibabaCloud::OSS::OssClient::GetObjectW(class AlibabaCloud::OSS::GetObjectRequest const &)const " (?GetObjectW@OssClient@OSS@AlibabaCloud@@qeba?AV?$Outcome@VOssError@OSS@AlibabaCloud@@VGetObjectResult@23@@23@AEBVGetObjectRequest@23@@z),该符号在函数 "int __cdecl AliYunOssDownLoadFile(class std::basic_string<char,struct std::char_traits,class std::allocator > const &,class std::basic_string<char,struct std::char_traits,class std::allocator > &)" (?AliYunOssDownLoadFile@@YAHAEBV?$basic_string@DU?$char_traits@D@std@@v?$allocator@D@2@@std@@AEAV12@@z) 中被引用",请问怎么解决
一个oss-cpp-sdk.a文件,在测试demo上传图片正常。
但是在实际项目中上传图片 上传图片失败,返回的错误: PutObject fail with msg Timeout wasreached
比较代码,demo是在主线程中上传的,实际项目中是在子线程中上传的
请告知下 后续可以怎么排查
使用分片传输,在多线程情况下,PartList
无法保证分片序号按非降序排列,在进行分片重组校验时(即 CompleteMultipartUpload
),返回 InvalidPartOrder
。
class ALIBABACLOUD_OSS_EXPORT CompleteMultipartUploadRequest
: public OssObjectRequest
{
public:
CompleteMultipartUploadRequest(const std::string& bucket
, const std::string& key);
CompleteMultipartUploadRequest(const std::string& bucket
, const std::string& key
, const PartList& partList);
CompleteMultipartUploadRequest(const std::string& bucket
, const std::string& key
, const PartList& partList
, const std::string& uploadId);
// ...
};
在 CompleteMultipartUploadRequest
中未对分片序号排列进行检查校正,同时,服务端也没有对此进行处理,直接返回 InvalidPartOrder
。
CompleteMultipartUploadRequest
进行检测,替用户纠正排列顺序。在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功能都没问题。
请教是在哪个环节可能出现错误?谢谢
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.