rfc1036 / whois

Intelligent WHOIS client
GNU General Public License v2.0
486 stars 113 forks source link

Compiling on macos threw error, fixed it with gpt #171

Open bdmorin opened 3 months ago

bdmorin commented 3 months ago
❯ uname -a
Darwin n0x.local 23.5.0 Darwin Kernel Version 23.5.0: Wed May  1 20:12:58 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T6000 arm64

I have absolutely no idea if this was the correct thing to do, but I was getting this error when trying to compile.

❯ make whois
cc -I/opt/homebrew/opt/curl/include -DHAVE_LIBIDN2 -I/opt/homebrew/Cellar/libidn2/2.3.7/include  -g -O2 -MM -MG *.c > Makefile.depend
perl make_ip_del.pl < ip_del_list > ip_del.h
perl make_ip6_del.pl < ip6_del_list > ip6_del.h
perl make_as_del.pl < as_del_list > as_del.h
perl make_new_gtlds.pl < new_gtlds_list > new_gtlds.h
perl make_tld_serv.pl < tld_serv_list > tld_serv.h
perl make_nic_handles.pl < nic_handles_list > nic_handles.h
cc -I/opt/homebrew/opt/curl/include -DHAVE_LIBIDN2 -I/opt/homebrew/Cellar/libidn2/2.3.7/include  -g -O2 -c whois.c
cc -I/opt/homebrew/opt/curl/include -DHAVE_LIBIDN2 -I/opt/homebrew/Cellar/libidn2/2.3.7/include  -g -O2 -c utils.c
utils.c:55:24: error: call to undeclared library function 'strdup' with type 'char *(const char *)'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
    argstring = NOFAIL(strdup(args));
                       ^
utils.c:55:24: note: include the header <string.h> or explicitly provide a declaration for 'strdup'
1 error generated.
make: *** [utils.o] Error 1

I have libiconv and libidn installed

I asked GPT and it said, just add char *strdup(const char *s); to utils.c and it worked.

❯ make whois
cc -I/opt/homebrew/opt/curl/include -DHAVE_LIBIDN2 -I/opt/homebrew/Cellar/libidn2/2.3.7/include  -g -O2 -c utils.c
cc -g -O2 -L/opt/homebrew/opt/curl/lib -o whois whois.o utils.o -L/opt/homebrew/Cellar/libidn2/2.3.7/lib -lidn2

Works great.

Again, this might have been the stupidest thing to do, I don't know.