PageRenderTime 55ms CodeModel.GetById 28ms RepoModel.GetById 0ms app.codeStats 0ms

/trunk/libs/libcares/cares-1_17_1/INSTALL.md

https://gitlab.com/thanhnhat041/padavan-ng
Markdown | 410 lines | 288 code | 122 blank | 0 comment | 0 complexity | 4126bb05e03d8ad4959f6de739c3ba83 MD5 | raw file
  1. ** This file is adapted from libcurl and not yet fully rewritten for c-ares! **
  2. ```
  3. ___ __ _ _ __ ___ ___
  4. / __| ___ / _` | '__/ _ \/ __|
  5. | (_ |___| (_| | | | __/\__ \
  6. \___| \__,_|_| \___||___/
  7. How To Compile
  8. ```
  9. Installing Binary Packages
  10. ==========================
  11. Lots of people download binary distributions of c-ares. This document
  12. does not describe how to install c-ares using such a binary package.
  13. This document describes how to compile, build and install c-ares from
  14. source code.
  15. Building from Git
  16. =================
  17. If you get your code off a Git repository rather than an official
  18. release tarball, see the [GIT-INFO](GIT-INFO) file in the root directory
  19. for specific instructions on how to proceed.
  20. In particular, if not using CMake you will need to run `./buildconf` (Unix) or
  21. `buildconf.bat` (Windows) to generate build files, and for the former
  22. you will need a local installation of Autotools. If using CMake the steps are
  23. the same for both Git and official release tarballs.
  24. AutoTools Build
  25. ===============
  26. ### General Information, works on most Unix Platforms (Linux, FreeBSD, etc)
  27. A normal Unix installation is made in three or four steps (after you've
  28. unpacked the source archive):
  29. ./configure
  30. make
  31. make ahost adig acountry (optional)
  32. make install
  33. You probably need to be root when doing the last command.
  34. If you have checked out the sources from the git repository, read the
  35. [GIT-INFO](GIT_INFO) on how to proceed.
  36. Get a full listing of all available configure options by invoking it like:
  37. ./configure --help
  38. If you want to install c-ares in a different file hierarchy than /usr/local,
  39. you need to specify that already when running configure:
  40. ./configure --prefix=/path/to/c-ares/tree
  41. If you happen to have write permission in that directory, you can do `make
  42. install` without being root. An example of this would be to make a local
  43. install in your own home directory:
  44. ./configure --prefix=$HOME
  45. make
  46. make install
  47. ### More Options
  48. To force configure to use the standard cc compiler if both cc and gcc are
  49. present, run configure like
  50. CC=cc ./configure
  51. # or
  52. env CC=cc ./configure
  53. To force a static library compile, disable the shared library creation
  54. by running configure like:
  55. ./configure --disable-shared
  56. If you're a c-ares developer and use gcc, you might want to enable more
  57. debug options with the `--enable-debug` option.
  58. ### Special Cases
  59. Some versions of uClibc require configuring with `CPPFLAGS=-D_GNU_SOURCE=1`
  60. to get correct large file support.
  61. The Open Watcom C compiler on Linux requires configuring with the variables:
  62. ./configure CC=owcc AR="$WATCOM/binl/wlib" AR_FLAGS=-q \
  63. RANLIB=/bin/true STRIP="$WATCOM/binl/wstrip" CFLAGS=-Wextra
  64. ### CROSS COMPILE
  65. (This section was graciously brought to us by Jim Duey, with additions by
  66. Dan Fandrich)
  67. Download and unpack the c-ares package.
  68. `cd` to the new directory. (e.g. `cd c-ares-1.7.6`)
  69. Set environment variables to point to the cross-compile toolchain and call
  70. configure with any options you need. Be sure and specify the `--host` and
  71. `--build` parameters at configuration time. The following script is an
  72. example of cross-compiling for the IBM 405GP PowerPC processor using the
  73. toolchain from MonteVista for Hardhat Linux.
  74. ```sh
  75. #! /bin/sh
  76. export PATH=$PATH:/opt/hardhat/devkit/ppc/405/bin
  77. export CPPFLAGS="-I/opt/hardhat/devkit/ppc/405/target/usr/include"
  78. export AR=ppc_405-ar
  79. export AS=ppc_405-as
  80. export LD=ppc_405-ld
  81. export RANLIB=ppc_405-ranlib
  82. export CC=ppc_405-gcc
  83. export NM=ppc_405-nm
  84. ./configure --target=powerpc-hardhat-linux \
  85. --host=powerpc-hardhat-linux \
  86. --build=i586-pc-linux-gnu \
  87. --prefix=/opt/hardhat/devkit/ppc/405/target/usr/local \
  88. --exec-prefix=/usr/local
  89. ```
  90. You may also need to provide a parameter like `--with-random=/dev/urandom`
  91. to configure as it cannot detect the presence of a random number
  92. generating device for a target system. The `--prefix` parameter
  93. specifies where c-ares will be installed. If `configure` completes
  94. successfully, do `make` and `make install` as usual.
  95. In some cases, you may be able to simplify the above commands to as
  96. little as:
  97. ./configure --host=ARCH-OS
  98. ### Cygwin (Windows)
  99. Almost identical to the unix installation. Run the configure script in the
  100. c-ares root with `sh configure`. Make sure you have the sh executable in
  101. `/bin/` or you'll see the configure fail toward the end.
  102. Run `make`
  103. ### QNX
  104. (This section was graciously brought to us by David Bentham)
  105. As QNX is targeted for resource constrained environments, the QNX headers
  106. set conservative limits. This includes the `FD_SETSIZE` macro, set by default
  107. to 32. Socket descriptors returned within the c-ares library may exceed this,
  108. resulting in memory faults/SIGSEGV crashes when passed into `select(..)`
  109. calls using `fd_set` macros.
  110. A good all-round solution to this is to override the default when building
  111. c-ares, by overriding `CFLAGS` during configure, example:
  112. # configure CFLAGS='-DFD_SETSIZE=64 -g -O2'
  113. ### RISC OS
  114. The library can be cross-compiled using gccsdk as follows:
  115. CC=riscos-gcc AR=riscos-ar RANLIB='riscos-ar -s' ./configure \
  116. --host=arm-riscos-aof --without-random --disable-shared
  117. make
  118. where `riscos-gcc` and `riscos-ar` are links to the gccsdk tools.
  119. You can then link your program with `c-ares/lib/.libs/libcares.a`.
  120. ### Android
  121. Method using a configure cross-compile (tested with Android NDK r7b):
  122. - prepare the toolchain of the Android NDK for standalone use; this can
  123. be done by invoking the script:
  124. ./tools/make-standalone-toolchain.sh
  125. which creates a usual cross-compile toolchain. Lets assume that you put
  126. this toolchain below `/opt` then invoke configure with something
  127. like:
  128. ```
  129. export PATH=/opt/arm-linux-androideabi-4.4.3/bin:$PATH
  130. ./configure --host=arm-linux-androideabi [more configure options]
  131. make
  132. ```
  133. - if you want to compile directly from our GIT repo you might run into
  134. this issue with older automake stuff:
  135. ```
  136. checking host system type...
  137. Invalid configuration `arm-linux-androideabi':
  138. system `androideabi' not recognized
  139. configure: error: /bin/sh ./config.sub arm-linux-androideabi failed
  140. ```
  141. this issue can be fixed with using more recent versions of `config.sub`
  142. and `config.guess` which can be obtained here:
  143. http://git.savannah.gnu.org/gitweb/?p=config.git;a=tree
  144. you need to replace your system-own versions which usually can be
  145. found in your automake folder:
  146. `find /usr -name config.sub`
  147. CMake builds
  148. ============
  149. Current releases of c-ares introduce a CMake v3+ build system that has been
  150. tested on most platforms including Windows, Linux, FreeBSD, MacOS, AIX and
  151. Solaris.
  152. In the most basic form, building with CMake might look like:
  153. ```sh
  154. cd /path/to/cmake/source
  155. mkdir build
  156. cd build
  157. cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local/cares ..
  158. make
  159. sudo make install
  160. ```
  161. Options
  162. -------
  163. Options to CMake are passed on the command line using "-D${OPTION}=${VALUE}".
  164. The values defined are all boolean and take values like On, Off, True, False.
  165. * CARES_STATIC - Build the static library (off by default)
  166. * CARES_SHARED - Build the shared library (on by default)
  167. * CARES_INSTALL - Hook in installation, useful to disable if chain building
  168. * CARES_STATIC_PIC - Build the static library as position-independent (off by
  169. default)
  170. Ninja
  171. -----
  172. Ninja is the next-generation build system meant for generators like CMake that
  173. heavily parallize builds. Its use is very similar to the normal build:
  174. ```sh
  175. cd /path/to/cmake/source
  176. mkdir build
  177. cd build
  178. cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local/cares -G "Ninja" ..
  179. ninja
  180. sudo ninja install
  181. ```
  182. Windows MSVC Command Line
  183. -------------------------
  184. ```
  185. cd \path\to\cmake\source
  186. mkdir build
  187. cd build
  188. cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=C:\cares -G "NMake Makefiles" ..
  189. nmake
  190. nmake install
  191. ```
  192. Windows MinGW-w64 Command Line via MSYS
  193. ---------------------------------------
  194. ```
  195. cd \path\to\cmake\source
  196. mkdir build
  197. cd build
  198. cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=C:\cares -G "MSYS Makefiles" ..
  199. make
  200. make install
  201. ```
  202. Platform-specific build systems
  203. ===============================
  204. Win32
  205. -----
  206. ### Building Windows DLLs and C run-time (CRT) linkage issues
  207. As a general rule, building a DLL with static CRT linkage is highly
  208. discouraged, and intermixing CRTs in the same app is something to
  209. avoid at any cost.
  210. Reading and comprehension of Microsoft Knowledge Base articles
  211. KB94248 and KB140584 is a must for any Windows developer. Especially
  212. important is full understanding if you are not going to follow the
  213. advice given above.
  214. - [KB94248](http://support.microsoft.com/kb/94248/en-us) - How To Use the C Run-Time
  215. - [KB140584](http://support.microsoft.com/kb/140584/en-us) - How to link with the correct C Run-Time (CRT) library
  216. - [KB190799](http://msdn.microsoft.com/en-us/library/ms235460) - Potential Errors Passing CRT Objects Across DLL Boundaries
  217. If your app is misbehaving in some strange way, or it is suffering
  218. from memory corruption, before asking for further help, please try
  219. first to rebuild every single library your app uses as well as your
  220. app using the debug multithreaded dynamic C runtime.
  221. ### MingW32
  222. Make sure that MinGW32's bin dir is in the search path, for example:
  223. set PATH=c:\mingw32\bin;%PATH%
  224. then run 'make -f Makefile.m32' in the root dir.
  225. ### MSVC 6 caveats
  226. If you use MSVC 6 it is required that you use the February 2003 edition PSDK:
  227. http://www.microsoft.com/msdownload/platformsdk/sdkupdate/psdk-full.htm
  228. ### MSVC from command line
  229. Run the `vcvars32.bat` file to get a proper environment. The
  230. `vcvars32.bat` file is part of the Microsoft development environment and
  231. you may find it in `C:\Program Files\Microsoft Visual Studio\vc98\bin`
  232. provided that you installed Visual C/C++ 6 in the default directory.
  233. Further details in [README.msvc](README.msvc)
  234. ### Important static c-ares usage note
  235. When building an application that uses the static c-ares library, you must
  236. add `-DCARES_STATICLIB` to your `CFLAGS`. Otherwise the linker will look for
  237. dynamic import symbols.
  238. IBM OS/2
  239. --------
  240. Building under OS/2 is not much different from building under unix.
  241. You need:
  242. - emx 0.9d
  243. - GNU make
  244. - GNU patch
  245. - ksh
  246. - GNU bison
  247. - GNU file utilities
  248. - GNU sed
  249. - autoconf 2.13
  250. If during the linking you get an error about `_errno` being an undefined
  251. symbol referenced from the text segment, you need to add `-D__ST_MT_ERRNO__`
  252. in your definitions.
  253. If you're getting huge binaries, probably your makefiles have the `-g` in
  254. `CFLAGS`.
  255. NetWare
  256. -------
  257. To compile `libcares.a` / `libcares.lib` you need:
  258. - either any gcc / nlmconv, or CodeWarrior 7 PDK 4 or later.
  259. - gnu make and awk running on the platform you compile on;
  260. native Win32 versions can be downloaded from:
  261. http://www.gknw.net/development/prgtools/
  262. - recent Novell LibC SDK available from:
  263. http://developer.novell.com/ndk/libc.htm
  264. - or recent Novell CLib SDK available from:
  265. http://developer.novell.com/ndk/clib.htm
  266. Set a search path to your compiler, linker and tools; on Linux make
  267. sure that the var `OSTYPE` contains the string 'linux'; set the var
  268. `NDKBASE` to point to the base of your Novell NDK; and then type
  269. `make -f Makefile.netware` from the top source directory;
  270. PORTS
  271. =====
  272. This is a probably incomplete list of known hardware and operating systems
  273. that c-ares has been compiled for. If you know a system c-ares compiles and
  274. runs on, that isn't listed, please let us know!
  275. - Alpha Tru64 v5.0 5.1
  276. - ARM Android 1.5, 2.1, 2.3
  277. - MIPS IRIX 6.2, 6.5
  278. - Power AIX 3.2.5, 4.2, 4.3.1, 4.3.2, 5.1, 5.2
  279. - i386 Linux 1.3, 2.0, 2.2, 2.3, 2.4, 2.6
  280. - i386 Novell NetWare
  281. - i386 Windows 95, 98, ME, NT, 2000, XP, 2003
  282. - x86_64 Linux
  283. Useful URLs
  284. ===========
  285. - c-ares: https://c-ares.haxx.se/
  286. - MingW: http://www.mingw.org/
  287. - MinGW-w64: http://mingw-w64.sourceforge.net/
  288. - OpenWatcom: http://www.openwatcom.org/