linux - Apache Avro C Installation -



linux - Apache Avro C Installation -

i working on project , using apache avro. have downloaded apache avro c , followed instructions provided in order install on scheme (ubuntu linux v14.04). after installation, have header files under /include directory , libraries under /lib directory. of ones installed apache avro.

at point, have created c source files follows:

1) socket_client.h :

#include <stdio.h> #include <sys/socket.h> #include <netinet/in.h> #include "avro.h" #include <errno.h> #include <stdint.h> #ifndef socket_client_h_ #define socket_client_h_ void init_schema(void); int client_execution_connect(char* ip_addr, int port, char* type); #endif /* socket_client_h_ */

2) socket_client.c :

#include <stdio.h> #include "socket_client.h" avro_schema_t bigpeer_schema; void init_schema(void) { if( avro_schema_from_json_literal(big_peer_schema, &bigpeer_schema) ) { printf("unable parse big_peer schema"); exit(exit_failure); } } int client_execution_connect(char* ip_addr, int port, char* type) { ... }

and test main file. also, have created next makefile compile code:

cc=gcc cflags=-c -wall ldflags= sources=test_main.c socket_client.c objects=$(sources:.c=.o) executable=avro_test inc_path=/include/avro/ inc=-i/include lib=-l/lib all: $(sources) $(executable) $(executable): $(objects) $(cc) $(ldflags) $(lib) $(objects) -o $@ .c.o: $(cc) $(inc) $(cflags) $< -o $@ clean: rm -rf *.o avro_test

but, when seek create application, following:

nick@rethimno:~/downloads/avroclient$ create gcc -i/include -c -wall test_main.c -o test_main.o test_main.c: in function ‘main’: test_main.c:22:6: warning: unused variable ‘port’ [-wunused-variable] int port = atoi(argv[2]); ^ test_main.c:15:8: warning: unused variable ‘type’ [-wunused-variable] char* type = "db_node"; ^ gcc -i/include -c -wall socket_client.c -o socket_client.o gcc -l/lib test_main.o socket_client.o -o avro_test socket_client.o: in function `init_schema': socket_client.c:(.text+0x14): undefined reference `avro_schema_from_json_length' collect2: error: ld returned 1 exit status make: *** [avro_test] error 1

what doing wrong? not quite if libraries of apache avro loaded properly.

thank you, nick

you including avro headers, aren't linking final executable against avro libraries. assuming have libavro.so or libavro.a in lib directory (where *.so shared library, , *.a static library), want alter line of makefile:

ldflags=-lavro

note that, if library binary called other libavro.so or libavro.a, you'll need alter -lavro value match. note packages can contain more 1 shared library need link against. not familiar plenty apache avro whether or not case; need , see within lib directory.

you can more info linking libraries in gcc documentation.

c linux gcc avro

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -