Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Confusion with oudated installation instructions - can't find paho-mqtt3a #504

Open
javezbak opened this issue Jul 10, 2024 · 14 comments
Open
Milestone

Comments

@javezbak
Copy link

Installing Paho C

The shell script and README instructions both say to checkout v1.3.13 from the C library. This branch does not exist.

Installing Paho C++

The README (in 2 places) says to checkout v1.4.0. This branch also does not exist, but I can reasonably assume in this case to use v1.4.x.

Further Confusion

These two README sections are almost identical. I think they could probably be merged into one.

Attempting to Install

When I follow the installation instructions (with branch v1.4.x) I get this output:

$ cmake -Bbuild -H. -DPAHO_WITH_MQTT_C=ON -DPAHO_BUILD_EXAMPLES=ON
-- The C compiler identification is GNU 7.5.0
-- The CXX compiler identification is GNU 7.5.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found OpenSSL: /usr/lib/x86_64-linux-gnu/libcrypto.so (found version "1.1.1") 
-- Paho C: Bundled
-- CMake version: 3.10.2
-- CMake system name: Linux
-- Timestamp is 2024-07-10T16:55:59Z
CMake Error at CMakeLists.txt:93 (install):
  install TARGETS given target "paho-mqtt3a" which does not exist in this
  directory.


-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Check if compiler accepts -pthread
-- Check if compiler accepts -pthread - yes
-- Found Threads: TRUE  
-- Configuring incomplete, errors occurred!
See also "/home/javezbak/Desktop/gitlab/paho.mqtt.cpp/build/CMakeFiles/CMakeOutput.log".
See also "/home/javezbak/Desktop/gitlab/paho.mqtt.cpp/build/CMakeFiles/CMakeError.log".

It looks like something is going wrong with paho-mqtt3a. I'm not sure what I'm doing wrong. Any help is appreciated. Thanks.

@fpagliughi
Copy link
Contributor

Sorry for the confusion, but... did you actually try the instructions? They do work.

The shell script and README instructions both say to checkout v1.3.13 from the C library. This branch does not exist.

v1.3.13 is not a branch. It is a tag. You can check it out, just as the instructions state. When you do, Git will tell you that you're in a "detached state". That's OK.

The README (in 2 places) says to checkout v1.4.0. This branch also does not exist, but I can reasonably assume in this case to use v1.4.x.

Similarly, v1.4.0 (and, as of a day or two ago v1.4.1) is a tag, not a branch. You can check out the tag.

v1.4.x is a running branch for changes to the v1.4 release. At any given time, it might contain untested updates that are destined for the next v1.4 release (v1.4.2, next). So it should not be used as a stable place to get production code.

When I follow the installation instructions (with branch v1.4.x) I get this output:

Try the current recommended way of building both the libraries together. This builds the Paho C library from a Git submodule in the C++ workspace:
https://github.com/eclipse/paho.mqtt.cpp?tab=readme-ov-file#build-the-paho-c-and-paho-c-libraries-together

Further Confusion

Yeah, this has been evolving quickly with the last few releases. It would probably be better if I just show the new, recommended way to build the library, and move the detailed instructions to another "for more information" document.

@javezbak
Copy link
Author

javezbak commented Jul 10, 2024

Hi, sorry about the confusion regarding tags. I thought checkout worked exclusively for branches. My bad.

However, I tried doing it exactly as described in the README, and I get the same error.

Is this issue related to this PR? eclipse-paho/paho.mqtt.c#1495
It looks like that was meant to resolve a similar issue someone was having, but the change is only in develop. I am not super familiar with the submodule command. Would this be resolved if I pointed my paho C repo to the develop branch?

@javezbak
Copy link
Author

I managed to get things working with the following steps:

git clone https://github.com/eclipse/paho.mqtt.c.git
cd paho.mqtt.c
git checkout v1.3.13
cmake -Bbuild -H. -DPAHO_ENABLE_TESTING=OFF -DPAHO_WITH_SSL=ON -DPAHO_HIGH_PERFORMANCE=ON
sudo cmake --build build/ --target install
cd ..
git clone https://github.com/eclipse/paho.mqtt.cpp.git
cd paho.mqtt.cpp
git checkout 922e866f4ff4c02f8d488f1426f806cbed603e5d
cmake -Bbuild -H. -DPAHO_BUILD_EXAMPLES=ON
sudo cmake --build build/ --target install

@fpagliughi
Copy link
Contributor

fpagliughi commented Jul 11, 2024

I've been working in the v1.4.x branch this week, and haven't seen this problem, which is odd since you seem to be working in Linux. (Windows always causes headaches).

I'm going to keep this open until I can get to the bottom of the problem.

But I suspect that I may have kept the develop branch of the C lib checked when I was testing the v1.4.1 release the other day. I've been writing the new v1.5 against the develop branch and may not have reverted it back when I went to v1.4.

But I'll verify that and fix it as needed.

@fpagliughi fpagliughi reopened this Jul 11, 2024
@fpagliughi fpagliughi added this to the v.1.4.2 milestone Jul 11, 2024
@fpagliughi
Copy link
Contributor

Still haven't been able to reproduce this. I mostly have variations of fairly recent Linux Mint and Ubuntu on my dev machines.

What platform are you using? Your tools & libs are a little old (~5yrs) but well within the known versions that work.

@fpagliughi fpagliughi added the cant reproduce Unable to reproduce label Jul 13, 2024
@javezbak
Copy link
Author

I'm on Ubuntu 18.04

@fpagliughi
Copy link
Contributor

fpagliughi commented Jul 15, 2024

Ubuntu 18.04 should work fine. I don't have a version of it on a current development machine, but 20.04 and 22.04 are similar with some slightly newer tools... though that really shouldn't matter.

To test, I've been trying a fresh download, build, and install in the /tmp directory to try and make sure I don't have any weird artifacts in my normal development tree. Just for completeness, this is what I'm seeing (doing the PAHO_WITH_MQTT_C thing).

Note that I didn't want to pollute my dev machine with an installed system copy of the libs in /usr/local, so I did a separate install step to write the libs into a local directory under my build tree (just as a sanity check).

$ git clone https://github.com/eclipse/paho.mqtt.cpp.git
Cloning into 'paho.mqtt.cpp'...
...
$ cd paho.mqtt.cpp/

$ git co v1.4.1
Note: switching to 'v1.4.1'.

You are in 'detached HEAD' state....       <-- This is OK
...

$ git submodule init
Submodule 'src/externals/paho-mqtt-c' (https://github.com/eclipse/paho.mqtt.c.git) registered for path 'externals/paho-mqtt-c'

$ git submodule update
Cloning into '/tmp/paho.mqtt.cpp/externals/paho-mqtt-c'...
Submodule path 'externals/paho-mqtt-c': checked out '07a875788d8cc6f5833b12581d6e3e349b34d719'


# Just verify that we have the right Paho C version in the submodule (v1.3.13)
$ cd externals/paho-mqtt-c/
$ git log -1 HEAD
commit 07a875788d8cc6f5833b12581d6e3e349b34d719 (HEAD, tag: v1.3.13)       <---- ** Verify C v.1.3.13 **
Merge: 3e83c02 8cf971c
Author: Ian Craggs <[email protected]>
Date:   Fri Oct 13 18:18:52 2023 +0100

    Merge branch 'develop'
$ cd ../..

$ cmake -Bbuild -H. -DPAHO_WITH_MQTT_C=ON -DPAHO_BUILD_EXAMPLES=ON
-- The C compiler identification is GNU 12.3.0
-- The CXX compiler identification is GNU 12.3.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found OpenSSL: /usr/lib/x86_64-linux-gnu/libcrypto.so (found version "3.0.2")  
-- Paho C: Bundled
-- CMake version: 3.22.1
-- CMake system name: Linux
-- Timestamp is 2024-07-15T15:42:40Z
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE  
-- Configuring done
-- Generating done
-- Build files have been written to: /tmp/paho.mqtt.cpp/build

$ cmake --build build/
...(Clean build except a few warnings in the C lib about obsolete SHA1 functions in OpenSSL)...

$ cmake --install build/ --prefix ./usr/local
-- Install configuration: ""
-- Installing: /tmp/paho.mqtt.cpp/./usr/local/lib/libpaho-mqtt3a.so.1.3.13
-- Installing: /tmp/paho.mqtt.cpp/./usr/local/lib/libpaho-mqtt3a.so.1
-- Installing: /tmp/paho.mqtt.cpp/./usr/local/lib/libpaho-mqtt3a.so
-- Installing: /tmp/paho.mqtt.cpp/./usr/local/lib/libpaho-mqtt3as.so.1.3.13
-- Installing: /tmp/paho.mqtt.cpp/./usr/local/lib/libpaho-mqtt3as.so.1
-- Installing: /tmp/paho.mqtt.cpp/./usr/local/lib/libpaho-mqtt3as.so
...
-- Installing: /tmp/paho.mqtt.cpp/./usr/local/lib/cmake/PahoMqttCpp/PahoMqttCppTargets.cmake
-- Installing: /tmp/paho.mqtt.cpp/./usr/local/lib/cmake/PahoMqttCpp/PahoMqttCppTargets-noconfig.cmake
-- Installing: /tmp/paho.mqtt.cpp/./usr/local/lib/cmake/PahoMqttCpp/PahoMqttCppConfig.cmake
-- Installing: /tmp/paho.mqtt.cpp/./usr/local/lib/cmake/PahoMqttCpp/PahoMqttCppConfigVersion.cmake

$ tree -d ./usr/local/
./usr/local/
├── bin
├── include
│   └── mqtt
├── lib
│   └── cmake
│       ├── eclipse-paho-mqtt-c
│       └── PahoMqttCpp
└── share
    └── doc
        └── Eclipse Paho C
            └── samples

11 directories

@VicdVud
Copy link

VicdVud commented Jul 16, 2024

I also compiled it in Ubuntu 18.04 and had the same problem, The following is the log output

$ git clone https://github.com/eclipse/paho.mqtt.cpp.git
...
$ cd paho.mqtt.cpp/
$ git checkout v1.4.1
Note: checking out 'v1.4.1'.

You are in 'detached HEAD' state.
...
HEAD is now at c310578 Updated version, README, and CHANGELOG for v1.4.1 release.

$ git submodule init
Submodule 'src/externals/paho-mqtt-c' (https://github.com/eclipse/paho.mqtt.c.git) registered for path 'externals/paho-mqtt-c'

$ git submodule update
Cloning into '/home/xxx/thirdparty/paho.mqtt.cpp/externals/paho-mqtt-c'...
Submodule path 'externals/paho-mqtt-c': checked out '07a875788d8cc6f5833b12581d6e3e349b34d719'

$ cd externals/paho-mqtt-c/
$ git log -1 HEAD
commit 07a875788d8cc6f5833b12581d6e3e349b34d719 (HEAD, tag: v1.3.13)
Merge: 3e83c02 8cf971c
Author: Ian Craggs <[email protected]>
Date:   Fri Oct 13 18:18:52 2023 +0100

    Merge branch 'develop'

$ cd ../..
$ cmake -Bbuild -H. -DPAHO_WITH_MQTT_C=ON -DPAHO_BUILD_EXAMPLES=ON
-- The C compiler identification is GNU 7.5.0
-- The CXX compiler identification is GNU 7.5.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found OpenSSL: /usr/lib/x86_64-linux-gnu/libcrypto.so (found version "1.1.1")
-- Paho C: Bundled
-- CMake version: 3.10.2
-- CMake system name: Linux
-- Timestamp is 2024-07-16T06:30:32Z
CMake Error at CMakeLists.txt:93 (install):
  install TARGETS given target "paho-mqtt3a" which does not exist in this
  directory.


-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Check if compiler accepts -pthread
-- Check if compiler accepts -pthread - yes
-- Found Threads: TRUE
-- Configuring incomplete, errors occurred!
See also "/home/xxx/thirdparty/paho.mqtt.cpp/build/CMakeFiles/CMakeOutput.log".
See also "/home/xxx/thirdparty/paho.mqtt.cpp/build/CMakeFiles/CMakeError.log".

@VicdVud
Copy link

VicdVud commented Jul 16, 2024

I found the problem, in cmake 3.13,a new feature was added: INSTALL(TARGETS) works outside the current directory. See https://cmake.org/cmake/help/v3.13/release/3.13.html. So, just upgrade CMake to 3.13 or newer, it works well.

@fpagliughi
Copy link
Contributor

fpagliughi commented Jul 16, 2024

Wow. Thanks, @VicdVud! I probably would never have found that.

@javezbak, would you be able to upgrade your cmake version and try to see if that fixes the problem for you?

If so, I will just bump the minimum required CMake in the build files.

@tarcuri
Copy link

tarcuri commented Jul 16, 2024

Wow. Thanks, @VicdVud! I probably would never have found that.

@javezbak, would you be able to upgrade your cmake version and try to see if that fixes the problem for you?

If so, I will just bump the minimum required CMake in the build files.

I am not expecting a fix just for me, but as it turns out I'm cross compiling with a rather outdated SDK that only has cmake 3.12.2, so I appear to be experiencing this same issue. I coincidentally stumbled onto this today, but for some reason I was able to build this 2 months ago (or thereabouts).

EDIT: I was able to work around my particular issue by installing the C library manually to my SDK sysroot, and then specifying that path when configuring the CPP library (-DCMAKE_MODULE_PATH=/path/to/SDK/sysroot/usr/lib).

Anyway, I appreciate the effort on the project!

@fpagliughi fpagliughi removed the cant reproduce Unable to reproduce label Jul 16, 2024
@fpagliughi
Copy link
Contributor

I suppose something was added to the v1.4.x line in the last few months that broke the build for CMake versions < 3.13?

I'll have a look and see if I can figure out a work-around without reintroducing the problem that I was attempting to fix. I'd like to keep the v1.4.x releases working with older build tools for people who can't (or don't want to) upgrade their toools.

The next version, v1.5, is going to jump to some newer tools. It will require a C++17 compiler and a version of CMake that supports C++17. I thought that was v3.12, so either way, I need the workaround, unless I just say v1.5 needs CMake v3.13.

@fpagliughi
Copy link
Contributor

BTW, I did confirm the problem with CMake v3.12. I built v3.12 and installed it on one of my dev machines (Mint 20/Ubuntu 20.04).

$  git clone https://gitlab.kitware.com/cmake/cmake.git
$  cd cmake/
$  git co v3.12.4

$  ./configure --prefix=/opt/cmake/cmake-3.12
$  make -j
$  sudo make install

$  /opt/cmake/cmake-3.12/bin/cmake --version
cmake version 3.12.4

Then I used that version to configure the build:

$ /opt/cmake/cmake-3.12/bin/cmake .. -DPAHO_WITH_MQTT_C=ON -DPAHO_BUILD_EXAMPLES=ON \
    -DPAHO_BUILD_TESTS=ON
...
CMake Error at CMakeLists.txt:93 (install):
  install TARGETS given target "paho-mqtt3a" which does not exist in this
  directory.

So I'll see what I can do to fix it.

@fpagliughi
Copy link
Contributor

fpagliughi commented Jul 16, 2024

Also... earlier versions of this library (< v1.1 c2019) had instructions for upgrading cmake, for back when Ubuntu 14 & 16 were still shipping with CMake v2.x. Basically, it said to rename the installed, old executable with the specific version number, like cmake-2.8, then build a newer version into /usr/local and set up to choose between them using update-alternatives.

See here:
https://github.com/eclipse/paho.mqtt.cpp/tree/v1.1?tab=readme-ov-file#updating-cmake-on-ubuntu-1404-or-1604

Nowadays I would think to install multiple, specific, versions to /opt/cmake using the --prefix configure options, and then set those up with update-alternatives. But a minor distinction.

That might help if anyone want to try an upgrade. If things don't work as hoped, you can always go back the original installed version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants