SS调试记录
1.1 开通oss服务
具体参考以下链接:
https://help.aliyun.com/document_detail/31884.html?spm=a2c4g.11186623.6.558.n2g1UA
1.2 SDK安装
在ubuntu下安装,安装步骤如下:
- 安装CMake
执行以下命令安装CMake。
sudo apt-get install cmake
- 安装第三方库
执行以下命令安装第三方库。
sudo apt-get install libcurl4-openssl-dev libapr1-dev libaprutil1-dev libmxml-dev
下载oss sdk,链接为:
https://github.com/aliyun/aliyun-oss-c-sdk
编译安装OSS C SDK
典型的编译命令如下:
1. cmake .
2. make
3. make install
注意:
- 执行cmake . 时默认会到/usr/local/下面去寻找curl,apr,apr-util,mxml的头文件和库文件。
- 默认编译是Debug类型,可以指定以下几种编译类型: Debug, Release, RelWithDebInfo和MinSizeRel,如果要使用release类型编译,则执行cmake -f CMakeLists.txt -DCMAKE_BUILD_TYPE=Release
- 如果您在安装curl,apr,apr-util,mxml时指定了安装目录,则需要在执行cmake时指定这些库的路径,
- 比如:cmake -f CMakeLists.txt -DCURL_INCLUDE_DIR=/usr/local/include/curl/ -DCURL_LIBRARY=/usr/local/lib/libcurl.so -DAPR_INCLUDE_DIR=/usr/local/include/apr-1/ -DAPR_LIBRARY=/usr/local/lib/libapr-1.so -DAPR_UTIL_INCLUDE_DIR=/usr/local/apr/include/apr-1 -DAPR_UTIL_LIBRARY=/usr/local/apr/lib/libaprutil-1.so -DMINIXML_INCLUDE_DIR=/usr/local/include -DMINIXML_LIBRARY=/usr/local/lib/libmxml.so
- 如果要指定安装目录,则需要在cmake时增加: -DCMAKE_INSTALL_PREFIX=/your/install/path/usr/local/
- 如果执行cmake时报以下错误:Could not find apr-config/apr-1-config,原因是在默认路径里面找不到apr-1-config文件,这时候可以在执行cmake命令时,在最后面加上-DAPR_CONFIG_BIN=/path/to/bin/apr-1-config。如果报:Could not find apu-config/apu-1-config,则需要加上-DAPU_CONFIG_BIN=/path/to/bin/apu-1-config。
参考链接:
https://help.aliyun.com/document_detail/32132.html?spm=a2c4g.11186623.6.795.puijFV
注:
如果在ubuntu14.04上执行”cmake .”命令时会出现报错信息:CMAKE_CXX_COMPILER-NOTFOUND,则需要安装g++: apt-get install g++
然后再执行:
cmake .
make
make install
即可
安装依赖库(ubuntu下的依赖库与交叉依赖库)
https://help.aliyun.com/document_detail/32132.html?spm=a2c4g.11186623.6.797.Bf6aUL
我自己在ubuntu下的编译oss-c-sdk时的命令
cmake -f CMakeLists.txt -DCURL_INCLUDE_DIR=/usr/local/include/curl/ -DCURL_LIBRARY=/usr/local/lib/libcurl.so -DAPR_INCLUDE_DIR=/usr/local/apr/include/apr-1 -DAPR_LIBRARY=/usr/local/apr/lib/libapr-1.so -DAPR_UTIL_INCLUDE_DIR=/usr/local/apr/include/apr-1 -DAPR_UTIL_LIBRARY=/usr/local/apr/lib/libaprutil-1.so -DMINIXML_INCLUDE_DIR=/usr/local/include -DMINIXML_LIBRARY=/usr/local/lib/libmxml.so
1.3 demo程序运行
1.3.1 下载demo程序
下载oss的demo程序,链接为:
demo程序的使用说明可以参考:
https://help.aliyun.com/document_detail/32132.html
https://yq.aliyun.com/articles/60924?spm=a2c4g.11186623.2.15.ljDN1R
1.3.2 编译运行demo程序
进入到oss-c-sdk-demo-ubuntu工程目录,修改main.c,下面修改的内容是参照3.1节开通oss服务时对应的内容。
const char OSS_ENDPOINT[] = "oss-cn-shanghai.aliyuncs.com";
const char ACCESS_KEY_ID[] = "LTAIGMGKwETW7Rbj";
const char ACCESS_KEY_SECRET[] = "i8MX7RAOY5Z5sCNQ721glLWxd4CVTw";
const char BUCKET_NAME[] = "pandarobot";
const char OBJECT_NAME[] = "SouthIsland_NewZealand.jpg";
执行make命令,发现
进入到/usr/local/include/oss_c_sdk,编辑aos_define.h
修改 #include < apr_time.h> 为 #include<apr-1/ apr_time.h>
继续make,出现类似的错误继续修改,直到make成功
然后输入 ./main
发现报错
那是因为目标程序需要依赖库
1、首先打开/etc/ld.so.conf文件
2、加入动态库文件所在的目录:执行vi /etc/ld.so.conf,在"include ld.so.conf.d/*.conf"下方增加"/usr/local/lib"。
3、保存后,在命令行终端执行:/sbin/ldconfig -v;其作用是将文件/etc/ld.so.conf列出的路径下的库文件缓存到/etc/ld.so.cache以供使用,因此当安装完一些库文件,或者修改/etc/ld.so.conf增加了库的新搜索路径,需要运行一下ldconfig,使所有的库文件都被缓存到文件/etc/ld.so.cache中,如果没做,可能会找不到刚安装的库。
参考链接:
https://www.cnblogs.com/codingmengmeng/p/7456539.html
再次编译运行./main
然后在阿里云的oss上就可以看到刚刚上传的SouthIsland_NewZealand.jpg
32位的ubuntu下,编译demo程序时,会报错:
/usr/local/include/oss_c_sdk/aos_define.h:11:28: fatal error: apr-1/apr_time.h: No such file or directory
修改Makefile,红色方框中为增加的内容
再次编译的时候,会有以下错误/usr/include/apr-1.0/apr.h:358:1: error: unknown type name ‘off64_t’
这是因为32位的ubuntu不支持off64_t,编辑/usr/include/apr-1.0/apr.h第358行,将off64_t改成off_t,再次编译就可以通过了。
参考链接:https://stackoverflow.com/questions/22663897/unknown-type-name-off64-t
1.3.3 交叉编译运行demo程序
1.3.3.1 安装交叉编译器
针对我们的机器人主控板ControllerMain使用的是FreeScale的iMx.6,安装对应的交叉编译器。
将freescale.tar.gz放到/opt目录下
tar zxvf freescale.tar.gz
将交叉编译器增加到环境变量中
gedit /etc/profile
在文件最后增加内容如下:
export ARCH=arm
export CROSS_COMPILE=/opt/freescale/usr/local/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/arm-none-linux-gnueabi-
export PATH=/opt/freescale/usr/local/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin:$PATH
执行source /etc/profile,使交叉编译器生效,最好再reboot
安装32bit的兼容库
apt-get install lib32z1 lib32ncurses5 lib32bz2-1.0
然后查看交叉编译器版本
arm-fsl-linux-gnueabi-gcc -v
如果能够查看到版本,说明交叉编译器安装成功
1.3.3.2 交叉编译demo程序
进入到oos-c-sdk-demo-ubuntu目录,修改makefile
gedit Makefile
修改INCLUDES和CC如下图所示
然后执行make命令,发现报错如下:
然后进入到/usr/include/curl/目录下
gedit curlrules.h
发现如下这段
意思是我们在1.2节所安装的libcurl的执行程序在这里不适用了,我们要重新交叉编译libcurl。
1. 安装curl
于是,在网上找libcurl的源代码工程
https://curl.haxx.se/download.html
下载链接为:
file:///D:/Documents/Downloads/curl-7.59.0.tar.gz
将curl-7.59.0.tar.gz复制到ubuntu中,交叉编译
这里将curl-7.59.0.tar.gz放到~/kevin 目录下
tar zxvf curl-7.59.0.tar.gz
然后交叉编译curl:
./configure --prefix=/home/kevin/dependLib/libcurl --host=arm-none-linux CC=arm-none-linux-gnueabi-gcc CXX=arm-none-linux-gnueabi-g++
Ubuntu 32bit:
./configure --prefix=/root/panda/PicoIPC-mqtt/oss/dependlib/dependlib-arm/libcurl --host=arm-none-linux CC=arm-none-linux-gnueabi-gcc CXX=arm-none-linux-gnueabi-g++
make
make install
如果configure按照如下配置执行:
./configure --host=arm-none-linux CC=arm-none-linux-gnueabi-gcc CXX=arm-none-linux-gnueabi-g++
那么libcurl会在以下目录:
/usr/local/lib
参考链接:
ARM平台移植libcurl curl-7.49.0
http://blog.csdn.net/miaodichiyou/article/details/51451134
交叉编译生成的libcurl在/home/kevin/ dependLib /libcurl目录下
Libraries have been installed in:
/home/kevin/dependLib/libcurl/lib
再次进入到oos-c-sdk-demo-ubuntu目录,修改makefile
然后再次执行make命令,发现报错
然后到/usr目录下查找mxml.h,发现它在include目录下,继续修改makefile
继续执行make命令,发现报错如下
修改makefile,重新指定oss_c_sdk和curl的目录
继续make,发现报错减少
2. 安装apr
下载apr的源代码
http://apr.apache.org/download.cgi
https://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-1.6.3.tar.gz
http://archive.apache.org/dist/apr/apr-1.5.2.tar.gz
在ubuntu中解压,进入apr文件夹,
新建arm-linux.cache
gedit arm-linux.cache,填写以下内容
apr_cv_process_shared_works=yes
apr_cv_mutex_robust_shared=yes
保存,退出。
输入以下命令
./configure --prefix=/home/kevin/dependLib/apr/ --host=arm-linux CC=arm-none-linux-gnueabi-gcc CXX=arm-none-linux-gnueabi-g++ LD=arm-none-linux-gnueabi-ld ac_cv_file__dev_zero=yes ac_cv_func_setpgrp_void=yes ac_cv_sizeof_struct_iovec=8 apr_cv_tcp_nodelay_with_cork=yes --cache=arm-linux.cache
Ubuntu 32bit下,输入以下命令
./configure --prefix=/root/panda/PicoIPC-mqtt/oss/dependlib/dependlib-arm/apr/ --host=arm-linux CC=arm-none-linux-gnueabi-gcc CXX=arm-none-linux-gnueabi-g++ LD=arm-none-linux-gnueabi-ld ac_cv_file__dev_zero=yes apr_cv_mutex_robust_shared=yes apr_cv_process_shared_works=yes ac_cv_func_setpgrp_void=yes ac_cv_sizeof_struct_iovec=8 apr_cv_tcp_nodelay_with_cork=yes --cache=arm-linux.cache
参考链接:
https://www.cnblogs.com/zhangsf/archive/2013/08/21/3272960.html
https://blog.csdn.net/u010394807/article/details/50761770
发现报错:cannot remove `libtoolT’: No such file or directory
网上找到一些解决方案,就是编辑 configure文件,查找 $RM "$cfgfile" 这个地方,用#注释掉,然后就可以了
参考链接:https://my.oschina.net/u/146514/blog/196168
继续./configure…… 发现报错
继续修改configure
#gedit configure
具体修改内容如下
还需要对configure文件进行一下修改,搜索apr_ssize_t可以定位到下面一段代码:
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking which format to use for apr_ssize_t" >&5
$as_echo_n "checking which format to use for apr_ssize_t... " >&6; }
if test -n "$ssize_t_fmt"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: %$ssize_t_fmt" >&5
$as_echo "%$ssize_t_fmt" >&6; }
elif test "$ac_cv_sizeof_ssize_t" = "$ac_cv_sizeof_int"; then
ssize_t_fmt="d"
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: %d" >&5
$as_echo "%d" >&6; }
elif test "$ac_cv_sizeof_ssize_t" = "$ac_cv_sizeof_long"; then
ssize_t_fmt="ld"
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: %ld" >&5
$as_echo "%ld" >&6; }
else
as_fn_error $? "could not determine the proper format for apr_ssize_t" "$LINENO" 5
fi
将中间添加一段代码(红色标注),修改为:
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking which format to use for apr_ssize_t" >&5
$as_echo_n "checking which format to use for apr_ssize_t... " >&6; }
if test -n "$ssize_t_fmt"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: %$ssize_t_fmt" >&5
$as_echo "%$ssize_t_fmt" >&6; }
elif test "$ac_cv_sizeof_ssize_t" = "$ac_cv_sizeof_int"; then
ssize_t_fmt="d"
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: %d" >&5
$as_echo "%d" >&6; }
elif test "$ac_cv_sizeof_ssize_t" = "$ac_cv_sizeof_long"; then
ssize_t_fmt="ld"
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: %ld" >&5
$as_echo "%ld" >&6; }
elif test "$ac_cv_sizeof_ssize_t" = "$ac_cv_sizeof_long_long";then
ssize_t_fmt="lld"
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: %lld" >&5
$as_echo "%lld" >&6; }
else
as_fn_error $? "could not determine the proper format for apr_ssize_t" "$LINENO" 5
fi
搜索apr_size_t可以定位到下面一段代码:
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking which format to use for apr_size_t" >&5
$as_echo_n "checking which format to use for apr_size_t... " >&6; }
if test -n "$size_t_fmt"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: %$size_t_fmt" >&5
$as_echo "%$size_t_fmt" >&6; }
elif test "$ac_cv_sizeof_size_t" = "$ac_cv_sizeof_int"; then
size_t_fmt="d"
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: %d" >&5
$as_echo "%d" >&6; }
elif test "$ac_cv_sizeof_size_t" = "$ac_cv_sizeof_long"; then
size_t_fmt="ld"
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: %ld" >&5
$as_echo "%ld" >&6; }
else
as_fn_error $? "could not determine the proper format for apr_size_t" "$LINENO" 5
fi
将中间添加一段代码(红色标注),修改为:
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking which format to use for apr_size_t" >&5
$as_echo_n "checking which format to use for apr_size_t... " >&6; }
if test -n "$size_t_fmt"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: %$size_t_fmt" >&5
$as_echo "%$size_t_fmt" >&6; }
elif test "$ac_cv_sizeof_size_t" = "$ac_cv_sizeof_int"; then
size_t_fmt="d"
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: %d" >&5
$as_echo "%d" >&6; }
elif test "$ac_cv_sizeof_size_t" = "$ac_cv_sizeof_long"; then
size_t_fmt="ld"
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: %ld" >&5
$as_echo "%ld" >&6; }
elif test "$ac_cv_sizeof_size_t" = "$ac_cv_sizeof_long_long"; then
size_t_fmt="lld"
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: %lld" >&5
$as_echo "%lld" >&6; }
else
as_fn_error $? "could not determine the proper format for apr_size_t" "$LINENO" 5
fi
执行make命令,发现报错
报错原因:
因为gen_test_char 使用编译工具编译出来的,但交叉编译出的gen_test_char这个工具在宿主机上无法使用,
所以可以先./configure 再make 将工具保存起来 在执行交叉编译configure,再把工具cp回原位置并修改makefile 执行即解决
完整编译流程如下:
./configure
make clean
make
cp -a tools/gen_test_char ..
make clean
./configure --prefix=/home/kevin/dependLib/apr --host=arm-linux CC=arm-none-linux-gnueabi-gcc CXX=arm-none-linux-gnueabi-g++ LD=arm-none-linux-gnueabi-ld ac_cv_file__dev_zero=yes ac_cv_func_setpgrp_void=yes ac_cv_sizeof_struct_iovec=8 apr_cv_tcp_nodelay_with_cork=yes --cache=arm-linux.cache
cp -a ../gen_test_char tools/
gedit Makefile
134 行
OBJECTS_gen_test_char = tools/gen_test_char.lo $(LOCAL_LIBS)
屏蔽
#OBJECTS_gen_test_char = tools/gen_test_char.lo $(LOCAL_LIBS)
目的是不生成新的gen_test_char文件
gedit include/apr_want.h 第93行 #ifndef APR_IOVEC_DEFINED 替换成#if 0
make
make install
Libraries have been installed in:
/home/kevin/dependLib/apr//lib
如果configure按照如下命令执行:
./configure --host=arm-linux CC=arm-none-linux-gnueabi-gcc CXX=arm-none-linux-gnueabi-g++ LD=arm-none-linux-gnueabi-ld ac_cv_file__dev_zero=yes ac_cv_func_setpgrp_void=yes ac_cv_sizeof_struct_iovec=8 apr_cv_tcp_nodelay_with_cork=yes --cache=arm-linux.cache
那么lib会在以下目录:
Libraries have been installed in:
/usr/local/apr/lib
参考链接:
http://blog.csdn.net/m0_37263637/article/details/78590853
3. 安装apr-util
下载链接为:http://apr.apache.org/download.cgi
tar -xvzf apr-util-1.4.1.tar.gz
cd apr-util-1.4.1.
mkdir /home/kevin/dependLib/apr-util
./configure
./configure --prefix=/home/kevin/dependLib/apr-util --with-apr=/home/kevin/dependLib/apr --host=arm-linux CC=arm-none-linux-gnueabi-gcc CXX=arm-none-linux-gnueabi-g++ LD=arm-none-linux-gnueabi-ld
Ubuntu 32bit 下:
./configure --prefix=/root/panda/PicoIPC-mqtt/oss/dependlib/dependlib-arm/apr-util --with-apr=/root/panda/PicoIPC-mqtt/oss/dependlib/dependlib-arm/apr --host=arm-linux CC=arm-none-linux-gnueabi-gcc CXX=arm-none-linux-gnueabi-g++ LD=arm-none-linux-gnueabi-ld
make
中间过程出现报错
xml/apr_xml.c:35:19: fatal error: expat.h: No such file or directory
网上PC平台说是说缺少了xml的解析器。查阅网络资料后找到了解决方案,下载libexpat,并交叉编译
git clone https://github.com/libexpat/libexpat.git
cd expat/
./buildconf.sh
出现报错
apt-get install autoconf automake libtool
继续输入以下指令
./configure --prefix=/home/kevin/dependLib/expat/ --with-docbook -host=arm-linux CC=arm-none-linux-gnueabi-gcc CXX=arm-none-linux-gnueabi-g++
Ubuntu 32bit下
./configure --prefix=/root/panda/PicoIPC-mqtt/oss/dependlib/dependlib-arm/expat/ --with-docbook -host=arm-linux CC=arm-none-linux-gnueabi-gcc CXX=arm-none-linux-gnueabi-g++
出现报错
apt-get install docbook2x
automake
make
make install
–with-expat=/home/kevin/dependLib/expat, expat安装目录加入到apr-util-1.6.1 configure中。
进入到apr-util-1.6.1目录中
apr-util-1.5.4/xlate/xlate.c的handle_special_names函数,直接关掉本地编码相关的两个判断,直接返回return page; 即:72 75行
// return apr_os_default_encoding(pool);
return page;
参考链接:http://blog.csdn.net/freeman1975/article/details/53482713
完整版的命令如下:
./configure --prefix=/home/kevin/dependLib/apr-util --host=arm-linux CC=arm-none-linux-gnueabi-gcc CXX=arm-none-linux-gnueabi-g++ --with-apr=/home/kevin/dependLib/apr --with-expat=~/kevin/dependLib/libexpat/expat --with-expat=/home/kevin/dependLib/expat
Ubuntu 32位下:
./configure --prefix=/root/panda/PicoIPC-mqtt/oss/dependlib/dependlib-arm/apr-util --host=arm-linux CC=arm-none-linux-gnueabi-gcc CXX=arm-none-linux-gnueabi-g++ --with-apr=/root/panda/PicoIPC-mqtt/oss/dependlib/dependlib-arm/apr --with-expat=/root/panda/PicoIPC-mqtt/oss/dependlib/dependlib-arm/expat
make
make install
Libraries have been installed in:
/home/kevin/dependLib/apr-util/lib
如果configure按照以下配置:
./configure --host=arm-linux CC=arm-none-linux-gnueabi-gcc CXX=arm-none-linux-gnueabi-g++ --with-apr=/home/kevin/dependLib/apr --with-expat=~/kevin/dependLib/libexpat/expat --with-expat=/home/kevin/dependLib/expat
那里库会安装到下列目录中:
Libraries have been installed in:
/usr/local/apr/lib
/usr/bin/install -c -m 644 aprutil.exp /usr/local/apr/lib
/usr/bin/install -c -m 755 apu-config.out /usr/local/apr/bin/apu-1-config
参考链接:
http://blog.csdn.net/m0_37263637/article/details/78590853
4. 安装mxml
mxml的下载链接为:
https://github.com/michaelrsweet/mxml/releases
https://github.com/michaelrsweet/mxml/releases/download/v2.11/mxml-2.11.tar.gz
tar -xvzf mxml-2.11.tar.gz
cd mxml-2.11
./configure --prefix=/home/kevin/dependLib/mxml --host=arm-linux CC=arm-none-linux-gnueabi-gcc CXX=arm-none-linux-gnueabi-g++
Ubuntu 32bit 下:
./configure --prefix=/root/panda/PicoIPC-mqtt/oss/dependlib/dependlib-arm/mxml --host=arm-linux CC=arm-none-linux-gnueabi-gcc CXX=arm-none-linux-gnueabi-g++
make
make install
如果configure按照如下进行配置:
./configure --host=arm-linux CC=arm-none-linux-gnueabi-gcc CXX=arm-none-linux-gnueabi-g++
那么库会被安装到如下目录:
Installing libmxml.so to /usr/local/lib...
Installing libmxml.a to /usr/local/lib...
Installing mxmldoc in /usr/local/bin...
Installing documentation in /usr/local/share/doc/mxml...
Installing header files in /usr/local/include...
Installing pkgconfig files in /usr/local/lib/pkgconfig...
Installing man pages in /usr/local/share/man...
参考链接:
http://blog.csdn.net/sukhoi27smk/article/details/19633601
以上1~4步完成的是Apache的交叉编译
5. oss_c_sdk交叉编译
参考链接:
https://help.aliyun.com/document_detail/32132.html?spm=a2c4g.11186623.6.796.apHDuU
进入到aliyun-oss-c-sdk目录
CMakeList.txt开头增加如下内容
SET(CMAKE_SYSTEM_NAME Linux)
SET(TOOLCHAIN_DIR "/opt/freescale/usr/local/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain")
set(CMAKE_SYSTEM_PROCESSOR MIPS)
SET(CMAKE_FIND_ROOT_PATH ${TOOLCHAIN_DIR})
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
SET(CMAKE_C_COMPILER ${TOOLCHAIN_DIR}/bin/arm-none-linux-gnueabi-gcc)
SET(CMAKE_CXX_COMPILER ${TOOLCHAIN_DIR}/bin/arm-none-linux-gnueabi-g++)
FIND_PROGRAM(APR_CONFIG_BIN NAMES apr-config apr-1-config PATHS /home/kevin/dependLib/apr/bin /usr/bin /usr/local/bin /usr/local/apr/bin/)
FIND_PROGRAM(APU_CONFIG_BIN NAMES apu-config apu-1-config PATHS /home/kevin/dependLib/apr-util/bin /usr/bin /usr/local/bin /usr/local/apr/bin/)
Ubuntu 32位下:
FIND_PROGRAM(APR_CONFIG_BIN NAMES apr-config apr-1-config PATHS /root/panda/PicoIPC-mqtt/oss/dependlib/dependlib-arm/apr/bin /usr/bin /usr/local/bin /usr/local/apr/bin/)
FIND_PROGRAM(APU_CONFIG_BIN NAMES apu-config apu-1-config PATHS /root/panda/PicoIPC-mqtt/oss/dependlib/dependlib-arm/apr-util/bin /usr/bin /usr/local/bin /usr/local/apr/bin/)
然后输入以下命令
cmake . -DCMAKE_INSTALL_PREFIX=/home/kevin/dependLib/oss_c_sdk -DCURL_INCLUDE_DIR=/home/kevin/dependLib/libcurl/include/ -DCURL_LIBRARY=/home/kevin/dependLib/libcurl/lib/libcurl.a -DAPR_INCLUDE_DIR=/home/kevin/dependLib/apr/include/apr-1 -DAPR_LIBRARY=/home/kevin/dependLib/apr/lib/libapr-1.a -DAPR_UTIL_INCLUDE_DIR=/home/kevin/dependLib/apr-util/include/apr-1 -DAPR_UTIL_LIBRARY=/home/kevin/dependLib/apr-util/lib/libaprutil-1.a -DMINIXML_INCLUDE_DIR=/home/kevin/dependLib/mxml/include/ -DMINIXML_LIBRARY=/home/kevin/dependLib/mxml/lib/libmxml.a
make,发现报错如下:
Ubuntu下生成oss sdk 的lib时:
cmake . -DCMAKE_INSTALL_PREFIX=/home/kevin/dependLib/oss_c_sdk -DCURL_INCLUDE_DIR=/usr/local/include -DCURL_LIBRARY=/usr/local/lib/libcurl.a -DAPR_INCLUDE_DIR=/usr/local/apr/include/apr-1 -DAPR_LIBRARY=/usr/local/apr/lib/libapr-1.a -DAPR_UTIL_INCLUDE_DIR=/usr/local/apr/include/apr-1 -DAPR_UTIL_LIBRARY=/usr/local/apr/lib/libaprutil-1.a -DMINIXML_INCLUDE_DIR=/usr/local/include -DMINIXML_LIBRARY=/usr/local/lib/libmxml.a –DMATH_LIBRARY=/home/kevin/dependLib/freescale/usr/local/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/arm-fsl-linux-gnueabi/multi-libs/usr/lib/libm.a –DM_LIBRARY=/home/kevin/dependLib/freescale/usr/local/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/arm-fsl-linux-gnueabi/multi-libs/usr/lib/libm.a –DPTHREAD_LIBRARY=/home/kevin/dependLib/freescale/usr/local/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/arm-fsl-linux-gnueabi/multi-libs/usr/lib/libpthread.a –DRT_LIBRARY=/home/kevin/dependLib/freescale/usr/local/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/arm-fsl-linux-gnueabi/multi-libs/usr/lib/librt.a
Ubuntu 32位下,交叉编译oss sdk的lib时:
修改CMakeList.txt
屏蔽最后两行
然后执行以下命令:
cmake . -DCMAKE_INSTALL_PREFIX=/root/panda/PicoIPC-mqtt/oss/dependlib/dependlib-arm /oss_c_sdk -DCURL_INCLUDE_DIR=/root/panda/PicoIPC-mqtt/oss/dependlib/dependlib-arm/libcurl/include -DCURL_LIBRARY=/root/panda/PicoIPC-mqtt/oss/dependlib/dependlib-arm/libcurl/lib/libcurl.a -DAPR_INCLUDE_DIR=/root/panda/PicoIPC-mqtt/oss/dependlib/dependlib-arm/apr/include/apr-1 -DAPR_LIBRARY=/root/panda/PicoIPC-mqtt/oss/dependlib/dependlib-arm/apr/lib/libapr-1.a -DAPR_UTIL_INCLUDE_DIR=/root/panda/PicoIPC-mqtt/oss/dependlib/dependlib-arm/apr-util /include/apr-1 -DAPR_UTIL_LIBRARY=/root/panda/PicoIPC-mqtt/oss/dependlib/dependlib-arm/apr-util/lib/libaprutil-1.a -DMINIXML_INCLUDE_DIR=/root/panda/PicoIPC-mqtt/oss/dependlib/dependlib-arm/mxml/include -DMINIXML_LIBRARY=/root/panda/PicoIPC-mqtt/oss/dependlib/dependlib-arm/mxml/lib/libmxml.a
6. oss_c_sdk-demo程序交叉编译
进入到oss-c-sdk-demo目录中,修改Makefile为
INCLUDES = -I. -I /root/panda/PicoIPC-mqtt/oss/dependlib/dependlib-arm/oss_c_sdk/include/oss_c_sdk -I /root/panda/PicoIPC-mqtt/oss/dependlib/dependlib-arm/expat/include -I /root/panda/PicoIPC-mqtt/oss/dependlib/dependlib-arm/libcurl/include -I /root/panda/PicoIPC-mqtt/oss/dependlib/dependlib-arm/apr/include/apr-1 -I /root/panda/PicoIPC-mqtt/oss/dependlib/dependlib-arm/apr-util/include/apr-1 -I /root/panda/PicoIPC-mqtt/oss/dependlib/dependlib-arm/mxml/include
SRCS = main.c
OBJS = $(SRCS:.c=.o)
CC = arm-fsl-linux-gnueabi-gcc
CFLAGS = -Wall -O -g
LDFLAGS := -L /root/panda/PicoIPC-mqtt/oss/dependlib/dependlib-arm/oss_c_sdk/lib -L /root/panda/PicoIPC-mqtt/oss/dependlib/dependlib-arm/expat/lib -L /root/panda/PicoIPC-mqtt/oss/dependlib/dependlib-arm/libcurl/lib -L /root/panda/PicoIPC-mqtt/oss/dependlib/dependlib-arm/apr/lib -L /root/panda/PicoIPC-mqtt/oss/dependlib/dependlib-arm/apr-util/lib -L /root/panda/PicoIPC-mqtt/oss/dependlib/dependlib-arm/mxml/lib
LDFLAGS += -lpthrad -loss_c_sdk -lcurl -lmxml -lapr-1 -lexpat -laprutil-1
#LIBS = -lpthread -loss_c_sdk -lcurl -lmxml -lapr-1 -laprutil-1
EXE = main
$(EXE):$(OBJS)
$(CC) $^ -o [email protected] $(LDFLAGS)
%.o: %.c
$(CC) $(CFLAGS) $(INCLUDES) -c $< -o [email protected]
clean:
rm -f $(EXE) $(OBJS)
将交叉编译生成的库拷贝到ControllerMain的/usr/lib目录中,注意名称要改成下列名称:
liboss_c_sdk.so.3.0.0
libcurl.so.4
libmxml.so.1
libapr-1.so.0
libexpat.so.1
libaprutil-1.so.0
如果拷贝这些库的话,在ControllerMain中执行oss的demo程序时,会报错:cannot open shared object file: No such file or directory
如果在ControllerMain中运行程序是出现如下错误:
put object from buffer failed
put object from file failed, code:403, error_code:RequestTimeTooSkewed, error_msg:The difference between the request time and the current time is too large., request_id:5AC983F72F08FBB69F72F8BB
get object to buffer failed
get object to local file failed
需要将系统时间设定为北京时间减去8小时,因为ControllerMain使用的是UTC时间,北京时间为UTC+8时区的时间。
设置系统时间的命令:
date 2018.04.08-03:03:00
hwclock -w
hwclock -r
原文地址:https://www.cnblogs.com/wangkevin5626/p/9183287.html