SpectrumIM / spectrum2

Spectrum 2 IM transports
https://spectrum.im
409 stars 91 forks source link

2.0.13 fails to build on FreeBSD #388

Closed drook closed 4 years ago

drook commented 4 years ago

FreeBSD:

# uname -a
FreeBSD elf.hq.norma.perm.ru 12.1-RELEASE-p2 FreeBSD 12.1-RELEASE-p2 r358469 ELF  amd64

Compiler:

# clang -v
FreeBSD clang version 8.0.1 (tags/RELEASE_801/final 366581) (based on LLVM 8.0.1)
Target: x86_64-unknown-freebsd12.1
Thread model: posix
InstalledDir: /usr/bin

Swiften:

# swiften-config --version
swiften-config 5.0alpha2-dev114
[root@elf:spectrum-2.0.10/bin]# swiften-config --libs   
-L../../Swiften -L/usr/local/lib -lSwiften -lboost_system -lboost_thread -lboost_regex -lboost_program_options -lboost_filesystem -lboost_serialization -lboost_date_time -lz -lssl -lcrypto -lpthread -ldl -lm -lc -lstdc++

Tail of the build log:

[...]
[ 27%] Building CXX object libtransport/CMakeFiles/transport.dir/__/include/Swiften/Network/DummyConnectionServer.cpp.o
[ 27%] Building CXX object libtransport/CMakeFiles/transport.dir/__/include/Swiften/Network/DummyConnectionServerFactory.cpp.o                                                                                                                  
[ 28%] Building CXX object libtransport/CMakeFiles/transport.dir/__/include/Swiften/Network/DummyNetworkFactories.cpp.o
/home/emz/src/spectrum2-2.0.13/include/Swiften/Network/DummyNetworkFactories.cpp:32:32: error: allocating an object of
      abstract class type 'Swift::DummyConnectionServerFactory'
        connectionServerFactory = new DummyConnectionServerFactory(eventLoop);
                                      ^
/usr/local/swiften/include/Swiften/Network/ConnectionServerFactory.h:27:55: note: unimplemented pure virtual method
      'createConnectionServer' in 'DummyConnectionServerFactory'
            virtual std::shared_ptr<ConnectionServer> createConnectionServer(unsigned short port) = 0;
                                                      ^
/usr/local/swiften/include/Swiften/Network/ConnectionServerFactory.h:29:55: note: unimplemented pure virtual method
      'createConnectionServer' in 'DummyConnectionServerFactory'
            virtual std::shared_ptr<ConnectionServer> createConnectionServer(const Swift::HostAddress& hostAddre...
                                                      ^
1 error generated.
*** Error code 1

Stop.
make[2]: stopped in /usr/home/emz/src/spectrum2-2.0.13
*** Error code 1

Stop.
make[1]: stopped in /usr/home/emz/src/spectrum2-2.0.13
*** Error code 1

Stop.
make: stopped in /usr/home/emz/src/spectrum2-2.0.13
vitalyster commented 4 years ago

You have DummyConnectionServer(Factory) classes installed both from spectrum and swiften, swiften classes should not be installed system-wide, they are for tests only.

drook commented 4 years ago

To be honest, I don't quite understand this (but I have only shallow knowledge of C++). I have only Swiften headers system-wide installed (bunch of various *.h files installed by the Swiften installer, and this looks totally valid to me), and they are directly mentioned in spectrum2: if I just delete all of the headers, or at least the headers mentioned in the error (leaving out only the libraries and swiften-config binary), spectrum2 stops building, because if cannot find it's includes (again, this looks totally predictable too). I can overcome the first error - mentioned above - by wiping out the content of the swiften ConnectionServerFactory.h header file - leaving only namespace declaration with 2 classes, - and the building stops complaining about virtual methods, but then it merely crashes later:

]# gmake
[  0%] Built target pb
[  4%] Built target transport-plugin
[  4%] Building CXX object libtransport/CMakeFiles/transport.dir/FileTransferManager.cpp.o
[  4%] Building CXX object libtransport/CMakeFiles/transport.dir/NetworkPluginServer.cpp.o
/home/emz/src/spectrum2-2.0.13/libtransport/NetworkPluginServer.cpp:311:75: error: member access into incomplete type
      'Swift::ConnectionServerFactory'
        m_server = component->getNetworkFactories()->getConnectionServerFactory()->createConnectionServer(SWIFT_...
                                                                                 ^
/usr/local/swiften/include/Swiften/FileTransfer/SOCKS5BytestreamServerManager.h:25:11: note: forward declaration of
      'Swift::ConnectionServerFactory'
    class ConnectionServerFactory;
          ^
/home/emz/src/spectrum2-2.0.13/libtransport/NetworkPluginServer.cpp:1915:19: warning: incrementing expression of type
      bool is deprecated and incompatible with C++17 [-Wdeprecated-increment-bool]
        matchCount++;
        ~~~~~~~~~~^
1 warning and 1 error generated.
gmake[2]: *** [libtransport/CMakeFiles/transport.dir/build.make:265: libtransport/CMakeFiles/transport.dir/NetworkPluginServer.cpp.o] Ошибка 1
gmake[1]: *** [CMakeFiles/Makefile2:556: libtransport/CMakeFiles/transport.dir/all] Ошибка 2
gmake: *** [Makefile:172: all] Ошибка 2

Could you please help me with building this ?

drook commented 4 years ago

I managed to fix this error above by converting pure virtual methods to non-pure (simply removing returned zero in swifter header for createConnectionServer() routine in createConnectionServerFactory.h). But then I got building crashed on another location, seems this has nothing to do with virtual methods I tampered with:

[ 15%] Building CXX object libtransport/CMakeFiles/transport.dir/__/include/Swiften/Server/ServerFromClientSession.cpp.o
/home/emz/src/spectrum2-2.0.13/include/Swiften/Server/ServerFromClientSession.cpp:115:31: error: no viable conversion
      from 'Swift::TLSServerLayer *' to 'std::unique_ptr<StreamLayer>'
                        getStreamStack()->addLayer(tlsLayer);
                                                   ^~~~~~~~
/usr/include/c++/v1/memory:2401:28: note: candidate constructor (the implicit copy constructor) not viable: no known
      conversion from 'Swift::TLSServerLayer *' to 'const std::__1::unique_ptr<Swift::StreamLayer,
      std::__1::default_delete<Swift::StreamLayer> > &' for 1st argument
class _LIBCPP_TEMPLATE_VIS unique_ptr {
                           ^
/usr/include/c++/v1/memory:2466:13: note: candidate constructor template not viable: no known conversion from
      'Swift::TLSServerLayer *' to 'std::nullptr_t' (aka 'nullptr_t') for 1st argument
  constexpr unique_ptr(nullptr_t) noexcept : __ptr_(pointer()) {}
            ^
/usr/include/c++/v1/memory:2494:3: note: candidate constructor not viable: no known conversion from
      'Swift::TLSServerLayer *' to 'std::__1::unique_ptr<Swift::StreamLayer,
      std::__1::default_delete<Swift::StreamLayer> > &&' for 1st argument
  unique_ptr(unique_ptr&& __u) noexcept
  ^
/usr/include/c++/v1/memory:2503:3: note: candidate template ignored: could not match 'unique_ptr<type-parameter-0-0,
      type-parameter-0-1>' against 'Swift::TLSServerLayer *'
  unique_ptr(unique_ptr<_Up, _Ep>&& __u) _NOEXCEPT
  ^
/usr/include/c++/v1/memory:2509:3: note: candidate template ignored: could not match 'auto_ptr<type-parameter-0-0>'
      against 'Swift::TLSServerLayer *'
  unique_ptr(auto_ptr<_Up>&& __p,
  ^
/usr/local/swiften/include/Swiften/StreamStack/StreamStack.h:27:73: note: passing argument to parameter here
            void addLayer(std::unique_ptr<StreamLayer> /* streamLayer */);
                                                                        ^
1 error generated.
gmake[2]: *** [libtransport/CMakeFiles/transport.dir/build.make:889: libtransport/CMakeFiles/transport.dir/__/include/Swiften/Server/ServerFromClientSession.cpp.o] Ошибка 1
gmake[1]: *** [CMakeFiles/Makefile2:556: libtransport/CMakeFiles/transport.dir/all] Ошибка 2
gmake: *** [Makefile:172: all] Ошибка 2

Could you please help with the latter, if it's not triggered by the changes I made (doubt that , but still).

vitalyster commented 4 years ago

These are changes from 5.0 which is not compatible with current released version, use swift-4.x branch