11cb0ef41Sopenharmony_ci** This file is adapted from libcurl and not yet fully rewritten for c-ares! **
21cb0ef41Sopenharmony_ci
31cb0ef41Sopenharmony_ci```
41cb0ef41Sopenharmony_ci                          ___       __ _ _ __ ___  ___
51cb0ef41Sopenharmony_ci                         / __| ___ / _` | '__/ _ \/ __|
61cb0ef41Sopenharmony_ci                        | (_  |___| (_| | | |  __/\__ \
71cb0ef41Sopenharmony_ci                         \___|     \__,_|_|  \___||___/
81cb0ef41Sopenharmony_ci
91cb0ef41Sopenharmony_ci                                How To Compile
101cb0ef41Sopenharmony_ci```
111cb0ef41Sopenharmony_ci
121cb0ef41Sopenharmony_ciInstalling Binary Packages
131cb0ef41Sopenharmony_ci==========================
141cb0ef41Sopenharmony_ci
151cb0ef41Sopenharmony_ciLots of people download binary distributions of c-ares. This document
161cb0ef41Sopenharmony_cidoes not describe how to install c-ares using such a binary package.
171cb0ef41Sopenharmony_ciThis document describes how to compile, build and install c-ares from
181cb0ef41Sopenharmony_cisource code.
191cb0ef41Sopenharmony_ci
201cb0ef41Sopenharmony_ciBuilding from Git
211cb0ef41Sopenharmony_ci=================
221cb0ef41Sopenharmony_ci
231cb0ef41Sopenharmony_ciIf you get your code off a Git repository rather than an official
241cb0ef41Sopenharmony_cirelease tarball, see the [GIT-INFO](GIT-INFO) file in the root directory
251cb0ef41Sopenharmony_cifor specific instructions on how to proceed.
261cb0ef41Sopenharmony_ci
271cb0ef41Sopenharmony_ciIn particular, if not using CMake you will need to run `./buildconf` (Unix) or
281cb0ef41Sopenharmony_ci`buildconf.bat` (Windows) to generate build files, and for the former
291cb0ef41Sopenharmony_ciyou will need a local installation of Autotools.  If using CMake the steps are
301cb0ef41Sopenharmony_cithe same for both Git and official release tarballs.
311cb0ef41Sopenharmony_ci
321cb0ef41Sopenharmony_ciAutoTools Build
331cb0ef41Sopenharmony_ci===============
341cb0ef41Sopenharmony_ci
351cb0ef41Sopenharmony_ci### General Information, works on most Unix Platforms (Linux, FreeBSD, etc.)
361cb0ef41Sopenharmony_ci
371cb0ef41Sopenharmony_ciA normal Unix installation is made in three or four steps (after you've
381cb0ef41Sopenharmony_ciunpacked the source archive):
391cb0ef41Sopenharmony_ci
401cb0ef41Sopenharmony_ci    ./configure
411cb0ef41Sopenharmony_ci    make
421cb0ef41Sopenharmony_ci    make install
431cb0ef41Sopenharmony_ci
441cb0ef41Sopenharmony_ciYou probably need to be root when doing the last command.
451cb0ef41Sopenharmony_ci
461cb0ef41Sopenharmony_ciIf you have checked out the sources from the git repository, read the
471cb0ef41Sopenharmony_ci[GIT-INFO](GIT_INFO) on how to proceed.
481cb0ef41Sopenharmony_ci
491cb0ef41Sopenharmony_ciGet a full listing of all available configure options by invoking it like:
501cb0ef41Sopenharmony_ci
511cb0ef41Sopenharmony_ci    ./configure --help
521cb0ef41Sopenharmony_ci
531cb0ef41Sopenharmony_ciIf you want to install c-ares in a different file hierarchy than /usr/local,
541cb0ef41Sopenharmony_ciyou need to specify that already when running configure:
551cb0ef41Sopenharmony_ci
561cb0ef41Sopenharmony_ci    ./configure --prefix=/path/to/c-ares/tree
571cb0ef41Sopenharmony_ci
581cb0ef41Sopenharmony_ciIf you happen to have write permission in that directory, you can do `make
591cb0ef41Sopenharmony_ciinstall` without being root. An example of this would be to make a local
601cb0ef41Sopenharmony_ciinstallation in your own home directory:
611cb0ef41Sopenharmony_ci
621cb0ef41Sopenharmony_ci    ./configure --prefix=$HOME
631cb0ef41Sopenharmony_ci    make
641cb0ef41Sopenharmony_ci    make install
651cb0ef41Sopenharmony_ci
661cb0ef41Sopenharmony_ci### More Options
671cb0ef41Sopenharmony_ci
681cb0ef41Sopenharmony_ciTo force configure to use the standard cc compiler if both cc and gcc are
691cb0ef41Sopenharmony_cipresent, run configure like
701cb0ef41Sopenharmony_ci
711cb0ef41Sopenharmony_ci    CC=cc ./configure
721cb0ef41Sopenharmony_ci    # or
731cb0ef41Sopenharmony_ci    env CC=cc ./configure
741cb0ef41Sopenharmony_ci
751cb0ef41Sopenharmony_ciTo force a static library compile, disable the shared library creation
761cb0ef41Sopenharmony_ciby running configure like:
771cb0ef41Sopenharmony_ci
781cb0ef41Sopenharmony_ci    ./configure --disable-shared
791cb0ef41Sopenharmony_ci
801cb0ef41Sopenharmony_ciIf you're a c-ares developer and use gcc, you might want to enable more
811cb0ef41Sopenharmony_cidebug options with the `--enable-debug` option.
821cb0ef41Sopenharmony_ci
831cb0ef41Sopenharmony_ci### Special Cases
841cb0ef41Sopenharmony_ci
851cb0ef41Sopenharmony_ciSome versions of uClibc require configuring with `CPPFLAGS=-D_GNU_SOURCE=1`
861cb0ef41Sopenharmony_cito get correct large file support.
871cb0ef41Sopenharmony_ci
881cb0ef41Sopenharmony_ciThe Open Watcom C compiler on Linux requires configuring with the variables:
891cb0ef41Sopenharmony_ci
901cb0ef41Sopenharmony_ci    ./configure CC=owcc AR="$WATCOM/binl/wlib" AR_FLAGS=-q \
911cb0ef41Sopenharmony_ci        RANLIB=/bin/true STRIP="$WATCOM/binl/wstrip" CFLAGS=-Wextra
921cb0ef41Sopenharmony_ci
931cb0ef41Sopenharmony_ci
941cb0ef41Sopenharmony_ci### CROSS COMPILE
951cb0ef41Sopenharmony_ci
961cb0ef41Sopenharmony_ci(This section was graciously brought to us by Jim Duey, with additions by
971cb0ef41Sopenharmony_ciDan Fandrich)
981cb0ef41Sopenharmony_ci
991cb0ef41Sopenharmony_ciDownload and unpack the c-ares package.
1001cb0ef41Sopenharmony_ci
1011cb0ef41Sopenharmony_ci`cd` to the new directory. (e.g. `cd c-ares-1.7.6`)
1021cb0ef41Sopenharmony_ci
1031cb0ef41Sopenharmony_ciSet environment variables to point to the cross-compile toolchain and call
1041cb0ef41Sopenharmony_ciconfigure with any options you need.  Be sure and specify the `--host` and
1051cb0ef41Sopenharmony_ci`--build` parameters at configuration time.  The following script is an
1061cb0ef41Sopenharmony_ciexample of cross-compiling for the IBM 405GP PowerPC processor using the
1071cb0ef41Sopenharmony_citoolchain from MonteVista for Hardhat Linux.
1081cb0ef41Sopenharmony_ci
1091cb0ef41Sopenharmony_ci```sh
1101cb0ef41Sopenharmony_ci#! /bin/sh
1111cb0ef41Sopenharmony_ci
1121cb0ef41Sopenharmony_ciexport PATH=$PATH:/opt/hardhat/devkit/ppc/405/bin
1131cb0ef41Sopenharmony_ciexport CPPFLAGS="-I/opt/hardhat/devkit/ppc/405/target/usr/include"
1141cb0ef41Sopenharmony_ciexport AR=ppc_405-ar
1151cb0ef41Sopenharmony_ciexport AS=ppc_405-as
1161cb0ef41Sopenharmony_ciexport LD=ppc_405-ld
1171cb0ef41Sopenharmony_ciexport RANLIB=ppc_405-ranlib
1181cb0ef41Sopenharmony_ciexport CC=ppc_405-gcc
1191cb0ef41Sopenharmony_ciexport NM=ppc_405-nm
1201cb0ef41Sopenharmony_ci
1211cb0ef41Sopenharmony_ci./configure --target=powerpc-hardhat-linux \
1221cb0ef41Sopenharmony_ci     --host=powerpc-hardhat-linux \
1231cb0ef41Sopenharmony_ci     --build=i586-pc-linux-gnu \
1241cb0ef41Sopenharmony_ci     --prefix=/opt/hardhat/devkit/ppc/405/target/usr/local \
1251cb0ef41Sopenharmony_ci     --exec-prefix=/usr/local
1261cb0ef41Sopenharmony_ci```
1271cb0ef41Sopenharmony_ci
1281cb0ef41Sopenharmony_ciYou may also need to provide a parameter like `--with-random=/dev/urandom`
1291cb0ef41Sopenharmony_cito configure as it cannot detect the presence of a random number
1301cb0ef41Sopenharmony_cigenerating device for a target system.  The `--prefix` parameter
1311cb0ef41Sopenharmony_cispecifies where c-ares will be installed.  If `configure` completes
1321cb0ef41Sopenharmony_cisuccessfully, do `make` and `make install` as usual.
1331cb0ef41Sopenharmony_ci
1341cb0ef41Sopenharmony_ciIn some cases, you may be able to simplify the above commands to as
1351cb0ef41Sopenharmony_cilittle as:
1361cb0ef41Sopenharmony_ci
1371cb0ef41Sopenharmony_ci    ./configure --host=ARCH-OS
1381cb0ef41Sopenharmony_ci
1391cb0ef41Sopenharmony_ci
1401cb0ef41Sopenharmony_ci### Cygwin (Windows)
1411cb0ef41Sopenharmony_ci
1421cb0ef41Sopenharmony_ciAlmost identical to the unix installation. Run the configure script in the
1431cb0ef41Sopenharmony_cic-ares root with `sh configure`. Make sure you have the sh executable in
1441cb0ef41Sopenharmony_ci`/bin/` or you'll see the configure fail toward the end.
1451cb0ef41Sopenharmony_ci
1461cb0ef41Sopenharmony_ciRun `make`
1471cb0ef41Sopenharmony_ci
1481cb0ef41Sopenharmony_ci
1491cb0ef41Sopenharmony_ci### QNX
1501cb0ef41Sopenharmony_ci
1511cb0ef41Sopenharmony_ci(This section was graciously brought to us by David Bentham)
1521cb0ef41Sopenharmony_ci
1531cb0ef41Sopenharmony_ciAs QNX is targeted for resource constrained environments, the QNX headers
1541cb0ef41Sopenharmony_ciset conservative limits. This includes the `FD_SETSIZE` macro, set by default
1551cb0ef41Sopenharmony_cito 32. Socket descriptors returned within the c-ares library may exceed this,
1561cb0ef41Sopenharmony_ciresulting in memory faults/SIGSEGV crashes when passed into `select(..)`
1571cb0ef41Sopenharmony_cicalls using `fd_set` macros.
1581cb0ef41Sopenharmony_ci
1591cb0ef41Sopenharmony_ciA good all-round solution to this is to override the default when building
1601cb0ef41Sopenharmony_cic-ares, by overriding `CFLAGS` during configure, example:
1611cb0ef41Sopenharmony_ci
1621cb0ef41Sopenharmony_ci    # configure CFLAGS='-DFD_SETSIZE=64 -g -O2'
1631cb0ef41Sopenharmony_ci
1641cb0ef41Sopenharmony_ci
1651cb0ef41Sopenharmony_ci### RISC OS
1661cb0ef41Sopenharmony_ci
1671cb0ef41Sopenharmony_ciThe library can be cross-compiled using gccsdk as follows:
1681cb0ef41Sopenharmony_ci
1691cb0ef41Sopenharmony_ci    CC=riscos-gcc AR=riscos-ar RANLIB='riscos-ar -s' ./configure \
1701cb0ef41Sopenharmony_ci         --host=arm-riscos-aof --without-random --disable-shared
1711cb0ef41Sopenharmony_ci    make
1721cb0ef41Sopenharmony_ci
1731cb0ef41Sopenharmony_ciwhere `riscos-gcc` and `riscos-ar` are links to the gccsdk tools.
1741cb0ef41Sopenharmony_ciYou can then link your program with `c-ares/lib/.libs/libcares.a`.
1751cb0ef41Sopenharmony_ci
1761cb0ef41Sopenharmony_ci
1771cb0ef41Sopenharmony_ci### Android
1781cb0ef41Sopenharmony_ci
1791cb0ef41Sopenharmony_ciMethod using a configure cross-compile (tested with Android NDK r7b):
1801cb0ef41Sopenharmony_ci
1811cb0ef41Sopenharmony_ci  - prepare the toolchain of the Android NDK for standalone use; this can
1821cb0ef41Sopenharmony_ci    be done by invoking the script:
1831cb0ef41Sopenharmony_ci
1841cb0ef41Sopenharmony_ci        ./tools/make-standalone-toolchain.sh
1851cb0ef41Sopenharmony_ci
1861cb0ef41Sopenharmony_ci    which creates a usual cross-compile toolchain. Let's assume that you put
1871cb0ef41Sopenharmony_ci    this toolchain below `/opt` then invoke configure with something
1881cb0ef41Sopenharmony_ci    like:
1891cb0ef41Sopenharmony_ci
1901cb0ef41Sopenharmony_ci    ```
1911cb0ef41Sopenharmony_ci        export PATH=/opt/arm-linux-androideabi-4.4.3/bin:$PATH
1921cb0ef41Sopenharmony_ci       ./configure --host=arm-linux-androideabi [more configure options]
1931cb0ef41Sopenharmony_ci        make
1941cb0ef41Sopenharmony_ci    ```
1951cb0ef41Sopenharmony_ci  - if you want to compile directly from our GIT repo you might run into
1961cb0ef41Sopenharmony_ci    this issue with older automake stuff:
1971cb0ef41Sopenharmony_ci
1981cb0ef41Sopenharmony_ci    ```
1991cb0ef41Sopenharmony_ci        checking host system type...
2001cb0ef41Sopenharmony_ci        Invalid configuration `arm-linux-androideabi':
2011cb0ef41Sopenharmony_ci        system `androideabi' not recognized
2021cb0ef41Sopenharmony_ci        configure: error: /bin/sh ./config.sub arm-linux-androideabi failed
2031cb0ef41Sopenharmony_ci    ```
2041cb0ef41Sopenharmony_ci    this issue can be fixed with using more recent versions of `config.sub`
2051cb0ef41Sopenharmony_ci    and `config.guess` which can be obtained here:
2061cb0ef41Sopenharmony_ci    http://git.savannah.gnu.org/gitweb/?p=config.git;a=tree
2071cb0ef41Sopenharmony_ci    you need to replace your system-own versions which usually can be
2081cb0ef41Sopenharmony_ci    found in your automake folder:
2091cb0ef41Sopenharmony_ci    `find /usr -name config.sub`
2101cb0ef41Sopenharmony_ci
2111cb0ef41Sopenharmony_ci
2121cb0ef41Sopenharmony_ciCMake builds
2131cb0ef41Sopenharmony_ci============
2141cb0ef41Sopenharmony_ci
2151cb0ef41Sopenharmony_ciCurrent releases of c-ares introduce a CMake v3+ build system that has been
2161cb0ef41Sopenharmony_citested on most platforms including Windows, Linux, FreeBSD, macOS, AIX and
2171cb0ef41Sopenharmony_ciSolaris.
2181cb0ef41Sopenharmony_ci
2191cb0ef41Sopenharmony_ciIn the most basic form, building with CMake might look like:
2201cb0ef41Sopenharmony_ci
2211cb0ef41Sopenharmony_ci```sh
2221cb0ef41Sopenharmony_cicd /path/to/cmake/source
2231cb0ef41Sopenharmony_cimkdir build
2241cb0ef41Sopenharmony_cicd build
2251cb0ef41Sopenharmony_cicmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local/cares ..
2261cb0ef41Sopenharmony_cimake
2271cb0ef41Sopenharmony_cisudo make install
2281cb0ef41Sopenharmony_ci```
2291cb0ef41Sopenharmony_ci
2301cb0ef41Sopenharmony_ciOptions
2311cb0ef41Sopenharmony_ci-------
2321cb0ef41Sopenharmony_ci
2331cb0ef41Sopenharmony_ciOptions to CMake are passed on the command line using "-D${OPTION}=${VALUE}".
2341cb0ef41Sopenharmony_ciThe values defined are all boolean and take values like On, Off, True, False.
2351cb0ef41Sopenharmony_ci
2361cb0ef41Sopenharmony_ci| Option Name                 | Description                                                           | Default Value  |
2371cb0ef41Sopenharmony_ci|-----------------------------|-----------------------------------------------------------------------|----------------|
2381cb0ef41Sopenharmony_ci| CARES_STATIC                | Build the static library                                              | Off            |
2391cb0ef41Sopenharmony_ci| CARES_SHARED                | Build the shared library                                              | On             |
2401cb0ef41Sopenharmony_ci| CARES_INSTALL               | Hook in installation, useful to disable if chain building             | On             |
2411cb0ef41Sopenharmony_ci| CARES_STATIC_PIC            | Build the static library as position-independent                      | Off            |
2421cb0ef41Sopenharmony_ci| CARES_BUILD_TESTS           | Build and run tests                                                   | Off            |
2431cb0ef41Sopenharmony_ci| CARES_BUILD_CONTAINER_TESTS | Build and run container tests (implies CARES_BUILD_TESTS, Linux only) | Off            |
2441cb0ef41Sopenharmony_ci| CARES_BUILD_TOOLS           | Build tools                                                           | On             |
2451cb0ef41Sopenharmony_ci| CARES_SYMBOL_HIDING         | Hide private symbols in shared libraries                              | Off            |
2461cb0ef41Sopenharmony_ci| CARES_THREADS               | Build with thread-safety support                                      | On             |
2471cb0ef41Sopenharmony_ci
2481cb0ef41Sopenharmony_ciNinja
2491cb0ef41Sopenharmony_ci-----
2501cb0ef41Sopenharmony_ci
2511cb0ef41Sopenharmony_ciNinja is the next-generation build system meant for generators like CMake that
2521cb0ef41Sopenharmony_ciheavily parallelize builds.  Its use is very similar to the normal build:
2531cb0ef41Sopenharmony_ci
2541cb0ef41Sopenharmony_ci```sh
2551cb0ef41Sopenharmony_cicd /path/to/cmake/source
2561cb0ef41Sopenharmony_cimkdir build
2571cb0ef41Sopenharmony_cicd build
2581cb0ef41Sopenharmony_cicmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local/cares -G "Ninja" ..
2591cb0ef41Sopenharmony_cininja
2601cb0ef41Sopenharmony_cisudo ninja install
2611cb0ef41Sopenharmony_ci```
2621cb0ef41Sopenharmony_ci
2631cb0ef41Sopenharmony_ciWindows MSVC Command Line
2641cb0ef41Sopenharmony_ci-------------------------
2651cb0ef41Sopenharmony_ci
2661cb0ef41Sopenharmony_ci```
2671cb0ef41Sopenharmony_cicd \path\to\cmake\source
2681cb0ef41Sopenharmony_cimkdir build
2691cb0ef41Sopenharmony_cicd build
2701cb0ef41Sopenharmony_cicmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=C:\cares -G "NMake Makefiles" ..
2711cb0ef41Sopenharmony_cinmake
2721cb0ef41Sopenharmony_cinmake install
2731cb0ef41Sopenharmony_ci```
2741cb0ef41Sopenharmony_ci
2751cb0ef41Sopenharmony_ciWindows MinGW-w64 Command Line via MSYS
2761cb0ef41Sopenharmony_ci---------------------------------------
2771cb0ef41Sopenharmony_ci```
2781cb0ef41Sopenharmony_cicd \path\to\cmake\source
2791cb0ef41Sopenharmony_cimkdir build
2801cb0ef41Sopenharmony_cicd build
2811cb0ef41Sopenharmony_cicmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=C:\cares -G "MSYS Makefiles" ..
2821cb0ef41Sopenharmony_cimake
2831cb0ef41Sopenharmony_cimake install
2841cb0ef41Sopenharmony_ci```
2851cb0ef41Sopenharmony_ci
2861cb0ef41Sopenharmony_ci
2871cb0ef41Sopenharmony_ciPlatform-specific build systems
2881cb0ef41Sopenharmony_ci===============================
2891cb0ef41Sopenharmony_ci
2901cb0ef41Sopenharmony_ciWin32
2911cb0ef41Sopenharmony_ci-----
2921cb0ef41Sopenharmony_ci
2931cb0ef41Sopenharmony_ci### Building Windows DLLs and C run-time (CRT) linkage issues
2941cb0ef41Sopenharmony_ci
2951cb0ef41Sopenharmony_ciAs a general rule, building a DLL with static CRT linkage is highly
2961cb0ef41Sopenharmony_cidiscouraged, and intermixing CRTs in the same app is something to
2971cb0ef41Sopenharmony_ciavoid at any cost.
2981cb0ef41Sopenharmony_ci
2991cb0ef41Sopenharmony_ciReading and comprehension of the following Microsoft Learn article
3001cb0ef41Sopenharmony_ciis a must for any Windows developer. Especially
3011cb0ef41Sopenharmony_ciimportant is full understanding if you are not going to follow the
3021cb0ef41Sopenharmony_ciadvice given above.
3031cb0ef41Sopenharmony_ci
3041cb0ef41Sopenharmony_ci - [Use the C Run-Time](https://learn.microsoft.com/en-us/troubleshoot/developer/visualstudio/cpp/libraries/use-c-run-time)
3051cb0ef41Sopenharmony_ci
3061cb0ef41Sopenharmony_ciIf your app is misbehaving in some strange way, or it is suffering
3071cb0ef41Sopenharmony_cifrom memory corruption, before asking for further help, please try
3081cb0ef41Sopenharmony_cifirst to rebuild every single library your app uses as well as your
3091cb0ef41Sopenharmony_ciapp using the debug multithreaded dynamic C runtime.
3101cb0ef41Sopenharmony_ci
3111cb0ef41Sopenharmony_ci
3121cb0ef41Sopenharmony_ci### MingW32
3131cb0ef41Sopenharmony_ci
3141cb0ef41Sopenharmony_ciMake sure that MinGW32's bin dir is in the search path, for example:
3151cb0ef41Sopenharmony_ci
3161cb0ef41Sopenharmony_ci    set PATH=c:\mingw32\bin;%PATH%
3171cb0ef41Sopenharmony_ci
3181cb0ef41Sopenharmony_cithen run 'make -f Makefile.m32' in the root dir.
3191cb0ef41Sopenharmony_ci
3201cb0ef41Sopenharmony_ci
3211cb0ef41Sopenharmony_ci### MSVC 6 caveats
3221cb0ef41Sopenharmony_ci
3231cb0ef41Sopenharmony_ciIf you use MSVC 6 it is required that you use the February 2003 edition PSDK:
3241cb0ef41Sopenharmony_cihttp://www.microsoft.com/msdownload/platformsdk/sdkupdate/psdk-full.htm
3251cb0ef41Sopenharmony_ci
3261cb0ef41Sopenharmony_ci
3271cb0ef41Sopenharmony_ci### MSVC from command line
3281cb0ef41Sopenharmony_ci
3291cb0ef41Sopenharmony_ciRun the `vcvars32.bat` file to get a proper environment. The
3301cb0ef41Sopenharmony_ci`vcvars32.bat` file is part of the Microsoft development environment and
3311cb0ef41Sopenharmony_ciyou may find it in `C:\Program Files\Microsoft Visual Studio\vc98\bin`
3321cb0ef41Sopenharmony_ciprovided that you installed Visual C/C++ 6 in the default directory.
3331cb0ef41Sopenharmony_ci
3341cb0ef41Sopenharmony_ciFurther details in [README.msvc](README.msvc)
3351cb0ef41Sopenharmony_ci
3361cb0ef41Sopenharmony_ci
3371cb0ef41Sopenharmony_ci### Important static c-ares usage note
3381cb0ef41Sopenharmony_ci
3391cb0ef41Sopenharmony_ciWhen building an application that uses the static c-ares library, you must
3401cb0ef41Sopenharmony_ciadd `-DCARES_STATICLIB` to your `CFLAGS`.  Otherwise the linker will look for
3411cb0ef41Sopenharmony_cidynamic import symbols.
3421cb0ef41Sopenharmony_ci
3431cb0ef41Sopenharmony_ci
3441cb0ef41Sopenharmony_ciIBM OS/2
3451cb0ef41Sopenharmony_ci--------
3461cb0ef41Sopenharmony_ci
3471cb0ef41Sopenharmony_ciBuilding under OS/2 is not much different from building under unix.
3481cb0ef41Sopenharmony_ciYou need:
3491cb0ef41Sopenharmony_ci
3501cb0ef41Sopenharmony_ci  - emx 0.9d
3511cb0ef41Sopenharmony_ci  - GNU make
3521cb0ef41Sopenharmony_ci  - GNU patch
3531cb0ef41Sopenharmony_ci  - ksh
3541cb0ef41Sopenharmony_ci  - GNU bison
3551cb0ef41Sopenharmony_ci  - GNU file utilities
3561cb0ef41Sopenharmony_ci  - GNU sed
3571cb0ef41Sopenharmony_ci  - autoconf 2.13
3581cb0ef41Sopenharmony_ci
3591cb0ef41Sopenharmony_ciIf during the linking you get an error about `_errno` being an undefined
3601cb0ef41Sopenharmony_cisymbol referenced from the text segment, you need to add `-D__ST_MT_ERRNO__`
3611cb0ef41Sopenharmony_ciin your definitions.
3621cb0ef41Sopenharmony_ci
3631cb0ef41Sopenharmony_ciIf you're getting huge binaries, probably your makefiles have the `-g` in
3641cb0ef41Sopenharmony_ci`CFLAGS`.
3651cb0ef41Sopenharmony_ci
3661cb0ef41Sopenharmony_ci
3671cb0ef41Sopenharmony_ciNetWare
3681cb0ef41Sopenharmony_ci-------
3691cb0ef41Sopenharmony_ci
3701cb0ef41Sopenharmony_ciTo compile `libcares.a` / `libcares.lib` you need:
3711cb0ef41Sopenharmony_ci
3721cb0ef41Sopenharmony_ci - either any gcc / nlmconv, or CodeWarrior 7 PDK 4 or later.
3731cb0ef41Sopenharmony_ci - gnu make and awk running on the platform you compile on;
3741cb0ef41Sopenharmony_ci   native Win32 versions can be downloaded from:
3751cb0ef41Sopenharmony_ci   http://www.gknw.net/development/prgtools/
3761cb0ef41Sopenharmony_ci - recent Novell LibC SDK available from:
3771cb0ef41Sopenharmony_ci   http://developer.novell.com/ndk/libc.htm
3781cb0ef41Sopenharmony_ci - or recent Novell CLib SDK available from:
3791cb0ef41Sopenharmony_ci   http://developer.novell.com/ndk/clib.htm
3801cb0ef41Sopenharmony_ci
3811cb0ef41Sopenharmony_ciSet a search path to your compiler, linker and tools; on Linux make
3821cb0ef41Sopenharmony_cisure that the var `OSTYPE` contains the string 'linux'; set the var
3831cb0ef41Sopenharmony_ci`NDKBASE` to point to the base of your Novell NDK; and then type
3841cb0ef41Sopenharmony_ci`make -f Makefile.netware` from the top source directory;
3851cb0ef41Sopenharmony_ci
3861cb0ef41Sopenharmony_ciVCPKG
3871cb0ef41Sopenharmony_ci=====
3881cb0ef41Sopenharmony_ci
3891cb0ef41Sopenharmony_ciYou can build and install c-ares using [vcpkg](https://github.com/Microsoft/vcpkg/) dependency manager:
3901cb0ef41Sopenharmony_ci
3911cb0ef41Sopenharmony_ci```sh or powershell
3921cb0ef41Sopenharmony_ci    git clone https://github.com/Microsoft/vcpkg.git
3931cb0ef41Sopenharmony_ci    cd vcpkg
3941cb0ef41Sopenharmony_ci    ./bootstrap-vcpkg.sh
3951cb0ef41Sopenharmony_ci    ./vcpkg integrate install
3961cb0ef41Sopenharmony_ci    ./vcpkg install c-ares
3971cb0ef41Sopenharmony_ci```
3981cb0ef41Sopenharmony_ci
3991cb0ef41Sopenharmony_ciThe c-ares port in vcpkg is kept up to date by Microsoft team members and community contributors. If the version is out of date, please [create an issue or pull request](https://github.com/Microsoft/vcpkg) on the vcpkg repository.
4001cb0ef41Sopenharmony_ci
4011cb0ef41Sopenharmony_ciWATCOM
4021cb0ef41Sopenharmony_ci=====
4031cb0ef41Sopenharmony_ci
4041cb0ef41Sopenharmony_ciTo build c-ares with OpenWatcom, you need to have at least version 1.9 of OpenWatcom. You can get the latest version from [http://openwatcom.org/ftp/install/](http://openwatcom.org/ftp/install/). Install the version that corresponds to your current host platform.
4051cb0ef41Sopenharmony_ci
4061cb0ef41Sopenharmony_ciAfter installing OpenWatcom, open a new command prompt and execute the following commands:
4071cb0ef41Sopenharmony_ci
4081cb0ef41Sopenharmony_ci```
4091cb0ef41Sopenharmony_ci  cd \path\to\cmake\source
4101cb0ef41Sopenharmony_ci  buildconf.bat
4111cb0ef41Sopenharmony_ci  wmake -u -f Makefile.Watcom
4121cb0ef41Sopenharmony_ci```
4131cb0ef41Sopenharmony_ci
4141cb0ef41Sopenharmony_ciAfter running wmake, you should get adig.exe, ahost.exe, and the static and dynamic versions of libcares.
4151cb0ef41Sopenharmony_ci
4161cb0ef41Sopenharmony_ciPORTS
4171cb0ef41Sopenharmony_ci=====
4181cb0ef41Sopenharmony_ci
4191cb0ef41Sopenharmony_ciThis is a probably incomplete list of known hardware and operating systems
4201cb0ef41Sopenharmony_cithat c-ares has been compiled for. If you know a system c-ares compiles and
4211cb0ef41Sopenharmony_ciruns on, that isn't listed, please let us know!
4221cb0ef41Sopenharmony_ci
4231cb0ef41Sopenharmony_ci     - Alpha Tru64 v5.0 5.1
4241cb0ef41Sopenharmony_ci     - ARM Android 1.5, 2.1, 2.3
4251cb0ef41Sopenharmony_ci     - MIPS IRIX 6.2, 6.5
4261cb0ef41Sopenharmony_ci     - Power AIX 3.2.5, 4.2, 4.3.1, 4.3.2, 5.1, 5.2
4271cb0ef41Sopenharmony_ci     - i386 Linux 1.3, 2.0, 2.2, 2.3, 2.4, 2.6
4281cb0ef41Sopenharmony_ci     - i386 Novell NetWare
4291cb0ef41Sopenharmony_ci     - i386 Windows 95, 98, ME, NT, 2000, XP, 2003
4301cb0ef41Sopenharmony_ci     - x86_64 Linux
4311cb0ef41Sopenharmony_ci
4321cb0ef41Sopenharmony_ci
4331cb0ef41Sopenharmony_ciUseful URLs
4341cb0ef41Sopenharmony_ci===========
4351cb0ef41Sopenharmony_ci
4361cb0ef41Sopenharmony_ci - c-ares: https://c-ares.org/
4371cb0ef41Sopenharmony_ci - MingW: http://www.mingw.org/
4381cb0ef41Sopenharmony_ci - MinGW-w64: http://mingw-w64.sourceforge.net/
4391cb0ef41Sopenharmony_ci - OpenWatcom: http://www.openwatcom.org/
440