shafreeck / cetcd

Cetcd is a C client library for etcd with full features support
Apache License 2.0
69 stars 39 forks source link

Compile error #30

Closed dennisip86 closed 8 years ago

dennisip86 commented 8 years ago

Hi: I use gcc 4.8.5 to compile example but i got this error:

cetcd-test.cpp:15:59: error: invalid conversion from ‘const void’ to ‘void’ [-fpermissive] cetcd_array_append(&addrs, "http://192.168.4.247:2379");

shafreeck commented 8 years ago

@dennisip86 There is no file called etcd-test.cpp in examples, Is this your own code ?

The errors told that you can not convert from const void to void, you can convert it explicitly

cetcd_array_append(&addrs, (void) "http://192.168.4.247:2379")

or add -fpermissive when compiles

dennisip86 commented 8 years ago

@shafreeck cetcd-test.cpp is my own code as same as cetcd_get.c

I convert it explicitly: cetcd_array_append(&addrs, (void *)"http://192.168.4.247:2379");

But i got the other link error: g++ -o cetcd-test cetcd-test.cpp -lcetcd

cetcd-test.cpp:(.text+0x18): undefined reference to cetcd_array_init(cetcd_array_t*, unsigned long)' cetcd-test.cpp:(.text+0x29): undefined reference tocetcd_array_append(cetcd_arrayt, void_)' cetcd-test.cpp:(.text+0x3a): undefined reference to cetcd_array_append(cetcd_array_t*, void*)' cetcd-test.cpp:(.text+0x4b): undefined reference tocetcd_array_append(cetcd_arrayt, void_)' cetcd-test.cpp:(.text+0x61): undefined reference to cetcd_client_init(cetcd_client_t*, cetcd_array_t*)' cetcd-test.cpp:(.text+0x75): undefined reference tocetcd_get(cetcd_clientt, char const_)' cetcd-test.cpp:(.text+0xc1): undefined reference to cetcd_response_print(cetcd_reponse_t*)' cetcd-test.cpp:(.text+0xcd): undefined reference tocetcd_response_release(cetcd_reponset)' cetcd-test.cpp:(.text+0xd9): undefined reference to cetcd_array_destroy(cetcd_array_t_)' cetcd-test.cpp:(.text+0xe8): undefined reference tocetcd_client_destroy(cetcd_client_t*)'

gcc -o cetcd-test cetcd-test.c -lcetcd Every thing is ok.

shafreeck commented 8 years ago

@dennisip86 This is because g++ can not correctly link to libetcd.so. Now fixed. Thanks very much for your feedback!