關于cpp程序的編譯指令
編譯需要指定頭文件目錄和庫文件目錄,添加動態鏈接庫aws-cpp-sdk-core和aws-cpp-sdk-s3。
g++ -I<install/prefix/path>/include -L<install/prefix/path>/lib64 -laws-cpp-sdk-core -laws-cpp-sdk-s3 xxx.cpp -o xxx
如果需要使用分片上傳融合接口,則需要增加aws-cpp-sdk-transfer依賴庫;如果需要使用sts功能接口,則需要增加aws-cpp-sdk-sts依賴庫。
g++ -I<install/prefix/path>/include -L<install/prefix/path>/lib64 -laws-cpp-sdk-core -laws-cpp-sdk-s3 -laws-cpp-sdk-transfer -laws-cpp-sdk-sts xxx.cpp -o xxx
運行程序需要鏈接動態庫時,提示找不到相關的.so庫的報錯
報錯描述如下:
error while loading shared libraries: libaws-cpp-sdk-core.so: cannot open shared object file: No such file or dictionary
解決方法:可以使用 -Wl,-rpath 命令在編譯的時候指定運行時庫文件查找路徑。
g++ -I<install/prefix/path>/include -L<install/prefix/path>/lib64 -Wl,-rpath=<install/prefix/path>/lib64 -laws-cpp-sdk-core -laws-cpp-sdk-s3 xxx.cpp -o xxx
找不到公共庫
報錯描述如下:
warning: libaws-c-event-stream.so.0unstable, not found (try using -rpath or -rpath-link)
warning: libaws-c-common.so.0unstable, not found (try using -rpath or -rpath-link)
warning: libaws-checksums.so, not found (try using -rpath or -rpath-link)
使用cmake的時候會生成公共庫的so文件,并安裝到 <install/prefix/path>/lib64 目錄中,如果在目錄中沒有找到,可以到 xos-cpp-sdk/build/.dep/install 目錄下尋找,并復制到 <install/prefix/path>/lib64 目錄中。