You are not logged in.

#1 2021-05-13 14:11:38

cmt100
Member
Registered: 2020-08-03
Posts: 5

Compiling app with c-ares

When compiling an app with c-ares in the past I used:

gcc -Wall -o acountry.cgi acountry.c ares_getenv.c ares_strcasecmp.c ares_version.c -static -static-libgcc -lcares

but now I get an error:

/usr/bin/ld: cannot find -lcares

Omitting "-lcares" gives undefined reference error.
I have the libraries in the usual path:

ls -ghlo /usr/lib/libcar*
lrwxrwxrwx 1  13 May 13 13:24 /usr/lib/libcares.so -> libcares.so.2
lrwxrwxrwx 1  17 May 13 13:24 /usr/lib/libcares.so.2 -> libcares.so.2.4.2
-rwxr-xr-x 1 94K May 13 13:24 /usr/lib/libcares.so.2.4.2

I would experiment with an older c-ares version (c-ares-1.17.1-1-x86_64.pkg.tar.zst installed)
if I had one.

Last edited by cmt100 (2021-05-13 14:13:24)

Offline

#2 2021-05-13 14:17:33

Scimmia
Fellow
Registered: 2012-09-01
Posts: 13,729

Re: Compiling app with c-ares

You used the -static option, but there's no static lib listed there for c-ares.

Last edited by Scimmia (2021-05-13 14:17:48)

Offline

#3 2021-05-13 19:35:14

cmt100
Member
Registered: 2020-08-03
Posts: 5

Re: Compiling app with c-ares

Thanks.
The "-static" option was giving me the error, but now I have a small file
which might not run independantly on a server.

Offline

#4 2021-05-13 19:48:35

progandy
Member
Registered: 2012-05-17
Posts: 5,321

Re: Compiling app with c-ares

If you want a static build, you'll have to compile c-ares manually with CARES_STATIC(_PIC)
https://github.com/c-ares/c-ares/blob/master/INSTALL.md


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' | alias ENGLISH='LANG=C.UTF-8 ' |

Offline

Board footer

Powered by FluxBB