Subject: Re: c-ares not compiling with mingw32ce

Re: c-ares not compiling with mingw32ce

From: Vincent Torri <vincent.torri_at_gmail.com>
Date: Wed, 23 Mar 2011 17:39:08 +0100

On Tue, Mar 22, 2011 at 10:47 PM, Vincent Torri <vincent.torri_at_gmail.com>wrote:

>
>
> On Tue, Mar 22, 2011 at 9:00 PM, Yang Tse <yangsita_at_gmail.com> wrote:
>
>> 2011/3/22 Vincent Torri wrote:
>>
>> > with current repo:
>> >
>> > ares_gethostbyaddr.c:222: error: 'ENOENT' undeclared (first use in this
>> > function)
>> > ares_gethostbyaddr.c:222: error: (Each undeclared identifier is reported
>> > only once
>> > ares_gethostbyaddr.c:222: error: for each function it appears in.)
>> > ares_gethostbyaddr.c:223: error: 'ESRCH' undeclared (first use in this
>> > function)
>> >
>> > I think that it's not the only place where fopen() returned value is
>> used. I
>> > don't know what to do here (I don't know the code...)
>>
>> Einch??? I'm certainly not a Win CE guy... In any case next two
>> commits seem reasonable to me...
>>
>>
>> https://github.com/bagder/c-ares/commit/c7ce7c7d4597300e7ee4079192da3c02d567223f
>>
>> https://github.com/bagder/c-ares/commit/3abad87d88fc77295230ed8c732f24bfb05f4397
>>
>
> They are reasonnable.
>
>
>>
>> > Also the mode used by fopen should always be in binary mode ("rb",
>> "wb"). On
>> > Unix, 'b' is ignored, but on Windows, it's important to have it:
>> >
>> > ares_gethostbyaddr.c: fp = fopen(PATH_HOSTS, "r");
>> > ares_gethostbyname.c: fp = fopen(PATH_HOSTS, "r")
>> > ares_init.c: fp = fopen(PATH_RESOLV_CONF, "r");
>> > ares_init.c: fp = fopen("/etc/nsswitch.conf", "r");
>> > ares_init.c: fp = fopen("/etc/host.conf", "r");
>> > ares_init.c: fp = fopen("/etc/svc.conf", "r");
>> > ares_search.c: fp = fopen(hostaliases, "r");
>>
>> All those files are actually text files. So why should we open them in
>> binary mode? Once you arrive to a point in which you are capable of
>> using c-ares on WinCE, you might want to re-address this if it is
>> actually needed.
>>
>
> I will have to test c-ares on embedded, then.
>
>
>>
>> More build failures?
>>
>
> Link problems
>
> .libs/ares_gethostbyaddr.o:ares_gethostbyaddr:(.text+0x238): undefined
> reference to `GetVersion'
> .libs/ares_gethostbyaddr.o:ares_gethostbyaddr:(.text+0x370): undefined
> reference to `GetWindowsDirectoryW'
> .libs/ares_gethostbyaddr.o:ares_gethostbyaddr:(.text+0x3ac): undefined
> reference to `ExpandEnvironmentStringsW'
> .libs/ares_getnameinfo.o:ares_getnameinfo.c:(.text+0x8c): undefined
> reference to `getservbyport'
> .libs/ares_init.o:ares_init.c:(.text+0xdd4): undefined reference to
> `getenv'
>
> 1) Windows CE has no environment variables, so no getenv (lines 522 and 530
> or ares_init.c) nor ExpandEnvironmentStrings. I don't know what to do, here.
>
> See
> http://www.pocketpcjunkies.com/Uwe/Forum.aspx/pocketpc-dev/6561/ExpandEnvironmentStrings
>
> 2) It seems that GetVersion() does not exist on Windows CE, but
> GetVersionEx() does (I use it in one of my library). The macro
>
> #define IS_NT() ((int)GetVersion() > 0)
>
> does not check NT at all. MSDN says that, but Microsoft actually removed
> all references to Windows 95 or 98. So GetVersion() can return a correct
> value while being on Windows98, for example. Just the macro IS_NT() is not
> sufficient imho. Anyway, see
>
> http://msdn.microsoft.com/en-us/library/ms724451%28VS.85%29.aspx
> and
> http://msdn.microsoft.com/en-us/library/ms960882.aspx
>
> 3) get_res_nt() should be rewritten for Windows CE. I have written code to
> access to registry on Windows CE. It uses RegCreateKeyEx, RegCloseKey,
> RegQueryValueEx, RegSetValueEx.
>
> 4) Instead of GetWindowsDirectory, on Windows CE, use
> SHGetSpecialFolderPath(0, buf, CSIDL_WINDOWS, 0);
>
> 5) getservbyport is not supported by Windows CE (see
> http://etutorials.org/Programming/Pocket+pc+network+programming/Chapter+1.+Winsock/Winsock+Basics/
> )
>

I saw that you added a stub getenv() function. That's a way to fix that
build problem :-)

Vincent
Received on 2011-03-23