sdamm / asio_dtls

A DTLS implementation using the ASIO library
51 stars 12 forks source link

Fail to Compile in to DTLS library #10

Closed VPBalaRama closed 4 years ago

VPBalaRama commented 4 years ago

Hi All, I tried to integrate the Boost DTLS in to 1.72 Boost Library. i write own make file to compile. i getting below error. Please guide to write make file properly CMakeLists.txt

c:\kodiak\releases\lmr-gw-r9.1.1\3rdparty\boost\boost\asio\detail\win_static_mutex.hpp(55): error C2039: 'CRITICAL_SECTION': is not a member of 'global namespace'' [C:\Kodiak\Releases\LMR-GW-R9.1.1\build\3rdparty\boost\boost\asio\ssl\dtls\boost_dtls.vcxproj] c:\kodiak\releases\lmr-gw-r9.1.1\3rdparty\boost\boost\asio\detail\win_static_mutex.hpp(55): error C3646: 'crit_section_': unknown override specifier [C:\Kodiak\Releases\LMR-GW-R9.1.1\build\3rdparty\boost\boost\asio\ssl\dtls\boost_dtls.vcxproj] c:\kodiak\releases\lmr-gw-r9.1.1\3rdparty\boost\boost\asio\detail\win_static_mutex.hpp(55): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int [C:\Kodiak\Releases\LMR-GW-R9.1.1\build\3rdparty\boost\boost\asio\ssl\dtls\boost_dtls.vcxproj] c:\kodiak\releases\lmr-gw-r9.1.1\3rdparty\boost\boost\asio\detail\win_static_mutex.hpp(45): error C2039: 'EnterCriticalSection': is not a member of 'global namespace'' [C:\Kodiak\Releases\LMR-GW-R9.1.1\build\3rdparty\boost\boost\asio\ssl\dtls\boost_dtls.vcxproj] c:\kodiak\releases\lmr-gw-r9.1.1\3rdparty\boost\boost\asio\detail\win_static_mutex.hpp(45): error C2065: 'critsection': undeclared identifier [C:\Kodiak\Releases\LMR-GW-R9.1.1\build\3rdparty\boost\boost\asio\ssl\dtls\boost_dtls.vcxproj] c:\kodiak\releases\lmr-gw-r9.1.1\3rdparty\boost\boost\asio\detail\win_static_mutex.hpp(45): error C3861: 'EnterCriticalSection': identifier not found [C:\Kodiak\Releases\LMR-GW-R9.1.1\build\3rdparty\boost\boost\asio\ssl\dtls\boost_dtls.vcxproj]

sdamm commented 4 years ago

The error you get does not show where it actually occurred, it seems to be in the boost\asio\detail\win_static_mutex.hpp header. But i would suspect a missing include/define but to be certain it would be good if you had a Verbose build showing what file is actually compiled.

I noticed in your Makefile you have: -UBOOST_ASIO_WINDOWS Shouldn't that be a -DBOOST_ASIO_WINDOWS ?

VPBalaRama commented 4 years ago

Hi, Thanks for Immediate response. I was getting that error while compiling the \boost\asio\ssl\dtls\detail\impl\engine.ipp file. I was getting a bunch of error in boost/asio/detail/win_static_mutex.hpp and win_static_mutex.ipp files. Below i have shared sample errors. c:\test\releases\projDTLS\3rdparty\boost\boost\asio\detail\win_static_mutex.hpp(55): error C2039: 'CRITICAL_SECTION': is not a member of '`global namespace'' (compi ling source file C:\test\Releases\projDTLS\3rdparty\boost\boost\asio\ssl\dtls\detail\impl\engine.ipp) [C:\test\Releases\projDTLS\build\3rdparty\boost\boost\a sio\ssl\dtls\boost_dtls.vcxproj] c:\test\releases\projDTLS\3rdparty\boost\boost\asio\detail\win_static_mutex.hpp(55): error C3646: 'critsection': unknown override specifier (compiling source file C:\test\Releases\projDTLS\3rdparty\boost\boost\asio\ssl\dtls\detail\impl\engine.ipp) [C:\test\Releases\projDTLS\build\3rdparty\boost\boost\asio\ssl\dtls\boo st_dtls.vcxproj]

To avoid above error i have added -UBOOST_ASIO_WINDOWS macro. still no efftective. I have commented out below lines in detail/static_mutex.hpp. Now its compiling succusfully. is this good way or what?

if !defined(BOOST_ASIO_HAS_THREADS)

include <boost/asio/detail/null_static_mutex.hpp>

//#elif defined(BOOST_ASIO_WINDOWS)//commented by v2 //# include <boost/asio/detail/win_static_mutex.hpp> //commneted by v2

elif defined(BOOST_ASIO_HAS_PTHREADS)

include <boost/asio/detail/posix_static_mutex.hpp>

elif defined(BOOST_ASIO_HAS_STD_MUTEX_AND_CONDVAR)

include <boost/asio/detail/std_static_mutex.hpp>

else

error Only Windows and POSIX are supported!

endif

if !defined(BOOST_ASIO_HAS_THREADS)

typedef null_static_mutex static_mutex;

define BOOST_ASIO_STATIC_MUTEX_INIT BOOST_ASIO_NULL_STATIC_MUTEX_INIT

//#elif defined(BOOST_ASIO_WINDOWS) //commented by v2 //typedef win_static_mutex static_mutex;//commented by v2 //# define BOOST_ASIO_STATIC_MUTEX_INIT BOOST_ASIO_WIN_STATIC_MUTEX_INIT //comment

elif defined(BOOST_ASIO_HAS_PTHREADS)

typedef posix_static_mutex static_mutex;

define BOOST_ASIO_STATIC_MUTEX_INIT BOOST_ASIO_POSIX_STATIC_MUTEX_INIT

elif defined(BOOST_ASIO_HAS_STD_MUTEX_AND_CONDVAR)

typedef std_static_mutex static_mutex;

define BOOST_ASIO_STATIC_MUTEX_INIT BOOST_ASIO_STD_STATIC_MUTEX_INIT

endif

VPBalaRama commented 4 years ago

After above library compilation.. now linker error with the library. Please let me know how to link library. main.obj : error LNK2019: unresolved external symbol _BIO_free referenced in function "public: thiscall boost::asio::ssl::dtls::detail::engine::~engine(void)" (??1engine @detail@dtls@ssl@asio@boost@@QAE@XZ) [C:\Kodiak\Releases\LMR-GW-R9.1.1\build\3rdparty\boost\boost\asio\ssl\dtls\src\examples\boost\async_client\example_boost_async_client. vcxproj] client.obj : error LNK2001: unresolved external symbol _BIO_free [C:\Kodiak\Releases\LMR-GW-R9.1.1\build\3rdparty\boost\boost\asio\ssl\dtls\src\examples\boost\async_client \example_boost_async_client.vcxproj] main.obj : error LNK2019: unresolved external symbol _CONF_modules_unload referenced in function "public: __thiscall boost::asio::ssl::detail::openssl_init_base::do_init:: ~do_init(void)" (??1do_init@openssl_init_base@detail@ssl@asio@boost@@QAE@XZ) [C:\Kodiak\Releases\LMR-GW-R9.1.1\build\3rdparty\boost\boost\asio\ssl\dtls\src\examples\boost\ async_client\example_boost_async_client.vcxproj] client.obj : error LNK2001: unresolved external symbol _CONF_modules_unload [C:\Kodiak\Releases\LMR-GW-R9.1.1\build\3rdparty\boost\boost\asio\ssl\dtls\src\examples\boost\a sync_client\example_boost_async_client.vcxproj] main.obj : error LNK2019: unresolved external symbol _SSL_CTX_set_options referenced in function "public: class boost::system::error_code thiscall boost::asio::ssl::dtls ::context::set_options(long,class boost::system::error_code &)" (?set_options@context@dtls@ssl@asio@boost@@QAE?AVerror_code@system@5@JAAV675@@Z) [C:\Kodiak\Releases\LMR-GW -R9.1.1\build\3rdparty\boost\boost\asio\ssl\dtls\src\examples\boost\async_client\example_boost_async_client.vcxproj] main.obj : error LNK2019: unresolved external symbol _SSL_CTX_new referenced in function "public: thiscall boost::asio::ssl::dtls::context::context(enum boost::asio::ssl ::dtls::context::dtls_method)" (??0context@dtls@ssl@asio@boost@@QAE@W4dtls_method@01234@@Z) [C:\Kodiak\Releases\LMR-GW-R9.1.1\build\3rdparty\boost\boost\asio\ssl\dtls\src\ examples\boost\async_client\example_boost_async_client.vcxproj] main.obj : error LNK2019: unresolved external symbol _SSL_CTX_free referenced in function "public: __thiscall boost::asio::ssl::dtls::context::~context(void)" (??1context@ dtls@ssl@asio@boost@@QAE@XZ) [C:\Kodiak\Releases\LMR-GW-R9.1.1\build\3rdparty\boost\boost\asio\ssl\dtls\src\examples\boost\async_client\example_boost_async_client.vcxproj] main.obj : error LNK2019: unresolved external symbol _SSL_CTX_set_default_passwd_cb_userdata referenced in function "public: thiscall boost::asio::ssl::dtls::context::~c ontext(void)" (??1context@dtls@ssl@asio@boost@@QAE@XZ) [C:\Kodiak\Releases\LMR-GW-R9.1.1\build\3rdparty\boost\boost\asio\ssl\dtls\src\examples\boost\async_client\example_b oost_async_client.vcxproj] main.obj : error LNK2019: unresolved external symbol _SSL_CTX_get_default_passwd_cb_userdata referenced in function "public: __thiscall boost::asio::ssl::dtls::context::~c ontext(void)" (??1context@dtls@ssl@asio@boost@@QAE@XZ) [C:\Kodiak\Releases\LMR-GW-R9.1.1\build\3rdparty\boost\boost\asio\ssl\dtls\src\examples\boost\async_client\example_b oost_async_client.vcxproj] main.obj : error LNK2019: unresolved external symbol _SSL_free referenced in fun

sdamm commented 4 years ago

_BIO_free is part of OpenSSL, so you probably don't link it correctly.

VPBalaRama commented 4 years ago

Hi I am getting below error, when i try to compile. please let me know hoe to fix it dtls\src\examples\boost\server\example_boost_server main.cpp c:\proj\releases\dtls\3rdparty\boost\boost\asio\detail\io_object_impl.hpp(87): error C2039: 'get_executor': is not a member of 'boost::asio::execution_context' [C:\proj\Releases\dtls\build\3rdparty\boost\boost\asio\ssl\dtls\src\examples\boost\server\example_boost_server.vcxproj] c:\proj\releases\dtls\3rdparty\boost\boost\asio\execution_context.hpp(106): note: see declaration of 'boost::asio::execution_context' c:\proj\releases\dtls\3rdparty\boost\boost\asio\basic_socket.hpp(133): note: see reference to function template instantiation 'boost::asio::detail::io_object_impl<boost::asio::detail::win_iocp_socket_service,Executor>::io_object_impl(ExecutionContext &,void )' being compiled with [ Protocol=boost::asio::ip::udp, Executor=boost::asio::executor, ExecutionContext=boost::asio::execution_context ] c:\proj\releases\dtls\3rdparty\boost\boost\asio\basic_socket.hpp(132): note: see reference to function template instantiation 'boost::asio::detail::io_object_impl<boost::asio::detail::win_iocp_socket_service,Executor>::io_object_impl(ExecutionContext &,void )' being compiled with [ Protocol=boost::asio::ip::udp, Executor=boost::asio::executor, ExecutionContext=boost::asio::execution_context ] c:\proj\releases\dtls\3rdparty\boost\boost\asio\basic_datagram_socket.hpp(108): note: see reference to function template instantiation 'boost::asio::basic_socket<Protocol,Executor>::basic_socket(ExecutionContext &,void )' being compiled with [ Protocol=boost::asio::ip::udp, Executor=boost::asio::executor, ExecutionContext=boost::asio::execution_context ] c:\proj\releases\dtls\3rdparty\boost\boost\asio\basic_datagram_socket.hpp(107): note: see reference to function template instantiation 'boost::asio::basic_socket<Protocol,Executor>::basic_socket(ExecutionContext &,void )' being compiled with

sdamm commented 4 years ago

I don't have a windows system for building available at the moment (maybe on Monday). What you could try is the ASIO_HEADER_ONLY define. Also I have only tested with Boost 1.70 so I'm not certain this works at the moment.

VPBalaRama commented 4 years ago

Hi, Thanks for Immediate response. I was getting that error while compiling the \boost\asio\ssl\dtls\detail\impl\engine.ipp file. I was getting a bunch of error in boost/asio/detail/win_static_mutex.hpp and win_static_mutex.ipp files. Below i have shared sample errors. c:\test\releases\projDTLS\3rdparty\boost\boost\asio\detail\win_static_mutex.hpp(55): error C2039: 'CRITICAL_SECTION': is not a member of '`global namespace'' (compi ling source file C:\test\Releases\projDTLS\3rdparty\boost\boost\asio\ssl\dtls\detail\impl\engine.ipp) [C:\test\Releases\projDTLS\build\3rdparty\boost\boost\a sio\ssl\dtls\boost_dtls.vcxproj] c:\test\releases\projDTLS\3rdparty\boost\boost\asio\detail\win_static_mutex.hpp(55): error C3646: 'critsection': unknown override specifier (compiling source file C:\test\Releases\projDTLS\3rdparty\boost\boost\asio\ssl\dtls\detail\impl\engine.ipp) [C:\test\Releases\projDTLS\build\3rdparty\boost\boost\asio\ssl\dtls\boo st_dtls.vcxproj]

To avoid above error i have added -UBOOST_ASIO_WINDOWS macro. still no efftective. I have commented out below lines in detail/static_mutex.hpp. Now its compiling succusfully. is this good way or what?

if !defined(BOOST_ASIO_HAS_THREADS)

include <boost/asio/detail/null_static_mutex.hpp>

//#elif defined(BOOST_ASIO_WINDOWS)//commented by v2 //# include <boost/asio/detail/win_static_mutex.hpp> //commneted by v2

elif defined(BOOST_ASIO_HAS_PTHREADS)

include <boost/asio/detail/posix_static_mutex.hpp>

elif defined(BOOST_ASIO_HAS_STD_MUTEX_AND_CONDVAR)

include <boost/asio/detail/std_static_mutex.hpp>

else

error Only Windows and POSIX are supported!

endif

if !defined(BOOST_ASIO_HAS_THREADS)

typedef null_static_mutex static_mutex;

define BOOST_ASIO_STATIC_MUTEX_INIT BOOST_ASIO_NULL_STATIC_MUTEX_INIT

//#elif defined(BOOST_ASIO_WINDOWS) //commented by v2 //typedef win_static_mutex static_mutex;//commented by v2 //# define BOOST_ASIO_STATIC_MUTEX_INIT BOOST_ASIO_WIN_STATIC_MUTEX_INIT //comment

elif defined(BOOST_ASIO_HAS_PTHREADS)

typedef posix_static_mutex static_mutex;

define BOOST_ASIO_STATIC_MUTEX_INIT BOOST_ASIO_POSIX_STATIC_MUTEX_INIT

elif defined(BOOST_ASIO_HAS_STD_MUTEX_AND_CONDVAR)

typedef std_static_mutex static_mutex;

define BOOST_ASIO_STATIC_MUTEX_INIT BOOST_ASIO_STD_STATIC_MUTEX_INIT

endif

I have to prepare cmake file without the comment. can you please comment on this.

sdamm commented 4 years ago

I have tried to compile asio_dtls using:

And after fixing the linkage of boost i have the error in

It seems there is an error in the dtls::acceptor . If you don't need this functionality you can just disable the server example. I can't say when i will have a fix as i haven't understood what the cause is, but i will try to get it fixed.

sdamm commented 4 years ago

With the latest Commit (https://github.com/sdamm/asio_dtls/commit/c578c3e49b65cb40112ab8c2a03eb4c164e0028f) i could successfully compile asio_dtls and the boost examples.

cmake call: cmake -DOPENSSL_ROOT_DIR=C:\Libraries\openssl-vc -DBOOST_ROOT=C:\Libraries\boost_1_72_0 -DBoost_USE_STATIC_LIBS=ON -Dasio_dtls_use_boost=ON ..

Assuming the libraries are located in the respective Directories and you have a static built Boost. And .. is the path to the asio_dtls source.

sdamm commented 4 years ago

I assume this has been fixed, so I'm closing the issue.