Closed gfxcc closed 8 years ago
You specified incorrect path to lib. Shall be:
$ gcc -lcapn -L /usr/local/lib/capn t.c
I tried your command. It show the same error like mine. I do not think the lib path is incorrect. I install capn on my mac os X like ---$brew install libcapn And i can compile on mac like ------$gcc /usr/local/lib/capn/libcapn.dylib t.c
Help me out~~ Thanks
It's my error in command, try:
$ gcc t.c -lcapn -L /usr/local/lib/capn
New command works !!! Thank you. But I meet a new Problem
At begin ./a.out ./a.out: error while loading shared libraries: libcapn.so.1: cannot open shared object file: No such file or directory I run $ldconfig and problem solved. No error printed. But my iPhone does not receive notification.
With the same code on Mac os X, my iPhone can receive notification. I can sure the token is correct and PEM is fight. (cause if I change path for .pem. It will show error message like ----Could not connected to Apple Push Notification Servece: unable to use specified SSL certificate (12))
How to solve this problem? Thanks very much!
Without seeing a code it is very difficult to speak about a possible problem. The current version also doesn't support logging. I would recommend to you to try version 2.0.0, it support logging and working faster. Look it https://github.com/adobkin/libcapn/tree/experimental. This branch is EXPERIMENTAL and it not compatible to 1.0. Experimental branch will be merged with master soon
I remove /usr/local/lib/capn/* /usr/local/include/capn/*
installd version 2.0.0 copy your simple code. something like this happened ubuntu@ip-172-31-17-20:~/libcapn/test$ gcc t.c -lcapn -L /usr/lib/capn t.c: In function ‘main’: t.c:18:9: error: variable ‘payload’ has initializer but incomplete type apn_payload_t payload = NULL; ^ t.c:18:23: error: storage size of ‘payload’ isn’t known apn_payload_t payload = NULL; ^ t.c:19:9: error: variable ‘ctx’ has initializer but incomplete type apn_ctx_t ctx = NULL; ^ t.c:19:19: error: storage size of ‘ctx’ isn’t known apn_ctx_t ctx = NULL; ^ t.c:52:9: error: variable ‘tokens’ has initializer but incomplete type apn_array_t tokens = apn_array_init(2, NULL, NULL); ^ t.c:52:21: error: storage size of ‘tokens’ isn’t known apn_array_t tokens = apn_array_init(2, NULL, NULL); ^
In example I lost asterisks. I fixed it and I added example tohttps://github.com/adobkin/libcapn/tree/experimental/examples. Try it
$$$$~/libcapn/libcapn/examples$ gcc send_push_message.c -lcapn -L/usr/lib/capn send_push_message.c: In function ‘main’: send_push_message.c:74:41: error: ‘APN_ARRAY_ITERATOR_REVERSE’ undeclared (first use in this function) for(apn_array_set_direction(tokens, APN_ARRAY_ITERATOR_REVERSE); apn_array_has_prev(tokens) == 1; apn_array_prev(tokens)) { ^ send_push_message.c:74:41: note: each undeclared identifier is reported only once for each function it appears in send_push_message.c:75:23: warning: initialization makes pointer from integer without a cast [enabled by default] char *token = apn_array_current_item(tokens); ^
send_push_message.c:74:41: error: ‘APN_ARRAY_ITERATOR_REVERSE’ undeclared (first use in this
fixed
Success! Segmentation fault (core dumped)
did send the notification. Thanks~ Looking forward to your libcapn2
This lib can run on my Mac OS 10.10 But when I test same code on Ubuntu, It goes wrong. I followed steps http://libcapn.org/doc/0.9.0/html/install.html I have spend all my night on this.