We are having a problem getting libxively working on our Raspberry Pi. We're programming in C with Geany, and want to get xively to work.But we are getting numerous errors. We followed several tutorials but couldn't figure out what's wrong.
Here is part of our main.c. We do have the feedID and API key in our code, of course.
#include </home/pi/libxively/src/libxively/xively.h>
#include </home/pi/libxively/src/libxively/xi_helpers.h>
#include </home/pi/libxively/src/libxively/xi_err.h>
#include <stdio.h>
#include <string.h>
#define XI_FEED_ID ---// set Xively Feed ID (numerical, no quoutes
#define XI_API_KEY "---" // set Xively API key (double-quoted string)
int xively();
int main(int argc, char **argv)
{xively();}
int xively()
{
xi_feed_t feed;
memset( &feed, NULL, sizeof( xi_feed_t ) );
feed.feed_id = XI_FEED_ID;
feed.datastream_count = 2;
feed.datastreams[0].datapoint_count = 1;
xi_datastream_t* foo_datastream = &feed.datastreams[0];
strcpy( foo_datastream->datastream_id, "foo" );
xi_datapoint_t* current_foo = &foo_datastream->datapoints[0];
feed.datastreams[1].datapoint_count = 1;
xi_datastream_t* bar_datastream = &feed.datastreams[1];
strcpy( bar_datastream->datastream_id, "bar" );
xi_datapoint_t* current_bar = &bar_datastream->datapoints[0];
// create the xively library context
xi_context_t* xi_context
= xi_create_context( XI_HTTP, XI_API_KEY, feed.feed_id );
// check if everything works
if( xi_context == NULL )
{
return -1;
}
xi_set_value_str( current_bar, "unknown" );
xi_set_value_f32( current_foo, 0.123 );
xi_feed_update(xi_context, &feed);
return 0;
}
We think something is wrong with the makefile, so here you go:
#This sample makefile has been setup for a project which contains the following files: main
#Change output_file_name.a to your desired executable filename
#Set all your object files (the object files of all the .c files in yourproject, e.g. main
OBJ = main.o
#Set any dependant header files so that if they are edited they cause a complete re-compile
DEPS = main.h
#Any special libraries you are using in your project
LIBS = -lrt -lwiringPi -L$(HOME)/pi/libxively/src/libxively -L/root/libxively/src/libxively -dxively
#we did try -lxively but that didn't work either
#Set any compiler flags you want to use
CFLAGS = -lrt
#Set the compiler you are using ( gcc for C or g++ for C++ )
CC = gcc
#Set the filename extension of your C files
EXTENSION = .c
#Define a rule that applies to all files ending in the .o suffix, which says ...
%.o: %$(EXTENSION) $(DEPS)
$(CC) -c -o $@ $< $(CFLAGS)
#Combine them into the outputfile
#Set your desired exe output filename here
sensortest.a: $(OBJ)
$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
#Cleanup
.PHONY: clean
clean:
srm -f *.o *~ core *~
When we compile it we get the following errors: