关于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 目录中。