Xively C库与ubuntu eclipse(gcc / g ++)32位交叉编译应用程序连接

时间:2013-09-12 15:27:22

标签: eclipse ubuntu xively beagleboneblack

我优化了我的ubuntu 13.04运行64位机器以交叉编译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 examples

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 ****

1 个答案:

答案 0 :(得分:1)

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

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

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
    
  5. 您现在可以尝试将 xively_static_test 可执行文件复制到目标设备的文件系统并执行它,这不会产生任何输出,因为它是一个测试示例。不,你可以扩展上面的例子来提供你想要的功能!