Skip to content

Commit 3631bce

Browse files
committed
Updated build instructions in the README
1 parent 26f4948 commit 3631bce

File tree

1 file changed

+35
-39
lines changed

1 file changed

+35
-39
lines changed

README.md

Lines changed: 35 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ To keep up with the latest announcements for this project, or to ask questions:
3636

3737
### What's New in v1.4.0
3838

39-
The v1.4 release is primarily concerned with reorganizing the sources and fixing a number of CMake build issues, particularly to get the Paho C submodule build working with the existing C library, fix transient dependencies, and get the Windows DLL (maybe, finally) working properly.
39+
The v1.4.0 release is primarily concerned with reorganizing the sources and fixing a number of CMake build issues, particularly to get the Paho C submodule build working with the existing C library, fix transient dependencies, and get the Windows DLL (maybe, finally) working properly.
4040

4141
- Ability to build the Paho C library automatically (now working)
4242
- Reworked the CMake build so that 'PAHO_WITH_MQTT_C' option properly compiles the existing Paho C v1.3.13
@@ -74,9 +74,9 @@ CMake allows for options to direct the build. The following are specific to Paho
7474

7575
Variable | Default Value | Description
7676
------------ | ------------- | -------------
77-
PAHO_BUILD_SHARED | TRUE (Linux), FALSE (Win32) | Whether to build the shared library
78-
PAHO_BUILD_STATIC | FALSE (Linux), TRUE (Win32) | Whether to build the static library
79-
PAHO_WITH_SSL | TRUE (Linux), FALSE (Win32) | Whether to build SSL/TLS support into the library
77+
PAHO_BUILD_SHARED | TRUE (*nix), FALSE (Win32) | Whether to build the shared library
78+
PAHO_BUILD_STATIC | FALSE (*nix), TRUE (Win32) | Whether to build the static library
79+
PAHO_WITH_SSL | TRUE (*nix), FALSE (Win32) | Whether to build SSL/TLS support into the library
8080
PAHO_BUILD_DOCUMENTATION | FALSE | Create the HTML API documentation (requires _Doxygen_)
8181
PAHO_BUILD_EXAMPLES | FALSE | Whether to build the example programs
8282
PAHO_BUILD_TESTS | FALSE | Build the unit tests. (Requires _Catch2_)
@@ -85,6 +85,25 @@ PAHO_WITH_MQTT_C | FALSE | Whether to build the bundled Paho C library
8585

8686
In addition, the C++ build might commonly use `CMAKE_PREFIX_PATH` to help the build system find the location of the Paho C library.
8787

88+
### Build the Paho C++ and Paho C libraries together
89+
90+
The quickest and easiest way to build Paho C++ is to buid it together with Paho C in a single step using the included Git submodule.
91+
This requires the CMake option `PAHO_WITH_MQTT_C` set.
92+
93+
```
94+
$ git clone https://github.com/eclipse/paho.mqtt.cpp
95+
$ cd paho.mqtt.cpp
96+
$ git co v1.4.0
97+
98+
$ git submodule init
99+
$ git submodule update
100+
101+
$ cmake -Bbuild -H. -DPAHO_WITH_MQTT_C=ON -DPAHO_BUILD_EXAMPLES=ON
102+
$ sudo cmake --build build/ --target install
103+
```
104+
105+
This assumes the build tools and dependencies, such as OpenSSL, have already been installed. For more details and platform-specific requirements, see below.
106+
88107
### Unix and Linux
89108

90109
On *nix systems CMake creates Makefiles.
@@ -118,9 +137,7 @@ _Catch2_ can be found here: [Catch2](https://github.com/catchorg/Catch2). You m
118137

119138
#### Building the Paho C library
120139

121-
The Paho C library can be built automatically when building this library by enabling the CMake build option, `PAHO_WITH_MQTT_C`. That will build and install the Paho C library from a Git submodule, using a known-good version, and the proper build configuration for the C++ library.
122-
123-
If you want to manually specify the build configuration of the Paho C library or use a different version, then it must be built and installed before building this library. Note, this version of the C++ library requires Paho C v1.3.13 or greater.
140+
The Paho C library can be built automatically when building this library by enabling the CMake build option, `PAHO_WITH_MQTT_C`. That will build and install the Paho C library from a Git submodule, using a known-good version, and the proper build configuration for the C++ library. But iIf you want to manually specify the build configuration of the Paho C library or use a different version, then it must be built and installed before building the C++ library. Note, this version of the C++ library requires Paho C v1.3.13 or greater.
124141

125142
To download and build the Paho C library:
126143

@@ -129,10 +146,8 @@ $ git clone https://github.com/eclipse/paho.mqtt.c.git
129146
$ cd paho.mqtt.c
130147
$ git checkout v1.3.13
131148
132-
$ cmake -Bbuild -H. -DPAHO_ENABLE_TESTING=OFF -DPAHO_BUILD_STATIC=ON \
133-
-DPAHO_WITH_SSL=ON -DPAHO_HIGH_PERFORMANCE=ON
149+
$ cmake -Bbuild -H. -DPAHO_ENABLE_TESTING=OFF -DPAHO_WITH_SSL=ON -DPAHO_HIGH_PERFORMANCE=ON
134150
$ sudo cmake --build build/ --target install
135-
$ sudo ldconfig
136151
```
137152

138153
This builds the C library with SSL/TLS enabled. If that is not desired, omit the `-DPAHO_WITH_SSL=ON`.
@@ -142,7 +157,7 @@ It also uses the "high performance" option of the C library to disable more exte
142157
The above will install the library to the default location on the host, which for Linux is normally `/usr/local`. To install the library to a non-standard location, use the `CMAKE_INSTALL_PREFIX` to specify a location. For example, to install into a directory under the user's home directory, perhaps for local testing, do this:
143158

144159
```
145-
$ cmake -Bbuild -H. -DPAHO_ENABLE_TESTING=OFF -DPAHO_BUILD_STATIC=ON \
160+
$ cmake -Bbuild -H. -DPAHO_ENABLE_TESTING=OFF \
146161
-DPAHO_WITH_SSL=ON -DPAHO_HIGH_PERFORMANCE=ON \
147162
-DCMAKE_INSTALL_PREFIX=$HOME/install
148163
```
@@ -154,25 +169,24 @@ If the Paho C library is not already installed, the recommended version can be b
154169
```
155170
$ git clone https://github.com/eclipse/paho.mqtt.cpp
156171
$ cd paho.mqtt.cpp
172+
$ git co v1.4.0
173+
$ git submodule init
174+
$ git submodule update
157175
158-
$ cmake -Bbuild -H. -DPAHO_WITH_MQTT_C=ON -DPAHO_BUILD_STATIC=ON \
159-
-DPAHO_BUILD_DOCUMENTATION=ON -DPAHO_BUILD_EXAMPLES=ON
176+
$ cmake -Bbuild -H. -DPAHO_WITH_MQTT_C=ON -DPAHO_BUILD_EXAMPLES=ON
160177
$ sudo cmake --build build/ --target install
161-
$ sudo ldconfig
162178
```
163179

164180
If a recent version of the Paho C library is available on the build host, and it's installed to a default location, it does not need to be built again. Omit the `PAHO_WITH_MQTT_C` option:
165181

166182
```
167-
$ cmake -Bbuild -H. -DPAHO_BUILD_STATIC=ON \
168-
-DPAHO_BUILD_DOCUMENTATION=ON -DPAHO_BUILD_SAMPLES=ON
183+
$ cmake -Bbuild -H. -DPAHO_BUILD_SAMPLES=ON
169184
```
170185

171186
If the Paho C library is installed to a _non-default_ location, or you want to build against a different version, use the `CMAKE_PREFIX_PATH` to specify its install location. Perhaps something like this:
172187

173188
```
174-
$ cmake -Bbuild -H. -DPAHO_BUILD_STATIC=ON \
175-
-DPAHO_BUILD_DOCUMENTATION=ON -DPAHO_BUILD_SAMPLES=ON \
189+
$ cmake -Bbuild -H. -DPAHO_BUILD_SAMPLES=ON \
176190
-DCMAKE_PREFIX_PATH=$HOME/install
177191
```
178192

@@ -205,17 +219,9 @@ It's better not to mix DLLs and static libraries, but if you do link the Paho C+
205219

206220
The build process currently supports a number Windows versions. The build process requires the following tools:
207221
* CMake GUI v3.5 or newer
208-
* Visual Studio 2015 or newer
209-
210-
First install and open the cmake-gui application. This tutorial is based on cmake-gui 3.5.2.
211-
212-
Second, select the path to the Paho MQTT C library (CMAKE_PREFIX_PATH) if not installed in a standard path. Remember that the Paho MQTT C must be installed on the system. Next, choose if it is supposed to build the documentation (PAHO_BUILD_DOCUMENTATION) and/or the sample applications (PAHO_BUILD_SAMPLES).
213-
214-
Once the configuration is done, click on the Configure button, select the version of the Visual Studio, and then click on Generate button.
222+
* Visual Studio 2017 or newer
215223

216-
At the end of this process you have a Visual Studio solution.
217-
218-
Alternately, the libraries can be completely built at an MSBuild Command Prompt. Download the Paho C and C++ library sources, then open a command window and first compile the Paho C library:
224+
The libraries can be completely built at an MSBuild Command Prompt. Download the Paho C and C++ library sources, then open a command window and first compile the Paho C library:
219225

220226
> cd paho.mqtt.c
221227
> cmake -Bbuild -H. -DCMAKE_INSTALL_PREFIX=C:\mqtt\paho-c
@@ -238,16 +244,6 @@ For MSVS 2019 and beyond:
238244
> cmake -G "Visual Studio 16 2019" -Ax64 -Bbuild -H. -DCMAKE_INSTALL_PREFIX=C:\mqtt\paho-c
239245
> ...
240246

241-
For Visual Studio 2015 which is v14 do this to first build the Paho C library:
242-
243-
> cmake -G "Visual Studio 14 Win64" -Bbuild -H. -DCMAKE_INSTALL_PREFIX=C:\mqtt\paho-c
244-
...
245-
246-
Then use it to build the C++ library:
247-
248-
> cmake -G "Visual Studio 14 Win64" -Bbuild -H. -DCMAKE_INSTALL_PREFIX=C:\mqtt\paho-cpp -DPAHO_WITH_SSL=OFF -DCMAKE_PREFIX_PATH=C:\mqtt\paho-c
249-
...
250-
251247
*Note that it is very important that you use the same generator (target) to build BOTH libraries, otherwise you will get lots of linker errors when you try to build the C++ library.*
252248

253249
## Supported Network Protocols
@@ -305,7 +301,7 @@ int main(int argc, char* argv[])
305301
callback cb;
306302
cli.set_callback(cb);
307303

308-
auto connOpts = mqtt::connect_options_builder()
304+
auto connOpts = mqtt::connect_options_builder()
309305
.keep_alive_interval(20);
310306
.clean_session()
311307
.finalize();

0 commit comments

Comments
 (0)