相关文章推荐
谈吐大方的山楂  ·  Python Elasticsearch ...·  5 月前    · 
风流倜傥的佛珠  ·  [图像]用edge ...·  11 月前    · 
奔放的黄瓜  ·  html - Adding options ...·  11 月前    · 

如果您编译SDK是在一台安装了32位Linux 的机器上,那么参考“目标系统为64为Linux”文档,即可得到32位的库和例程。

如果您是在安装了64位 Ubuntu16.04 的机器上,需要编译出32位的库,请按照下文操作

sudo apt-get install -y libc6:i386 libstdC++6:i386 gcc:i386
        

修改平台配置文件

vim src/board/config.ubuntu.x86
        

增加如下一行

CONFIG_ENV_CFLAGS   += -m32
        

比如:

cat src/board/config.ubuntu.x86
CONFIG_ENV_CFLAGS   += \
    -Os -Wall \
    -g3 --coverage \
    -D_PLATFORM_IS_LINUX_ \
    -D__UBUNTU_SDK_DEMO__ \
CONFIG_ENV_LDFLAGS  += -lpthread -lrt
CONFIG_ENV_LDFLAGS  += -m32
OVERRIDE_STRIP      := strip
        

选择平台配置

make reconfig
SELECT A CONFIGURATION:
1) config.macos.make    3) config.ubuntu.x86
2) config.rhino.make    4) config.win7.mingw32
        

编译

make
        

获取二进制库

cd output/release/lib
        

其中有三个主要产物, 它们都是32位架构的

可以用如下方式验证,注意 file 命令的输出中,已经显示程序都是32位的了( ELF 32-bit LSB executable )。

file output/release/bin/*
output/release/bin/linkkit-example-countdown: ELF 32-bit LSB executable, Intel 80386, ... stripped
output/release/bin/linkkit-example-sched:     ELF 32-bit LSB executable, Intel 80386, ... stripped
output/release/bin/linkkit-example-solo:      ELF 32-bit LSB executable, Intel 80386, ... stripped
output/release/bin/linkkit_tsl_convert:       ELF 32-bit LSB executable, Intel 80386, ... stripped
output/release/bin/mqtt-example:              ELF 32-bit LSB executable, Intel 80386, ... stripped
output/release/bin/mqtt-example-multithread:  ELF 32-bit LSB executable, Intel 80386, ... stripped
output/release/bin/mqtt-example-rrpc:         ELF 32-bit LSB executable, Intel 80386, ... stripped
output/release/bin/ota-example-mqtt:          ELF 32-bit LSB executable, Intel 80386, ... stripped
output/release/bin/sdk-testsuites:            ELF 32-bit LSB executable, Intel 80386, ... stripped
output/release/bin/uota_app-example:          ELF 32-bit LSB executable, Intel 80386, ... stripped
                  

使用cmake方式编译

修改CMakeLists.txt 文件

在默认的文件中修改CFLAGS,加入-m32

SET (CMAKE\_C\_FLAGS " -Iexamples -Os -Wall")
            

改成

SET (CMAKE\_C\_FLAGS " -Iexamples -Os -Wall -m32")
                  

从CMakeLists.txt构建makefile

mkdir ooo
cd ooo
cmake ..
                  

编译

make -j32
                  

产物

~/srcs/iotx-sdk-c/ooo\$ ls
bin  CMakeCache.txt  CMakeFiles  cmake\_install.cmake  examples  lib  Makefile  src  tests
            

可执行程序在bin/ 目录下:

ls bin/
linkkit-example-countdown  linkkit-example-sched  linkkit-example-solo  linkkit\_tsl\_convert
mqtt-example  mqtt\_example\_multithread  mqtt\_example\_rrpc  ota-example-mqtt  uota\_app-example
            

可以用如下方式验证,注意file命令的输出中,已经显示程序都是32位的了(ELF 32-bit LSB executable)。

file ooo/bin/\*
ooo/bin/linkkit-example-countdown: ELF 32-bit LSB executable, Intel 80386, ... stripped
ooo/bin/linkkit-example-sched:     ELF 32-bit LSB executable, Intel 80386, ... stripped
ooo/bin/linkkit-example-solo:      ELF 32-bit LSB executable, Intel 80386, ... stripped
ooo/bin/linkkit\_tsl\_convert:       ELF 32-bit LSB executable, Intel 80386, ... stripped
ooo/bin/mqtt-example:              ELF 32-bit LSB executable, Intel 80386, ... stripped
ooo/bin/mqtt-example-multithread:  ELF 32-bit LSB executable, Intel 80386, ... stripped
ooo/bin/mqtt-example-rrpc:         ELF 32-bit LSB executable, Intel 80386, ... stripped
ooo/bin/ota-example-mqtt:          ELF 32-bit LSB executable, Intel 80386, ... stripped
ooo/bin/sdk-testsuites:            ELF 32-bit LSB executable, Intel 80386, ... stripped
ooo/bin/uota\_app-example:          ELF 32-bit LSB executable, Intel 80386, ... stripped
            

二进制库在lib/ 目录下:

ls lib/
libiot\_hal.so  libiot\_sdk.so  libiot\_tls.so