• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1For Windows builds - see the Windows Section
2
3Obtaining the Libcoap Source
4============================
5
6To get the libcoap library source, you need to do either the following
7
8* Obtain the latest distribution package file from
9  https://github.com/obgm/libcoap/archive/develop.zip
10  [There is a stable version at
11   https://github.com/obgm/libcoap/archive/main.zip]
12* Change to the directory that you want to install the libcoap sub-directory
13  into
14* Unpack the distribution package file
15* Change into the top level directory of the unpackaged files
16
17or alternatively, clone the libcoap git repository from github
18
19* Change to the directory that you want to install the libcoap sub-directory
20  into.
21* Then clone the latest (develop) version of the code:-
22   git clone https://github.com/obgm/libcoap.git
23* Change into the top level directory of the cloned files
24* Optionally, change the branch from develop to the stable main branch:-
25   git checkout main
26
27Building Libcoap Libraries and Examples
28=======================================
29
30Follow the appropriate sections below
31
32
33TinyDTLS Only
34=============
35
36It is possible that you may need to execute the following two commands once to
37get the TinyDTLS code into your project, so the TinyDTLS library can be used.
38
39 git submodule init
40 git submodule update
41
42General Building with cmake for linux/windows/macos/android (not for LwIP or Contiki - see below)
43================
44
45 cmake -E remove_directory build
46 cmake -E make_directory build
47 cd build
48 cmake .. -DENABLE_TESTS=ON
49 cmake --build .
50 [sudo] cmake --build . -- install
51 cd ..
52
53 Note: to see possible options (TLS lib, doc, tests, examples etc.):
54 cmake -LH build
55
56 Note: For Windows, this is supported by Visual Studio Code with CMake extension
57 Note: You must use cmake version >=3.10.
58
59 Note: you can use cmake's find package after installation: find_package(libcoap-2 REQUIRED),
60 and target_link_libraries(myTarget PRIVATE libcoap::coap-2)
61
62 Note: Shared Library support is not currently available for Windows.
63
64General Building with autoconf (not for LwIP or Contiki - see below)
65================
66
67 ./autogen.sh
68 ./configure
69 make
70 sudo make install
71
72./autogen.sh will fail if there is a required package for buildling libcoap
73that is missing. Install the missing package and try ./autogen.sh again.
74
75It is possible that you may need to provide some options to ./configure
76to customize your installation.
77
78In particular you may need to define which (D)TLS library to use as well as
79disable some building of documentation.
80
81General configure instructions can be found in INSTALL, which is built
82by ./autogen.sh
83
84 ./configure --help
85gives the specific options available to libcoap.
86
87Some examples are:-
88
89# No DTLS
90 ./configure --enable-tests --disable-documentation --enable-examples --disable-dtls --enable-shared
91
92# With TinyDTLS
93 ./configure --enable-tests --disable-documentation --enable-examples --with-tinydtls --enable-shared
94
95Note: FreeBSD requires gmake instead of make when building TinyDTLS - i.e.
96 gmake
97 sudo gmake install
98
99# With OpenSSL
100 ./configure --with-openssl --enable-tests --enable-shared
101
102# With GnuTLS
103 ./configure --with-gnutls --enable-tests --enable-shared
104
105Note: --disable-documentation disables the building of doxygen and man page
106files.  If you want to only disable one of them, use --disable-doxygen or
107--disable-manpages.  Doxygen requires the program doxygen and man pages require
108the program a2x to build the appropriate files.
109
110If you need to rebuild the libcoap-*.{map,sym} files to update any exposed
111function changes, run
112
113 make update-map-file
114
115prior to running 'make'.
116
117LwIP
118====
119
120 ./autogen.sh
121 ./configure --disable-tests --disable-documentation --disable-examples --disable-dtls
122 cd examples/lwip
123 make
124
125Executable is ./server. See examples/lwip/README for further information
126
127Contiki
128=======
129
130 ./autogen.sh
131 ./configure --disable-tests --disable-documentation --disable-examples --disable-dtls
132 cd examples/contiki
133 make
134
135Executable is ./server.minimal-net. See examples/contiki/README for further
136information
137
138Windows
139=======
140
141Install OpenSSL (minimum version 1.1.0) including the development libraries if
142not already installed.
143
144Within Visual Studio, "Clone or check out code" using the repository
145https://github.com/obgm/libcoap.git
146
147You may need to update the SDK version of the libcoap Windows Project files to
148match that of the SDK version of the Visual Studio you are using.  In Solution
149Explorer with the view set to libcoap.sln, right click "Solution 'libcoap'"
150and then "Retarget solution".
151
152You may need to edit win32\libcoap.props to update the OpenSSLRootDir and
153OpenSSLRootDirDbg variables to point to the top level directory where OpenSSL
154is installed so that the include, lib etc. directories are correctly set up.
155Note: Make sure that you include a trailing \ in the variable definitions.
156
157Alternatively you can build everything in Visual Studio with CMake.
158