0

I have optimised my ubuntu 13.04 running 64-bit machine to cross-compile for 32bit ARM and checked by developing c/c++ code the code is successfully running on 32bit ARM(BBBlack) NOW what I want to achieve is connectivity with the Xively server's updating and retrieving feeds/datapoints from datastreams.

So I'm thinking to utilise the c library from Xively to use in my Ubuntu eclipse development environment will it work?

Will there be any crosscompilation problem's? or Is it all fine?

The following is what I'm getting when I run >> 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'

UPDATES ERRORS WHILE BUILDING WITH LIBRARy:

Build of configuration Debug for project Test **

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 ****
Naaz
  • 273
  • 2
  • 6
  • 21

1 Answers1

1

Xively C library should work on any 32-bit and 64-bit POSIX OS as well as various RTOS with lwIP.

To cross compile the library using arm-linux-eabi-gcc, you need to run the following command in the toplevel directory:

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

Detailed instructions

Below I will describe how to compile a simple example C program and statically link it with Xively library. This should provide enough background information. Although, I cannot provide information on how to fix Eclipse IDE as I doubt it's possible.

  1. Create a directory and clone the library:

    mkdir hello_xively
    cd hello_xively
    git clone --recursive https://github.com/xively/libxively
    
  2. Add the test.c file now as shown:

    #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. Build the library itself (please note that CC and AR values for your target may differ):

    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. Compile test.c and link it with the static library:

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

You now can try copying the xively_static_test executable to the target device's filesystem and execute it, which should produce no output as it's a test example. No you can extend the above example to provide functionality you desire!

errordeveloper
  • 6,716
  • 6
  • 41
  • 54
  • so I just need to do this once and for all and this Xively C library is configured ? and add it to the linux in the coneventional way? – Naaz Sep 12 '13 at 18:13
  • 1
    Well, if you don't make changes to the library, then you shouldn't need to rebuild it. Otherwise you would need to teach your IDE that this is part of clean build. – errordeveloper Sep 13 '13 at 06:03
  • 1
    So normally you'd want to make your IDE link to a static library, which you will find under `libxively/src/obj/libxively.a`. – errordeveloper Sep 13 '13 at 06:04
  • I mean what kind of library have .a extension in C? – Naaz Sep 13 '13 at 06:10
  • I ran the both make -C src CC=arm-linux-eabi-gcc AR=arm-linux-eabi-gcc libxively and make -C src CC=arm-linux-eabi-gcc AR=arm-linux-eabi-gcc examples but it feels like its already done what these statements are suppose to do as I ran "make all" while being in the libxively directory ,**I'HVE ADDED THE RETURN PROMPT ABOVE** – Naaz Sep 13 '13 at 09:25
  • I added the static library within the src folder a simple drag and drop then provided its path on the GCC C++ linker and added the includes in the GCC C++ in under properties>c++ Build> settings – Naaz Sep 13 '13 at 12:24
  • Ok all done BUT while building I get the UPDATED ABOVE ERRORS – Naaz Sep 13 '13 at 13:15
  • There is no point of panicking, perhaps you should go back one step and try to understand how linking static libraries works. I would suggest you try building a simple executable by hand, see my updated answer. – errordeveloper Sep 13 '13 at 14:11
  • The includes now work and I think my library linking is just as fine as it should be, I HAVE ALREADY TESTED the machine with a simple c executable and it works so all related to c/c++ addons etc works now I have added a datastream example that I want to make work – Naaz Sep 13 '13 at 14:14
  • Dude, I just finished writing it. Refresh the page please. – errordeveloper Sep 13 '13 at 14:35
  • If you are in doubt about the next step, please do not update this question and post an new one instead. – errordeveloper Sep 13 '13 at 14:37
  • One very small question im getting undefined reference to `xi_create_context' and undefined reference to `xi_delete_context' I think its generating because of this XI_HTTP , – Naaz Sep 13 '13 at 15:42
  • Did you follow the command-line instructions or you are getting this error from the IDE? – errordeveloper Sep 13 '13 at 15:51
  • the function in the xively.h which is being filled with parameters and called goes like this: **typedef enum { /** `http://api.xively.com` */ XI_HTTP, /** `https://api.xively.com` */ XI_HTTPS, /** `telnet api.xively.com 8081` */ XI_TCP, /** `openssl s_client -host api.xively.com -port 8091 -tls1` */ XI_TCPS, /** `ws://api.xively.com:8080` */ XI_WS, /** `wss://api.xively.com:8090` */ XI_WSS, } xi_protocol_t; ** several urls are commented out! – Naaz Sep 13 '13 at 16:03
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/37351/discussion-between-naaz-and-errordeveloper) – Naaz Sep 13 '13 at 16:19