1

This is main.c file I am trying to work with influxdb library I hope I installed it clearly with my knowledge here are the screen shots of library enter image description here
This is linked library

enter image description here
This is the path of the library

This is the code file

#include <influxdb/influxdb.h>

int main() {
    int status;
    s_influxdb_client *client = influxdb_client_new("xxxxxxxxxx", "influxdb", "xxxxxxxxxxxxxx", "", 0);

    status = influxdb_create_database(client, "toto");

    influxdb_client_free(client);

    return status != 201;
}

This is how I executing the command in gcc to compile and run

gcc -I/usr/local/include/ -L/usr/local/lib -linfluxdb -o john john.c  

Even though I included the library it raising undefined reference This is what my error is

/tmp/cce9K1Kh.o: In function `main':
john.c:(.text+0x23): undefined reference to `influxdb_client_new'
john.c:(.text+0x38): undefined reference to `influxdb_create_database'
john.c:(.text+0x47): undefined reference to `influxdb_client_free'
collect2: error: ld returned 1 exit status    

This is where I found library and Followed the instructions in Read Me file Everything is performed smooth Influxdb

Please let me know if you need more information

GShaik
  • 197
  • 1
  • 17
Ankanna
  • 737
  • 2
  • 8
  • 21

1 Answers1

0

The influxdb README.md is b0rken. Ordering of command-line arguments to gcc (or the linker actually) matters; the -linfluxdb must come after your john.c on the command line.

Thus, try compiling/linking with with

gcc -I/usr/local/include/ -L/usr/local/lib -o john john.c -linfluxdb 
Community
  • 1
  • 1
  • 1
    Successfully compiled but when I execute `./john` it is raising following exception `./john: error while loading shared libraries: libinfluxdb.so.0: cannot open shared object file: No such file or directory` – Ankanna Apr 12 '16 at 00:08
  • can u suggest me alternate for influxdb – Ankanna Apr 12 '16 at 00:10
  • it asked me for including the `-lcurl` so i edited your answer for just small change – Ankanna Apr 12 '16 at 00:12