Trojan-Plus-Group / trojan-plus

More Experimental Effective Features for Trojan
GNU General Public License v3.0
83 stars 21 forks source link

[HELP] compiling binary from android termux #4

Closed peter-tank closed 4 years ago

peter-tank commented 4 years ago

failed in compiling from android termux, seems no easier way to do so? Maybe there neeeds explicit options on tunedev and dnsserver.

[ 3%] Building CXX object CMakeFiles/trojan.dir/src/core/service.cpp.o /data/data/com.termux/files/home/trojan-plus/src/core/service.cpp:131:17: error: incomplete type 'DNSServer' named in nested name specifier if (DNSServer::get_dns_lock()) { ^~~ /data/data/com.termux/files/home/trojan-plus/src/core/service.h:42:7: note: forward declaration of 'DNSServer' class DNSServer; ^ /data/data/com.termux/files/home/trojan-plus/src/core/service.cpp:133:33: error: member access into incomplete type 'std::ndk1::shared_ptr::element_type' (aka 'DNSServer') if (m_dns_server->start()) { ^ /data/data/com.termux/files/home/trojan-plus/src/core/service.h:42:7: note: forward declaration of 'DNSServer' class DNSServer; ^ In file included from /data/data/com.termux/files/home/trojan-plus/src/core/service.cpp:23: In file included from /data/data/com.termux/files/home/trojan-plus/src/core/service.h:26: In file included from /data/data/com.termux/files/home/boost_1_70_0/boost/asio/io_context.hpp:18: In file included from /data/data/com.termux/files/home/boost_1_70_0/boost/asio/detail/config.hpp:26: In file included from /data/data/com.termux/files/home/boost_1_70_0/boost/config.hpp:44: In file included from /data/data/com.termux/files/home/boost_1_70_0/boost/config/detail/select_stdlib_config.hpp:18: In file included from /data/data/com.termux/files/usr/bin/../include/c++/v1/cstddef:111: /data/data/com.termux/files/usr/bin/../include/c++/v1/type_traits:3153:38: error: incomplete type 'DNSServer' used in type trait expression : public integral_constant<bool, __is_constructible(_Tp, _Args...)> ^ /data/data/com.termux/files/usr/bin/../include/c++/v1/memory:4325:20: note: in instantiation of template class 'std::ndk1::is_constructible<DNSServer, Service >' requested here static_assert( is_constructible<_Tp, _Args...>::value, "Can't construct object in make_shared" ); ^ /data/data/com.termux/files/usr/bin/../include/c++/v1/memory:4710:29: note: in instantiation of function template specialization 'std::__ndk1::shared_ptr::make_shared<Service >' requested here return shared_ptr<_Tp>::make_shared(_VSTD::forward<_Args>(args)...); ^ /data/data/com.termux/files/home/trojan-plus/src/core/service.cpp:132:32: note: in instantiation of function template specialization 'std::ndk1::make_shared<DNSServer, Service >' requested here m_dns_server = make_shared(this); ^ /data/data/com.termux/files/home/trojan-plus/src/core/service.h:42:7: note: forward declaration of 'DNSServer' class DNSServer; ^ In file included from /data/data/com.termux/files/home/trojan-plus/src/core/service.cpp:23: In file included from /data/data/com.termux/files/home/trojan-plus/src/core/service.h:26: In file included from /data/data/com.termux/files/home/boost_1_70_0/boost/asio/io_context.hpp:24: In file included from /data/data/com.termux/files/home/boost_1_70_0/boost/asio/detail/wrapped_handler.hpp:18: In file included from /data/data/com.termux/files/home/boost_1_70_0/boost/asio/detail/bind_handler.hpp:19: In file included from /data/data/com.termux/files/home/boost_1_70_0/boost/asio/associated_allocator.hpp:19: /data/data/com.termux/files/usr/bin/../include/c++/v1/memory:4325:5: error: static_assert failed due to requirement 'is_constructible<DNSServer, Service >::value' "Can't construct object in make_shared" static_assert( is_constructible<_Tp, _Args...>::value, "Can't construct object in make_shared" ); ^ ~~~~~~~~~~ /data/data/com.termux/files/usr/bin/../include/c++/v1/memory:4710:29: note: in instantiation of function template specialization 'std::ndk1::shared_ptr::make_shared<Service >' requested here return shared_ptr<_Tp>::make_shared(_VSTD::forward<_Args>(args)...); ^ /data/data/com.termux/files/home/trojan-plus/src/core/service.cpp:132:32: note: in instantiation of function template specialization 'std::ndk1::make_shared<DNSServer, Service >' requested here m_dns_server = make_shared(this); ^ In file included from /data/data/com.termux/files/home/trojan-plus/src/core/service.cpp:23: In file included from /data/data/com.termux/files/home/trojan-plus/src/core/service.h:26: In file included from /data/data/com.termux/files/home/boost_1_70_0/boost/asio/io_context.hpp:18: In file included from /data/data/com.termux/files/home/boost_1_70_0/boost/asio/detail/config.hpp:26: In file included from /data/data/com.termux/files/home/boost_1_70_0/boost/config.hpp:44: In file included from /data/data/com.termux/files/home/boost_1_70_0/boost/config/detail/select_stdlib_config.hpp:18: In file included from /data/data/com.termux/files/usr/bin/../include/c++/v1/cstddef:111: /data/data/com.termux/files/usr/bin/../include/c++/v1/type_traits:1559:38: error: incomplete type 'DNSServer' used in type trait expression : public integral_constant<bool, is_empty(_Tp)> {}; ^ /data/data/com.termux/files/usr/bin/../include/c++/v1/memory:2133:15: note: in instantiation of template class 'std::ndk1::is_empty' requested here is_empty<_Tp>::value && !__libcpp_is_final<_Tp>::value> ^ /data/data/com.termux/files/usr/bin/../include/c++/v1/memory:2212:35: note: in instantiation of default argument for 'compressed_pair_elem<DNSServer, 1>' required here private compressed_pair_elem<_T2, 1> { ^~~~~~~~~~ /data/data/com.termux/files/usr/bin/../include/c++/v1/memory:3661:36: note: in instantiation of template class 'std::ndk1::compressed_pair<std::ndk1::allocator, DNSServer>' requested here compressed_pair<_Alloc, _Tp> _data; ^ /data/data/com.termux/files/usr/bin/../include/c++/v1/memory:4331:26: note: in instantiation of template class 'std::ndk1::shared_ptr_emplace<DNSServer, std::ndk1::allocator >' requested here ::new(hold2.get()) _CntrlBlk(a2, _VSTD::forward<_Args>(args)...); ^ /data/data/com.termux/files/usr/bin/../include/c++/v1/memory:4710:29: note: in instantiation of function template specialization 'std::__ndk1::shared_ptr::make_shared<Service *>' requested here return shared_ptr<_Tp>::make_shared(_VSTD::forward<_Args>(args)...); ^ /data/data/com.termux/files/home/trojan-plus/src/core/service.cpp:132:32: note: in instantiation of function template specialization 'std::ndk1::make_shared<DNSServer, Service *>' requested here m_dns_server = make_shared(this); ^ /data/data/com.termux/files/home/trojan-plus/src/core/service.h:42:7: note: forward declaration of 'DNSServer' class DNSServer; ^ In file included from /data/data/com.termux/files/home/trojan-plus/src/core/service.cpp:23: In file included from /data/data/com.termux/files/home/trojan-plus/src/core/service.h:26: In file included from /data/data/com.termux/files/home/boost_1_70_0/boost/asio/io_context.hpp:24: In file included from /data/data/com.termux/files/home/boost_1_70_0/boost/asio/detail/wrapped_handler.hpp:18: In file included from /data/data/com.termux/files/home/boost_1_70_0/boost/asio/detail/bind_handler.hpp:19: In file included from /data/data/com.termux/files/home/boost_1_70_0/boost/asio/associated_allocator.hpp:19: /data/data/com.termux/files/usr/bin/../include/c++/v1/memory:2133:30: error: no member named 'value' in 'std::ndk1::is_empty' is_empty<_Tp>::value && !__libcpp_is_final<_Tp>::value>


/data/data/com.termux/files/usr/bin/../include/c++/v1/memory:2214:11: note: in instantiation of default argument for '__compressed_pair_elem<DNSServer, 1>' required here
typedef __compressed_pair_elem<_T2, 1> _Base2;
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/data/data/com.termux/files/usr/bin/../include/c++/v1/memory:3661:36: note: in instantiation of template class 'std::__ndk1::__compressed_pair<std::__ndk1::allocator<DNSServer>, DNSServer>' requested here
__compressed_pair<_Alloc, _Tp> __data_;
^
/data/data/com.termux/files/usr/bin/../include/c++/v1/memory:4331:26: note: in instantiation of template class 'std::__ndk1::__shared_ptr_emplace<DNSServer, std::__ndk1::allocator<DNSServer> >' requested here
::new(__hold2.get()) _CntrlBlk(__a2, _VSTD::forward<_Args>(__args)...);
^
/data/data/com.termux/files/usr/bin/../include/c++/v1/memory:4710:29: note: in instantiation of function template specialization 'std::__ndk1::shared_ptr<DNSServer>::make_shared<Service *>' requested here
return shared_ptr<_Tp>::make_shared(_VSTD::forward<_Args>(__args)...);
^
/data/data/com.termux/files/home/trojan-plus/src/core/service.cpp:132:32: note: in instantiation of function template specialization 'std::__ndk1::make_shared<DNSServer, Service *>' requested here
m_dns_server = make_shared<DNSServer>(this);
^
In file included from /data/data/com.termux/files/home/trojan-plus/src/core/service.cpp:23:
In file included from /data/data/com.termux/files/home/trojan-plus/src/core/service.h:26:
In file included from /data/data/com.termux/files/home/boost_1_70_0/boost/asio/io_context.hpp:24:
In file included from /data/data/com.termux/files/home/boost_1_70_0/boost/asio/detail/wrapped_handler.hpp:18:
In file included from /data/data/com.termux/files/home/boost_1_70_0/boost/asio/detail/bind_handler.hpp:19:
In file included from /data/data/com.termux/files/home/boost_1_70_0/boost/asio/associated_allocator.hpp:19:
/data/data/com.termux/files/usr/bin/../include/c++/v1/memory:4334:28: error: assigning to 'std::__ndk1::__shared_weak_count *' from incompatible type 'std::__ndk1::unique_ptr<std::__ndk1::__shared_ptr_emplace<DNSServer, std::__ndk1::allocator<DNSServer> >, std::__ndk1::__allocator_destructor<std::__ndk1::allocator<std::__ndk1::__shared_ptr_emplace<DNSServer, std::__ndk1::allocator<DNSServer> > > > >::pointer' (aka 'std::__ndk1::__shared_ptr_emplace<DNSServer, std::__ndk1::allocator<DNSServer> > *')
__r.__cntrl_ = __hold2.release();
~~~~~~~~^~~~~~~~~
/data/data/com.termux/files/usr/bin/../include/c++/v1/memory:4710:29: note: in instantiation of function template specialization 'std::__ndk1::shared_ptr<DNSServer>::make_shared<Service *>' requested here
return shared_ptr<_Tp>::make_shared(_VSTD::forward<_Args>(__args)...);
^
/data/data/com.termux/files/home/trojan-plus/src/core/service.cpp:132:32: note: in instantiation of function template specialization 'std::__ndk1::make_shared<DNSServer, Service *>' requested here
m_dns_server = make_shared<DNSServer>(this);
^
7 errors generated.
make[2]: *** [CMakeFiles/trojan.dir/build.make:102: CMakeFiles/trojan.dir/src/core/service.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:76: CMakeFiles/trojan.dir/all] Error 2
make: *** [Makefile:141: all] Error 2
peter-tank commented 4 years ago

5

yuchting commented 4 years ago

class DNSServer was defined in "src/tun/dnsserver.h", the include path was set in: https://github.com/Trojan-Plus-Group/trojan-plus/blob/master/CMakeLists.txt#L98

include_directories(
    src            #<----- here
    src/tun/lwip_custom
    badvpn/lwip/src/include
    badvpn
)

https://github.com/Trojan-Plus-Group/trojan-plus/blob/master/CMakeLists.txt#L169

    src/tun/lwip_tcp_client.cpp
    src/tun/tundev.cpp
    src/tun/tunsession.cpp
    src/tun/tunproxysession.cpp
    src/tun/tunlocalsession.cpp
    src/tun/dnsserver.cpp   # <---------------------here
    src/tun/udplocalforwarder.cpp

Your compiling error message:

/data/data/com.termux/files/home/trojan-plus/src/core/service.cpp:131:17: error: incomplete type 'DNSServer' named in nested name specifier if (DNSServer::get_dns_lock()) {

said cannot find DNSServer class completed defined in service.cpp, but in https://github.com/Trojan-Plus-Group/trojan-plus/blob/master/src/core/service.cpp#L39

#include "session/pipelinesession.h"
#include "session/serversession.h"
#include "utils.h"

#include "tun/dnsserver.h"      // <---------------- here
#include "tun/tundev.h"

using namespace std;
using namespace boost::asio::ip;
using namespace boost::asio::ssl;

so I don't know why your compiler would give such error message.

Or CMake / Make in termux has some bug?

The codes has been test by CI: https://dev.azure.com/Trojan-Plus-Group/trojan-plus/_build

Compiling is OK.

yuchting commented 4 years ago

Another information, I'm working for Trojan-Plus Android client: https://github.com/Trojan-Plus-Group/trojan-plus-app

It needs some days for first beta version.

yuchting commented 4 years ago

I checked your compiling error message again, I found your boost library is 1.70, but the minimum version for Trojan-Plus is 1.72, so even if you pass this error message, you will meet another error about boost.

peter-tank commented 4 years ago

• pass after remove tundev and dnsserver linked with boost_0_70_0 • pass on fully compiled after upgrade to boost_0_72_0

yuchting commented 4 years ago

• pass after remove tundev and dnsserver linked with boost_0_70_0 • pass on fully compiled after upgrade to boost_0_72_0

Cool!

tundev and dnsserver is prepare for Android/iOS Lib, so if you remove these modules, it will be fine.