0

我已经优化了运行 64 位机器的 ubuntu 13.04 以针对 32 位 ARM 进行交叉编译,并通过开发 c/c++ 代码进行检查,该代码在 32 位 ARM(BBBlack) 上成功运行现在我想要实现的是与 Xively 服务器更新的连接并从数据流中检索提要/数据点。

所以我正在考虑利用 Xively 的 c 库在我的 Ubuntu eclipse 开发环境中使用 它会工作吗?

会有交叉编译问题吗?还是一切都好?

以下是我运行时得到的结果 >> make -C src CC=arm-linux-eabi-gcc AR=arm-linux-eabi-gcc 示例

make: *** src: No such file or directory.  Stop.
nishant@Nishant-K53SC:~$ cd libxively
nishant@Nishant-K53SC:~/libxively$ make -C src CC=arm-linux-eabi-gcc AR=arm-linux-eabi-gcc libxively
make: Entering directory `/home/nishant/libxively/src'
make -C libxively
make[1]: Entering directory `/home/nishant/libxively/src/libxively'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/home/nishant/libxively/src/libxively'
make: Leaving directory `/home/nishant/libxively/src'
nishant@Nishant-K53SC:~/libxively$ make -C src CC=arm-linux-eabi-gcc AR=arm-linux-eabi-gcc libxively
make: Entering directory `/home/nishant/libxively/src'
make -C libxively
make[1]: Entering directory `/home/nishant/libxively/src/libxively'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/home/nishant/libxively/src/libxively'
make: Leaving directory `/home/nishant/libxively/src'
nishant@Nishant-K53SC:~/libxively$ make -C src CC=arm-linux-eabi-gcc AR=arm-linux-eabi-gcc examples
make: Entering directory `/home/nishant/libxively/src'
make -C examples
make[1]: Entering directory `/home/nishant/libxively/src/examples'
for dir in datapoint_delete datapoint_delete_range datastream_create datastream_delete datastream_get datastream_update feed_get feed_update; do (make -C $dir) || exit 1; done
make[2]: Entering directory `/home/nishant/libxively/src/examples/datapoint_delete'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/home/nishant/libxively/src/examples/datapoint_delete'
make[2]: Entering directory `/home/nishant/libxively/src/examples/datapoint_delete_range'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/home/nishant/libxively/src/examples/datapoint_delete_range'
make[2]: Entering directory `/home/nishant/libxively/src/examples/datastream_create'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/home/nishant/libxively/src/examples/datastream_create'
make[2]: Entering directory `/home/nishant/libxively/src/examples/datastream_delete'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/home/nishant/libxively/src/examples/datastream_delete'
make[2]: Entering directory `/home/nishant/libxively/src/examples/datastream_get'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/home/nishant/libxively/src/examples/datastream_get'
make[2]: Entering directory `/home/nishant/libxively/src/examples/datastream_update'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/home/nishant/libxively/src/examples/datastream_update'
make[2]: Entering directory `/home/nishant/libxively/src/examples/feed_get'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/home/nishant/libxively/src/examples/feed_get'
make[2]: Entering directory `/home/nishant/libxively/src/examples/feed_update'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/home/nishant/libxively/src/examples/feed_update'
make[1]: Leaving directory `/home/nishant/libxively/src/examples'
make: Leaving directory `/home/nishant/libxively/src'

使用库构建时更新错误:

为项目测试构建配置调试**

make all 
Building file: ../src/Test.cpp
Invoking: GCC C++ Compiler
arm-linux-gnueabi-g++ -I/usr/arm-linux-gnueabi/include/c++/4.7.3 -I/home/nishant/libxively/src/libxively -I/usr/arm-linux-gnueabi/include/c++/4.7.3/bits -I/usr/arm-linux-gnueabi/include/c++/4.7.3/ext -I/usr/arm-linux-gnueabi/include/c++/4.7.3/arm-linux-gnueabi -I/usr/arm-linux-gnueabi/include/c++/4.7.3/backward -I/usr/arm-linux-gnueabi/include/c++/4.7.3/decimal -includexively.h -includexi_helpers.h -includexi_err.h -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/Test.d" -MT"src/Test.d" -o "src/Test.o" "../src/Test.cpp"
/home/nishant/workspace/Test/src/libxively.a: could not read symbols: File format not recognized
Finished building: ../src/Test.cpp

collect2: error: ld returned 1 exit status
Building target: Test
make: *** [Test] Error 1
Invoking: GCC C++ Linker
arm-linux-gnueabi-g++ -L/home/nishant/workspace/Test/src -L/usr/arm-linux-gnueabi/lib -o "Test"  ./src/Test.o   -lxively

**** Build Finished ****
4

1 回答 1

1

Xively C 库应该适用于任何 32 位和 64 位 POSIX 操作系统以及带有 lwIP 的各种 RTOS。

要使用 交叉编译库arm-linux-eabi-gcc,您需要在顶层目录中运行以下命令:

make -C src CC=arm-linux-eabi-gcc AR=arm-linux-eabi-gcc libxively
make -C src CC=arm-linux-eabi-gcc AR=arm-linux-eabi-gcc examples

详细说明

下面我将描述如何编译一个简单的示例 C 程序并将其与 Xively 库静态链接。这应该提供足够的背景信息。虽然,我无法提供有关如何修复 Eclipse IDE 的信息,因为我怀疑这是可能的。

  1. 创建目录并克隆库:

    mkdir hello_xively
    cd hello_xively
    git clone --recursive https://github.com/xively/libxively
    
  2. 现在添加test.c文件,如图所示:

    #include "xively.h"
    
    int main() {
    
      xi_context_t* ctx = xi_create_context( XI_HTTP, "DUMMY_API_KEY_STRING", 123 );
      xi_delete_context( ctx );
      return 0;
    };
    
  3. 构建库本身(请注意,CCAR的目标的值可能不同)

    export CC=arm-linux-eabi-gcc  # C compiler fron-end for the ARM Linux target
    export AR=arm-linux-eabi-ar   # This is needed for the build to work
    export XI=`pwd`/libxively.a   # To store the output in current direcory
    make -C libxively/src libxively
    
  4. 编译test.c并将其与静态库链接:

    $CC test.c \
      -I./libxively/src/libxively \
      libxively.a -o xively_static_test
    

您现在可以尝试将xively_static_test可执行文件复制到目标设备的文件系统并执行它,这应该不会产生任何输出,因为它是一个测试示例。不,您可以扩展上面的示例以提供您想要的功能!

于 2013-09-12T16:43:09.133 回答