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

compile error with boost 1.66 #2034

Closed
stintel opened this issue Jan 2, 2018 · 13 comments
Closed

compile error with boost 1.66 #2034

stintel opened this issue Jan 2, 2018 · 13 comments

Comments

@stintel
Copy link

stintel commented Jan 2, 2018

Domoticz does not compile against boost 1.66:

[ 58%] Building CXX object CMakeFiles/domoticz.dir/hardware/PhilipsHue/PhilipsHue.cpp.o
In file included from /home/build/lede/staging_dir/target-x86_64_musl/usr/include/boost/asio/impl/write.hpp:25:0,
                 from /home/build/lede/staging_dir/target-x86_64_musl/usr/include/boost/asio/write.hpp:927,
                 from /home/build/lede/staging_dir/target-x86_64_musl/usr/include/boost/asio/buffered_write_stream.hpp:29,
                 from /home/build/lede/staging_dir/target-x86_64_musl/usr/include/boost/asio/buffered_stream.hpp:22,
                 from /home/build/lede/staging_dir/target-x86_64_musl/usr/include/boost/asio.hpp:41,
                 from /home/stijn/Development/LEDE/source/build_dir/target-x86_64_musl/domoticz-3.8153/hardware/PhilipsHue/../../main/../tcpserver/TCPClient.h:3,
                 from /home/stijn/Development/LEDE/source/build_dir/target-x86_64_musl/domoticz-3.8153/hardware/PhilipsHue/../../main/../tcpserver/TCPServer.h:4,
                 from /home/stijn/Development/LEDE/source/build_dir/target-x86_64_musl/domoticz-3.8153/hardware/PhilipsHue/../../main/mainworker.h:11,
                 from /home/stijn/Development/LEDE/source/build_dir/target-x86_64_musl/domoticz-3.8153/hardware/PhilipsHue/PhilipsHue.cpp:9:
/home/build/lede/staging_dir/target-x86_64_musl/usr/include/boost/asio/detail/consuming_buffers.hpp: In member function 'boost::asio::detail::consuming_buffers<Buffer, Buffers, Buffer_Iterator>::prepared_buffers_type boost::asio::detail::consuming_buffers<Buffer, Buffers, Buffer_Iterator>::prepare(std::size_t)':
/home/build/lede/staging_dir/target-x86_64_musl/usr/include/boost/asio/detail/consuming_buffers.hpp:105:65: error: '.' cannot appear in a constant-expression
     while (next != end && max_size > 0 && result.count < result.max_buffers)
                                                                 ^
/home/build/lede/staging_dir/target-x86_64_musl/usr/include/boost/asio/detail/consuming_buffers.hpp:105:50: error: parse error in template argument list
     while (next != end && max_size > 0 && result.count < result.max_buffers)
                                                  ^
make[5]: *** [CMakeFiles/domoticz.dir/build.make:2631: CMakeFiles/domoticz.dir/hardware/PhilipsHue/PhilipsHue.cpp.o] Error 1
make[5]: Leaving directory '/home/build/lede/build_dir/target-x86_64_musl/domoticz-3.8153'
make[4]: *** [CMakeFiles/Makefile2:106: CMakeFiles/domoticz.dir/all] Error 2
make[4]: Leaving directory '/home/build/lede/build_dir/target-x86_64_musl/domoticz-3.8153'
make[3]: *** [Makefile:152: all] Error 2
make[3]: Leaving directory '/home/build/lede/build_dir/target-x86_64_musl/domoticz-3.8153'
make[2]: *** [Makefile:111: /home/stijn/Development/LEDE/source/build_dir/target-x86_64_musl/domoticz-3.8153/.built] Error 2
make[2]: Leaving directory '/home/stijn/Development/LEDE/openwrt-packages/utils/domoticz'
make[1]: *** [package/Makefile:111: package/feeds/packages/domoticz/compile] Error 2
make[1]: Leaving directory '/home/stijn/Development/LEDE/source'
make: *** [/home/stijn/Development/LEDE/source/include/toplevel.mk:218: package/domoticz/compile] Error 2
@Siewert308SW
Copy link

Siewert308SW commented Jan 4, 2018

Don't think it's a Domoticz issue but rather a outdated repo issue.
As you didn't described how and on what hardware you are working i can't say anything which could solve it.
I see your on x86 but doesn't tell what your system is.

I have it working with the current repo working on my RPi3 with Raspbian Jessie.
Maybe i forgot something but link below is how setup my system.
https://www.domoticz.com/forum/viewtopic.php?f=6&t=19186&p=164346#p164340

@stintel
Copy link
Author

stintel commented Jan 4, 2018

It's with the 3.8153 release. Reverting boost to 1.65 makes the problem go away. Tried a couple of things to get it to build but did not succeed yet.

@HoekieN
Copy link
Contributor

HoekieN commented Jan 5, 2018

pi@raspberrypi:~ $ cd dev-domoticz/
pi@raspberrypi:~/ dev-domoticz $ git pull
Already up-to-date.
pi@raspberrypi:~/dev-domoticz $ CONF_SWAPFILE=1024
pi@raspberrypi:~/dev-domoticz $ make
[  1%] Built target sqlite
[ 13%] Built target lua
-- Found Git: /usr/bin/git (found version "2.11.0")
[ 13%] Built target revisiontag
[ 13%] Built target domoticz_gch
[ 20%] Built target mqtt
[ 20%] Linking CXX executable domoticz
CMakeFiles/domoticz.dir/main/mainworker.cpp.o: In function `MainWorker::SendResetCommand(CDomoticzHardwareBase*)':
mainworker.cpp:(.text+0x29d10): undefined reference to `boost::this_thread::hidden::sleep_until(timespec const&)'
mainworker.cpp:(.text+0x29d98): undefined reference to `boost::this_thread::hidden::sleep_until(timespec const&)'
CMakeFiles/domoticz.dir/main/mainworker.cpp.o: In function `MainWorker::OnHardwareConnected(CDomoticzHardwareBase*)':
mainworker.cpp:(.text+0x29e7c): undefined reference to `boost::this_thread::hidden::sleep_until(timespec const&)'
mainworker.cpp:(.text+0x29f04): undefined reference to `boost::this_thread::hidden::sleep_until(timespec const&)'
CMakeFiles/domoticz.dir/hardware/PiFace.cpp.o: In function `CPiFace::Do_Work()':
PiFace.cpp:(.text+0x46ac): undefined reference to `boost::this_thread::hidden::sleep_until(timespec const&)'
CMakeFiles/domoticz.dir/hardware/PiFace.cpp.o:PiFace.cpp:(.text+0x4b90): more undefined references to `boost::this_thread::hidden::sleep_until(timespec const&)' follow
collect2: error: ld returned 1 exit status
CMakeFiles/domoticz.dir/build.make:5914: recipe for target 'domoticz' failed
make[2]: *** [domoticz] Error 1
CMakeFiles/Makefile2:71: recipe for target 'CMakeFiles/domoticz.dir/all' failed
make[1]: *** [CMakeFiles/domoticz.dir/all] Error 2
Makefile:151: recipe for target 'all' failed
make: *** [all] Error 2

Had no problem with 1.65 then installed 1.66 and got this error.
Pi 3

pi@raspberrypi:~/dev-domoticz $ uname -a
Linux raspberrypi 4.9.59-v7+ #1047 SMP Sun Oct 29 12:19:23 GMT 2017 armv7l GNU/Linux
pi@raspberrypi:~/dev-domoticz $ cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 9 (stretch)"
NAME="Raspbian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"

@Siewert308SW
Copy link

Siewert308SW commented Jan 5, 2018

Stretch is giving me a big headache as besides compiling some other issues non Domoticz and Domoticz stuff giving me a hard time.
There for went back to Jessie where compiling even without boost 1.66 went flawless.
I know it aint the solution for you question.

@HoekieN
Copy link
Contributor

HoekieN commented Jan 5, 2018

Not a bad idea to go back to Jessie.

@vermeeren
Copy link

The update to boost 1.66 also caused issues on the Arch Linux package:
https://aur.archlinux.org/packages/domoticz-git

Here is a quick and dirty fix for compilation, but some domoticz code itself may also need minor refactoring to make it clean.

diff --git a/webserver/proxyclient.cpp b/webserver/proxyclient.cpp
index 6bd6b8771..646cfdeee 100644
--- a/webserver/proxyclient.cpp
+++ b/webserver/proxyclient.cpp
@@ -770,8 +770,8 @@ namespace http {
 		void CProxyManager::StartThread()
 		{
 			try {
-				//boost::asio::ssl::context ctx(io_service, boost::asio::ssl::context::tlsv12_client);
-				boost::asio::ssl::context ctx(io_service, boost::asio::ssl::context::sslv23);
+				//boost::asio::ssl::context ctx(boost::asio::ssl::context::tlsv12_client);
+				boost::asio::ssl::context ctx(boost::asio::ssl::context::sslv23);
 				ctx.set_verify_mode(boost::asio::ssl::verify_none);
 
 				proxyclient.reset(new CProxyClient(io_service, ctx, m_pWebEm));
diff --git a/webserver/server.cpp b/webserver/server.cpp
index fe001e811..c0eec2166 100644
--- a/webserver/server.cpp
+++ b/webserver/server.cpp
@@ -152,7 +152,7 @@ void server::handle_accept(const boost::system::error_code& e) {
 ssl_server::ssl_server(const ssl_server_settings & ssl_settings, request_handler & user_request_handler) :
 		server_base(ssl_settings, user_request_handler),
 		settings_(ssl_settings),
-		context_(io_service_, ssl_settings.get_ssl_method())
+		context_(ssl_settings.get_ssl_method())
 {
 #ifdef DEBUG_WWW
 	_log.Log(LOG_STATUS, "[web:%s] create ssl_server using ssl_server_settings : %s", ssl_settings.listening_port.c_str(), ssl_settings.to_string().c_str());
@@ -165,7 +165,7 @@ ssl_server::ssl_server(const ssl_server_settings & ssl_settings, request_handler
 ssl_server::ssl_server(const server_settings & settings, request_handler & user_request_handler) :
 		server_base(settings, user_request_handler),
 		settings_(dynamic_cast<ssl_server_settings const &>(settings)),
-		context_(io_service_, dynamic_cast<ssl_server_settings const &>(settings).get_ssl_method()) {
+		context_(dynamic_cast<ssl_server_settings const &>(settings).get_ssl_method()) {
 #ifdef DEBUG_WWW
 	_log.Log(LOG_STATUS, "[web:%s] create ssl_server using server_settings : %s", settings.listening_port.c_str(), settings.to_string().c_str());
 #endif

@cotequeiroz
Copy link

The patch above is needed to update the boost API.

However, even with the patch applied, domoticz will not compile with g++5; it compiles fine with g++6. Apparently, the boost header file boost/asio/detail/consuming_buffers.hpp triggers a parsing error in g++5. I'm not a c++ programmer, so excuse me if this explanation is not accurate. I figured g++ thinks it's a template invocation and chokes. To circumvent this, you can just add parenthesis around result_count in the header file. I have suggested that workaround to the boost developers. Meanwhile, you can apply the following patch to boost and domoticz will compile.

--- a/boost/asio/detail/consuming_buffers.hpp
+++ b/boost/asio/detail/consuming_buffers.hpp
@@ -102,7 +102,7 @@ public:

     std::advance(next, next_elem_);
     std::size_t elem_offset = next_elem_offset_;
-    while (next != end && max_size > 0 && result.count < result.max_buffers)
+    while (next != end && max_size > 0 && (result.count) < result.max_buffers)
     {
       Buffer next_buf = Buffer(*next) + elem_offset;
       result.elems[result.count] = boost::asio::buffer(next_buf, max_size);

buildroot-auto-update pushed a commit to buildroot/buildroot that referenced this issue Jan 15, 2018
Patch fetch from one of the answer of
 domoticz/domoticz#2034
(issue still opened, no official PR sent upstream)

Boost asio changed its API:
 - http://www.boost.org/doc/libs/1_66_0/doc/html/boost_asio/net_ts.html

Fixes:
 - http://autobuild.buildroot.net/results/5f02c8fc84889748f283ee1cb76248bb0880215a

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
woodsts pushed a commit to woodsts/buildroot that referenced this issue Jan 16, 2018
Fix domoticz build with boost 1.66 and g++5

Patch fetch from one of the answer of
 domoticz/domoticz#2034:
 workaround suggested to the boost developers

Fixes:
 - http://autobuild.buildroot.net/results/dec57c19e9aa2e367e23de2232c1d22a2f226a32

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
@jwakely
Copy link

jwakely commented Jan 23, 2018

This is a domoticz issue, because it's using a deprecated constructor that was removed in Boost 1.66.0.

@gizmocuz
Copy link
Contributor

best to follow our wiki
http://www.domoticz.com/wiki/Raspberry_Pi_-_Build_Domoticz_from_source

and this mentions 1.65 yes ... or just use the binary solution so you don't have to install boost

@stintel
Copy link
Author

stintel commented Jan 24, 2018

There is conflicting information, it also mentions to use the latest version of boost, which is now 1.66. But I guess rolling distros will just have to fix it downstream until upstream is compatible with >= 1.66.

@jwakely
Copy link

jwakely commented Jan 24, 2018

"Just use the binary solution" isn't an option for distros that ship binaries that they build themselves. I'm trying to upgrade Fedora to use a new Boost, and this means domocitz needs to be patched locally in Fedora, and every other distro that packages it. Obviously it would be better to fix it upstream.

@gizmocuz
Copy link
Contributor

I think the Domoticz binaries should run under Fedora.
Made some changes and Domoticz should now build with 1.66

@jwakely
Copy link

jwakely commented Jan 25, 2018

I think the Domoticz binaries should run under Fedora.

Fedora does not distribute upstream binaries, it rebuilds everything from source. Most distros work that way.

Made some changes and Domoticz should now build with 1.66

Great, thanks!

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

7 participants