museek-plus icon indicating copy to clipboard operation
museek-plus copied to clipboard

Build on macOS broken

Open rien333 opened this issue 7 years ago • 3 comments

If I run make after having run cmake, I get the following error:

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/functional:1045:13: error:
      no matching constructor for initialization of 'binder1st<std::__1::mem_fun1_t<void, Museek::PeerManager,
      NewNet::ClientSocket *> >'
    {return binder1st<__Operation>(__op, __x);}

https://github.com/eLvErDe/museek-plus/issues/29#issuecomment-274582265 suggests that this has to do with the gcc on macOS, but setting both CC and CXX to the GNU gcc within cmake results in the same error. I think it rather seems to do with an error in an include file. https://github.com/eLvErDe/museek-plus/issues/29#issuecomment-276313015 found a temporary workaround that involves uncommenting the erroneous lines, but is unsure of the consequences of this action, which sounds pretty scary to me. (maybe somebody can at least give some insights on what commenting this line will do) I am also not quite sure what lines exactly I have to comment out.

rien333 avatar Jan 13 '18 15:01 rien333

This appears to be a clang error, rather than OS specific, as it happens on FreeBSD as well. Note that depending on which version of OSX you are using, the "gcc" command is mapped to clang, so setting CC/CXX most likely has no affect for you.

The full error text is:

/usr/include/c++/v1/functional:1048:13: error: no matching constructor for initialization of 'binder1st<:__1::mem_fun1_t museek::peermanager newnet::clientsocket> >'
    {return binder1st<__operation>(__op, __x);}
            ^                      ~~~~~~~~~
/root/museek-plus/./NewNet/nnevent.h:147:16: note: in instantiation of function template specialization 'std::__1::bind1st<:__1::mem_fun1_t museek::peermanager newnet::clientsocket>, Museek::PeerSocket *>' requested here
          std::bind1st(std::mem_fun(m_Method), m_Object)(t);
               ^
/root/museek-plus/./NewNet/nnevent.h:123:7: note: in instantiation of member function 'NewNet::Event<:clientsocket>::BoundCallback<:peersocket void>::operator()' requested
      here
      BoundCallback(ObjectType * object, MethodType method)
      ^
/root/museek-plus/./NewNet/nnevent.h:223:18: note: in instantiation of member function 'NewNet::Event<:clientsocket>::BoundCallback<:peersocket void>::BoundCallback'
      requested here
      return new BoundCallback(object, method);
                 ^
/root/museek-plus/./NewNet/nnevent.h:233:22: note: in instantiation of function template specialization 'NewNet::Event<:clientsocket>::bind<:peersocket void>' requested
      here
      return connect(bind(object, method));
                     ^
/root/museek-plus/museekd/peersocket.cpp:519:57: note: in instantiation of function template specialization 'NewNet::Event<:clientsocket>::connect<:peersocket void>'
      requested here
    m_CannotConnectOurselfCallback = cannotConnectEvent.connect(this, & PeerManager::onCannotConnectOurself);
                                                        ^
/usr/include/c++/v1/functional:1033:31: note: candidate constructor not viable: no known conversion from 'Museek::PeerSocket *const' to 'const typename mem_fun1_t::first_argument_type'
      (aka 'Museek::PeerManager *const') for 2nd argument
    _LIBCPP_INLINE_VISIBILITY binder1st(const __Operation& __x,
                              ^
/usr/include/c++/v1/functional:1025:28: note: candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 2 were provided
class _LIBCPP_TEMPLATE_VIS binder1st
                           ^
/usr/include/c++/v1/functional:1025:28: note: candidate constructor (the implicit move constructor) not viable: requires 1 argument, but 2 were provided
1 error generated.
*** Error code 1

ascl00 avatar Feb 09 '19 21:02 ascl00

I am able to build successfully with a minor change, however I have not looked closely enough to determine if it is correct or not:

diff --git a/museekd/peersocket.cpp b/museekd/peersocket.cpp
index 8db1e8b..58796fb 100644
--- a/museekd/peersocket.cpp
+++ b/museekd/peersocket.cpp
@@ -516,7 +516,7 @@ Museek::PeerSocket::initiateOurself()
     HInitiate handshake(museekd()->server()->username(), type(), token());
     sendMessage(handshake.make_network_packet());
 
-    m_CannotConnectOurselfCallback = cannotConnectEvent.connect(this, & PeerManager::onCannotConnectOurself);
+    m_CannotConnectOurselfCallback = cannotConnectEvent.connect(museekd()->peers(), & PeerManager::onCannotConnectOurself);
 
     uint port = museekd()->peers()->peerFactory()->serverSocket()->listenPort();

ascl00 avatar Feb 09 '19 22:02 ascl00

This appears to be a clang error, rather than OS specific, as it happens on FreeBSD as well. Note that depending on which version of OSX you are using, the "gcc" command is mapped to clang, so setting CC/CXX most likely has no affect for you.

For clarity, I am aware of this mapping and I specifically set CC to GNU gcc which I downloaded from homebrew. Still didn't work, and past instances of setting CC in this way have worked successfully.

Odd that it happens on FreeBSD as well, although macOS is somewhat BSD related.

rien333 avatar Feb 10 '19 00:02 rien333