基於freescale i.Mx6(ARM)的阿里雲oss調試記錄

交叉編譯阿里OSS調試記錄

1.1 開通oss服務

具體參考如下連接:html

https://help.aliyun.com/document_detail/31884.html?spm=a2c4g.11186623.6.558.n2g1UAnode

 

1.2 SDK安裝

在ubuntu下安裝,安裝步驟以下:linux

  • 安裝CMake

執行如下命令安裝CMake。git

sudo apt-get install cmake
  • 安裝第三方庫

執行如下命令安裝第三方庫。github

sudo apt-get install libcurl4-openssl-dev libapr1-dev libaprutil1-dev libmxml-dev

 

下載oss sdk,連接爲:apache

https://github.com/aliyun/aliyun-oss-c-sdkubuntu

 

編譯安裝OSS C SDK緩存

典型的編譯命令以下:網絡

1.  cmake .
2.  make
3.  make install

注意:curl

  • 執行cmake . 時默認會到/usr/local/下面去尋找curlaprapr-utilmxml的頭文件和庫文件。
  • 默認編譯是Debug類型,能夠指定如下幾種編譯類型: Debug, Release, RelWithDebInfoMinSizeRel,若是要使用release類型編譯,則執行cmake -f CMakeLists.txt -DCMAKE_BUILD_TYPE=Release
  • 若是您在安裝curlaprapr-utilmxml時指定了安裝目錄,則須要在執行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程序,連接爲:

http://docs-aliyun.cn-hangzhou.oss.aliyun-inc.com/assets/attach/32132/cn_zh/1487730555529/aliyun-oss-c-sdk-demo.tar.gz?spm=a2c4g.11186623.2.14.ljDN1R&file=aliyun-oss-c-sdk-demo.tar.gz

 

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

發現報錯

 

 

 

那是由於目標程序須要依賴庫

一、首先打開/etc/ld.so.conf文件

二、加入動態庫文件所在的目錄:執行vi /etc/ld.so.conf,在"include ld.so.conf.d/*.conf"下方增長"/usr/local/lib"。

三、保存後,在命令行終端執行:/sbin/ldconfig -v;其做用是將文件/etc/ld.so.conf列出的路徑下的庫文件緩存到/etc/ld.so.cache以供使用,所以當安裝完一些庫文件,或者修改/etc/ld.so.conf增長了庫的新搜索路徑,須要運行一下ldconfig,使全部的庫文件都被緩存到文件/etc/ld.so.cache中,若是沒作,可能會找不到剛安裝的庫。

參考連接:

http://www.javashuo.com/article/p-vmnfjmdm-u.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" 這個地方,用#註釋掉,而後就能夠了

 

 

參考連接:http://www.javashuo.com/article/p-sgeswrpa-dh.html

 

繼續./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交叉編譯

參考連接:

http://docs-aliyun.cn-hangzhou.oss.aliyun-inc.com/pdf/oss-sdk-intl-zh-2018-03-14.pdf?spm=a3c0i.o32169zh.a3.13.26855ac5zpO1jp&file=oss-sdk-intl-zh-2018-03-14.pdf

 

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 $@ $(LDFLAGS)

 

%.o: %.c

         $(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@

 

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

相關文章
相關標籤/搜索