简体   繁体   中英

Can't make: implicit declaration of function ‘http_write_chunked’

I'm trying to compile demo main file (https post with the chunked-encoding data) from github repo using, I have installed libghc-iproute-dev and libnl3.

gcc -o main -Imbedtls/include -fPIC -DHAVE_CONFIG_H -D_U_="attribute((unused))" main.c -O2 mbedtls/library/libmbedx509.a mbedtls/library/libmbedtls.a mbedtls/library/libmbedcrypto.a

I can't compile porgram, here is what I got:

main.c: In function ‘main’:
main.c:133:8: warning: implicit declaration of function ‘http_open_chunked’; did you mean ‘http_read_chunked’? [-Wimplicit-function-declaration]
if(http_open_chunked(&hi2, url) == 0)
^~~~~~~~~~~~~~~~~
http_read_chunked
main.c:137:12: warning: implicit declaration of function ‘http_write_chunked’; did you mean ‘http_read_chunked’? [-Wimplicit-function-declaration]
if(http_write_chunked(&hi2, data, size) != size)
^~~~~~~~~~~~~~~~~~
http_read_chunked
/tmp/cc7m6wMn.o: In function main': main.c:(.text.startup+0x3b): undefined reference to http_init'
main.c:(.text.startup+0x48): undefined reference to http_init' main.c:(.text.startup+0x59): undefined reference to http_open_chunked'
main.c:(.text.startup+0x9e): undefined reference to http_write_chunked' main.c:(.text.startup+0xd3): undefined reference to http_write_chunked'
main.c:(.text.startup+0x120): undefined reference to http_write_chunked' main.c:(.text.startup+0x139): undefined reference to http_strerror'
main.c:(.text.startup+0x157): undefined reference to http_close' main.c:(.text.startup+0x15f): undefined reference to http_close'
main.c:(.text.startup+0x19c): undefine

d reference to `http_read_chunked'
collect2: error: ld returned 1 exit status

I also tried to include netlink libraries, using:

#include <asm/types.h>
#include <linux/netlink.h>
#include <linux/rtnetlink.h>

And try to compile using the line:

gcc -o main -fPIC -DHAVE_CONFIG_H -D_U_="attribute((unused))" -O2 -I/usr/include/libnl3/netlink/ -Imbedtls/include main.c ApiService.c mbedtls/library/libmbedx509.a mbedtls/library/libmbedtls.a mbedtls/library/libmbedcrypto.a

Then I got:

ApiService.c:17:8: warning: implicit declaration of function ‘http_open_chunked’; did you mean ‘http_read_chunked’? [-Wimplicit-function-declaration]
if(http_open_chunked(&hi2, url) == 0)
^~~~~~~~~~~~~~~~~
http_read_chunked
ApiService.c:21:12: warning: implicit declaration of function ‘http_write_chunked’; did you mean ‘http_read_chunked’? [-Wimplicit-function-declaration]
if(http_write_chunked(&hi2, data, size) != size)
^~~~~~~~~~~~~~~~~~
http_read_chunked
ApiService.c: In function ‘getTask’:
ApiService.c:106:5: warning: format not a string literal and no format arguments [-Wformat-security]
sprintf(data, cJSON_Print(task));
^~~~~~~
https.c: In function ‘mbedtls_net_connect_timeout’:
https.c:496:18: error: ‘errno’ undeclared (first use in this function); did you mean ‘h_errno’?
else if( errno == EINPROGRESS )
^~~~~
h_errno
https.c:496:18: note: each undeclared identifier is reported only once for each function it appears in
https.c:496:27: error: ‘EINPROGRESS’ undeclared (first use in this function)
else if( errno == EINPROGRESS )
^~~~~~~~~~~
https.c:515:33: error: ‘EINTR’ undeclared (first use in this function); did you mean ‘NLE_INTR’?
if(errno == EINTR) continue;
^~~~~
NLE_INTR
Makefile:16: recipe for target 'compile' failed

Link to repo https://github.com/HISONA/https_client . Please help I trying to compile that whole day, nothing works for me.

The implicit declaration of function error means that the compiler cannot locate the function in your workspace. you should indicate to the caller where the http_open_chunked function reside in your code by including the header ( .h ) file where it is impleented.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM