aldebaran / libqi

NAOqi core framework
http://doc.aldebaran.com/libqi/
BSD 3-Clause "New" or "Revised" License
66 stars 53 forks source link

Fixed compliation issues on Ubuntu 22.04 with Boost 1.74 & 1.77 #36

Closed souljaboy764 closed 2 years ago

souljaboy764 commented 2 years ago

I was running into issues compiling libqi (Until commit aldebaran/libqi@8899fb2fb18b84ae96ce04973eef0f8330b0ea65) on Ubuntu 22.04 with Boost 1.74 (installed via apt) and also later with Boost 1.77 (locally installed for libqi-python).

Summary of issues and fixes:

After these changes, I was able to successfully compile and install libqi (Compile log) and also separately with Boost 1.77 by specifying BOOST_ROOT to point to the local installation (Compile log). I tested this on a Pepper robot after compiling libqi-python with libqi after the above changes and was able to move the robot.

nyibbang commented 2 years ago

Hello. Thank you for your contribution. We have a review process outside of Github so we cannot merge your pull request directly in here.

Initially there were issues with std::placeholders (Compile log) which got fixed after including <boost/bind.hpp>and changing them to boost::placeholders.

Note that we currently only support Boost 1.77 and Ubuntu 20.04 (with gcc/g++ 9.4), and we haven't had issues with std::placeholders or missing includes in our builds. Although I don't think we'll replace uses of std::placeholders with boost::placeholders, we'll see to add the missing include.

Then there were issues with linking Boost Regex (Compile log) which were caused due to not adding BOOST_REGEX in CMakeLists.txt for linking the libraries.

The functions you seem to have undefined references to should be compiled inside your binary, since they are template functions (such as boost::cpp_regex_traits<char>::toi(char const*&, char const*, int) const which is defined in boost/regex/v5/cpp_regex_traits.hpp). This could be a change in behavior in the compiler or due to a compilation flag. We'll see to add the missing library to our CMake files.

nyibbang commented 2 years ago

After looking into our changes more closely, we dropped the dependency to the boost regex library because the library became header-only since Boost 1.76.

You can check the changelog for Boost here

Regex
    - Regex is now header only except in C++03 mode.
    - Support for C++03 is now deprecated.
    - The library can now be used "standalone" without the rest of Boost being present.

Therefore linking to it in Boost 1.77 should not be required.

Furthermore, the boost/bind.hpp should not be used anymore as it defines the boost placeholders (_1, _2, ...) in the global namespace, and produces a warning unless BOOST_BIND_GLOBAL_PLACEHOLDERS is defined, which should be avoided. To keep compatibility with our users code, we added this define in our public headers:

+#define BOOST_BIND_GLOBAL_PLACEHOLDERS
 #include <boost/bind.hpp>
+#undef BOOST_BIND_GLOBAL_PLACEHOLDERS

But we changed our private files to use std::placeholders and to include boost/bind/bind.hpp instead.

You may take a look at the commit fb3a5b5b0 of porting Boost to 1.77 for more details on all changes we introduced.

souljaboy764 commented 2 years ago

Ah, my apologies, I just tried it without any modifications with Boost 1.77 and it worked out of the box. The placeholders and regex issues were coming only when using Boost 1.74 which was the default available one via apt. Thanks for the comments!