retf / boost.application Goto Github PK
View Code? Open in Web Editor NEWBoost Application Library
Boost Application Library
I mean here : https://github.com/boostorg/boost
There some things like asio, system, thread are moved so module should support it by using something alike
#if (BOOST_VERSION > 105700)
#include <boost/program_options/option.hpp>
#else
#include <boost/program_options.hpp>
#endif
I am trying to start a tiny service on my pc. And I copy the example provided in README entirely.
Then I use service_setup_ex.exe to register the service on my pc. The problem shows as soon as I click start the service.
Since I cannot debug a "server" mode app, I change the mode to "common". Then I found the crash happens at
my_log_file_ << "Start Log..." << std::endl;
It prompts to show an "Access Violation" exception.
But this only happens in release mode, not in debug mode.
Besides, I also have a try on the simple_server_example. The same problems happened.
Boost Application is failed to build with latest boost master branch.
Last successful build was produced 4 month ago https://travis-ci.org/retf/Boost.Application/builds/63207520
Current state is https://travis-ci.org/retf/Boost.Application/builds/79274940
gcc.compile.c++ ../../../bin.v2/libs/application/test/signal_binder_test.test/gcc-4.6/debug/threading-multi/signal_binder_test.o
In file included from ../../../boost/application/system_error.hpp:10:0,
from ../../../boost/application/config.hpp:32,
from ../../../boost/application.hpp:15,
from signal_binder_test.cpp:15:
../../../boost/system/config.hpp:34:3: error: #error Must not define both BOOST_SYSTEM_DYN_LINK and BOOST_SYSTEM_STATIC_LINK
Issue was discovered with pull request #42 which was build successfully with boost release 1.58.0
I suspect it is related to Boost.Build settings used by Boost.Application, but unfortunately not familiar with bjam/boost.build enough.
@apolukhin Could you please take a look on it? Thank you.
fatal error C1189: #error: Boost.Application requires at least the windows vista feature level of the windows sdk.
class wait_for_termination_request_impl : noncopyable
{
public:
// will wait for termination request
void wait()
{
fd_set readfds;
FD_ZERO(&readfds);
FD_SET(selfpipe_.read_fd(), &readfds);
// block and wait
while(select(selfpipe_.read_fd() + 1, &readfds, 0, 0, 0) == -1 && errno == EINTR)
{
// nothing here, restart when signal is catch
}
}
void proceed()
{
selfpipe_.poke();
}
private:
application::selfpipe selfpipe_;
};
block dont work
I have the 1063 error on windows when i start aplication as server (from visual studio).
in impl_.reset i have ec = 1063 and fail.
template <typename Application, typename SignalManager>
server(Application& myapp, SignalManager &sm,
application::context &context, boost::system::error_code& ec)
{
// default aspects patterns added to this kind of application
if(!context.find<run_mode>())
{
context.insert<run_mode>(
csbl::make_shared<run_mode>(mode()));
}
if(!context.find<status>())
{
context.insert<status>(
csbl::make_shared<status>(status::running));
}
// need be created after run_mode, status
impl_.reset(new server_application_impl(
boost::bind<int>( &Application::operator(), &myapp, _1), sm,
context, ec));
//ec = 1063
}
Please help me to understand what i doing wrong. This my main function:
int main(int argc, char * argv[])
{
myapp app;
boost::application::context app_context;
app_context.insert<boost::application::args>(std::make_shared<boost::application::args>(argc, argv));
boost::application::handler<>::parameter_callback termination_callback = boost::bind<bool>(&myapp::stop, &app, _1);
app_context.insert<boost::application::termination_handler>(std::make_shared<boost::application::termination_handler_default_behaviour>(termination_callback));
return boost::application::launch<boost::application::server>(app, app_context);
}
When i start application from visual studio i have 1063 error code:
1063 (0x427)
The service process could not connect to the service controller.
When i start as service from windows services window i have 1067 error code:
1067 (0x42B)
The process terminated unexpectedly.
When i start application in common mode from visual studio, all is ok.
I read that it is impossible to start service from visual studio. How i can debug my service app and found the reason of crash?
Thanks.
Travis currently fails to build the fourth tutorial:
gcc.compile.c++ ../../../bin.v2/libs/application/example/tutorial/gcc-4.6/debug/threading-multi/main_stage4.o
In file included from ../example/tutorial/main_stage4.cpp:12:0:
../example/tutorial/myfunctor_stage4.hpp:77:18: error: field ‘my_log_file_’ has incomplete type
../example/tutorial/myfunctor_stage4.hpp: In member function ‘int myapp::operator()()’:
../example/tutorial/myfunctor_stage4.hpp:36:7: error: ‘my_log_file_’ was not declared in this scope
../example/tutorial/myfunctor_stage4.hpp: In member function ‘bool myapp::stop()’:
../example/tutorial/myfunctor_stage4.hpp:48:7: error: ‘my_log_file_’ was not declared in this scope
../example/tutorial/myfunctor_stage4.hpp: In member function ‘bool myapp::pause()’:
../example/tutorial/myfunctor_stage4.hpp:58:7: error: ‘my_log_file_’ was not declared in this scope
../example/tutorial/myfunctor_stage4.hpp: In member function ‘bool myapp::resume()’:
../example/tutorial/myfunctor_stage4.hpp:67:7: error: ‘my_log_file_’ was not declared in this scope
../../../boost/asio/error.hpp: At global scope:
../../../boost/asio/error.hpp:258:45: warning: ‘boost::asio::error::system_category’ defined but not used [-Wunused-variable]
../../../boost/asio/error.hpp:260:45: warning: ‘boost::asio::error::netdb_category’ defined but not used [-Wunused-variable]
../../../boost/asio/error.hpp:262:45: warning: ‘boost::asio::error::addrinfo_category’ defined but not used [-Wunused-variable]
../../../boost/asio/error.hpp:264:45: warning: ‘boost::asio::error::misc_category’ defined but not used [-Wunused-variable]
"g++" -ftemplate-depth-128 -O0 -fno-inline -Wall -g -pthread -fPIC -m64 --coverage -std=c++98 -fno-strict-aliasing -DBOOST_ALL_DYN_LINK -DBOOST_ALL_NO_LIB -DBOOST_ALL_NO_LIB=1 -DBOOST_CHRONO_DYN_LINK=1 -DBOOST_DATE_TIME_DYN_LINK=1 -DBOOST_FILESYSTEM_DYN_LINK=1 -DBOOST_LIB_DIAGNOSTIC -DBOOST_PROGRAM_OPTIONS_DYN_LINK=1 -DBOOST_SYSTEM_DYN_LINK=1 -DBOOST_SYSTEM_NO_DEPRECATED -DBOOST_THREAD_BUILD_DLL=1 -DBOOST_THREAD_POSIX -DBOOST_THREAD_USE_DLL=1 -DDATE_TIME_INLINE -I"../../.." -I"../../../../type_index" -c -o "../../../bin.v2/libs/application/example/tutorial/gcc-4.6/debug/threading-multi/main_stage4.o" "../example/tutorial/main_stage4.cpp"
...failed gcc.compile.c++ ../../../bin.v2/libs/application/example/tutorial/gcc-4.6/debug/threading-multi/main_stage4.o...
The test case 'aspect_map_test' fail, need to fix it.
Currently we have local object std|boost thread which is created in signal_handler here
When std::thread is used it produce crash.
When boost::thread used it works, because of boost call detach() on joinable threads. See here - http://www.boost.org/doc/libs/1_59_0/doc/html/thread/thread_management.html#thread.thread_management.thread.destructor
If I build example with BOOST_THREAD_PROVIDES_THREAD_DESTRUCTOR_CALLS_TERMINATE_IF_JOINABLE it also crashed.
Should be fixed either using detach() for this thread, or not produce thread at all
spawn(ec, signal_number);
,
or keep pointer or reference to this thread anywhere.
Minimal example to demonstrate issue here https://github.com/snikulov/boost.app.minimal
Travis currently fails to build the selfpipe example:
gcc.compile.c++ ../../../bin.v2/libs/application/example/selfpipe/gcc-4.6/debug/build-yes/threading-multi/selfpipe.o
../example/selfpipe/selfpipe.cpp: In constructor ‘signal_usr2::signal_usr2(boost::application::global_context_ptr)’:
../example/selfpipe/selfpipe.cpp:136:40: error: no matching function for call to ‘boost::application::signal_manager::signal_manager(boost::application::global_context_ptr&)’
../example/selfpipe/selfpipe.cpp:136:40: note: candidates are:
../../../boost/application/signal_binder.hpp:270:7: note: boost::application::signal_manager::signal_manager(boost::application::context&)
../../../boost/application/signal_binder.hpp:270:7: note: no known conversion for argument 1 from ‘boost::application::global_context_ptr {aka boost::shared_ptr<boost::application::global_context>}’ to ‘boost::application::context& {aka boost::application::basic_context&}’
../../../boost/application/signal_binder.hpp:263:7: note: boost::application::signal_manager::signal_manager(boost::application::context&, boost::system::error_code&)
../../../boost/application/signal_binder.hpp:263:7: note: candidate expects 2 arguments, 1 provided
../../../boost/application/signal_binder.hpp:258:10: note: boost::application::signal_manager::signal_manager(const boost::application::signal_manager&)
../../../boost/application/signal_binder.hpp:258:10: note: no known conversion for argument 1 from ‘boost::application::global_context_ptr {aka boost::shared_ptr<boost::application::global_context>}’ to ‘const boost::application::signal_manager&’
../example/selfpipe/selfpipe.cpp:138:7: error: ‘parameter_callback’ is not a member of ‘boost::application::handler<bool>’
../example/selfpipe/selfpipe.cpp:138:50: error: expected ‘;’ before ‘callback1’
../example/selfpipe/selfpipe.cpp:141:7: error: ‘parameter_callback’ is not a member of ‘boost::application::handler<bool>’
../example/selfpipe/selfpipe.cpp:141:50: error: expected ‘;’ before ‘callback2’
../example/selfpipe/selfpipe.cpp:145:21: error: ‘callback1’ was not declared in this scope
../example/selfpipe/selfpipe.cpp:146:21: error: ‘callback2’ was not declared in this scope
../../../boost/asio/error.hpp: At global scope:
../../../boost/asio/error.hpp:258:45: warning: ‘boost::asio::error::system_category’ defined but not used [-Wunused-variable]
../../../boost/asio/error.hpp:260:45: warning: ‘boost::asio::error::netdb_category’ defined but not used [-Wunused-variable]
../../../boost/asio/error.hpp:262:45: warning: ‘boost::asio::error::addrinfo_category’ defined but not used [-Wunused-variable]
../../../boost/asio/error.hpp:264:45: warning: ‘boost::asio::error::misc_category’ defined but not used [-Wunused-variable]
"g++" -ftemplate-depth-128 -O0 -fno-inline -Wall -g -pthread -fPIC -m64 --coverage -std=c++98 -fno-strict-aliasing -DBOOST_ALL_DYN_LINK -DBOOST_ALL_NO_LIB -DBOOST_ALL_NO_LIB=1 -DBOOST_CHRONO_DYN_LINK=1 -DBOOST_DATE_TIME_DYN_LINK=1 -DBOOST_FILESYSTEM_DYN_LINK=1 -DBOOST_LIB_DIAGNOSTIC -DBOOST_PROGRAM_OPTIONS_DYN_LINK=1 -DBOOST_SYSTEM_DYN_LINK=1 -DBOOST_SYSTEM_NO_DEPRECATED -DBOOST_THREAD_BUILD_DLL=1 -DBOOST_THREAD_POSIX -DBOOST_THREAD_USE_DLL=1 -DDATE_TIME_INLINE -I"../../.." -I"../../../../type_index" -c -o "../../../bin.v2/libs/application/example/selfpipe/gcc-4.6/debug/build-yes/threading-multi/selfpipe.o" "../example/selfpipe/selfpipe.cpp"
...failed gcc.compile.c++ ../../../bin.v2/libs/application/example/selfpipe/gcc-4.6/debug/build-yes/threading-multi/selfpipe.o...
It seems like BOOST_APPLICATION_VERSION_BUILD
value should be 11
as of 18e28c9 commit. But it still 10
in master branch.
Hi there!
I've got some very doubtful ideas of shared_library enchantments:
foo::bar(std::vector<int>)
could be easily imported via sl.get<std::size_t(std::vector<int>)>("alias_name")
boost::function
,boost::shared_ptr
holding a pointer to shared_library symbol and a countable reference to shared_library (suggestion of Peter Dimov)Some of those are not very safe and some require a lot of code. My proposal is to move all the shared_libray stuff into a separate library (repository). It looks right from the point of libraries functionality (functionality of Application is not very close to Dynamic Loading) and in that way it won't interfere with upcoming Boost review of Application library.
What do you think about making a separate repo and about enchantments?
common.mkdir ../../../bin.v2/libs/application/test/simple_server_application_with_auto_handler.test
common.mkdir ../../../bin.v2/libs/application/test/simple_server_application_with_auto_handler.test/gcc-4.6
common.mkdir ../../../bin.v2/libs/application/test/simple_server_application_with_auto_handler.test/gcc-4.6/debug
common.mkdir ../../../bin.v2/libs/application/test/simple_server_application_with_auto_handler.test/gcc-4.6/debug/threading-multi
gcc.compile.c++ ../../../bin.v2/libs/application/test/simple_server_application_with_auto_handler.test/gcc-4.6/debug/threading-multi/simple_server_application_with_auto_handler.o
In file included from ../../../boost/application/all.hpp:26:0,
from ../../../boost/application.hpp:14,
from ../example/simple_server_application_with_auto_handler.cpp:62:
../../../boost/application/auto_handler.hpp: In constructor ‘boost::application::detail::handler_auto_set_u<Application, Derived>::handler_auto_set_u(boost::application::context&) [with Application = myapp, Derived = boost::application::auto_handler, boost::application::context = boost::application::basic_context]’:
../../../boost/application/auto_handler.hpp:194:29: instantiated from ‘boost::application::auto_handler::auto_handler(boost::application::context&) [with Application = myapp, boost::application::context = boost::application::basic_context]’
../example/simple_server_application_with_auto_handler.cpp:249:52: instantiated from here
../../../boost/application/auto_handler.hpp:119:10: error: no matching function for call to ‘myapp::myapp()’
../../../boost/application/auto_handler.hpp:119:10: note: candidate is:
../example/simple_server_application_with_auto_handler.cpp:79:4: note: myapp::myapp(boost::application::context&)
../example/simple_server_application_with_auto_handler.cpp:79:4: note: candidate expects 1 argument, 0 provided
../../../boost/asio/error.hpp: At global scope:
../../../boost/asio/error.hpp:253:45: warning: ‘boost::asio::error::system_category’ defined but not used [-Wunused-variable]
../../../boost/asio/error.hpp:255:45: warning: ‘boost::asio::error::netdb_category’ defined but not used [-Wunused-variable]
../../../boost/asio/error.hpp:257:45: warning: ‘boost::asio::error::addrinfo_category’ defined but not used [-Wunused-variable]
../../../boost/asio/error.hpp:259:45: warning: ‘boost::asio::error::misc_category’ defined but not used [-Wunused-variable]
"g++" -ftemplate-depth-128 -O0 -fno-inline -Wall -g -pthread -fPIC --coverage -std=c++0x -fno-strict-aliasing -DBOOST_ALL_DLL -DBOOST_ALL_NO_LIB=1 -DBOOST_CHRONO_DYN_LINK=1 -DBOOST_DATE_TIME_DYN_LINK=1 -DBOOST_FILESYSTEM_DYN_LINK=1 -DBOOST_PROGRAM_OPTIONS_DYN_LINK=1 -DBOOST_SYSTEM_DYN_LINK=1 -DBOOST_SYSTEM_NO_DEPRECATED -DBOOST_TEST_NO_AUTO_LINK=1 -DBOOST_THREAD_BUILD_DLL=1 -DBOOST_THREAD_POSIX -DBOOST_THREAD_USE_DLL=1 -DDATE_TIME_INLINE -I"../../.." -I"../../../../type_index" -c -o "../../../bin.v2/libs/application/test/simple_server_application_with_auto_handler.test/gcc-4.6/debug/threading-multi/simple_server_application_with_auto_handler.o" "../example/simple_server_application_with_auto_handler.cpp"
...failed gcc.compile.c++ ../../../bin.v2/libs/application/test/simple_server_application_with_auto_handler.test/gcc-4.6/debug/threading-multi/simple_server_application_with_auto_handler.o...
common.mkdir ../../../bin.v2/libs/application/test/simple_server_application_with_auto_handler_and_global_context.test
common.mkdir ../../../bin.v2/libs/application/test/simple_server_application_with_auto_handler_and_global_context.test/gcc-4.6
common.mkdir ../../../bin.v2/libs/application/test/simple_server_application_with_auto_handler_and_global_context.test/gcc-4.6/debug
common.mkdir ../../../bin.v2/libs/application/test/simple_server_application_with_auto_handler_and_global_context.test/gcc-4.6/debug/threading-multi
gcc.compile.c++ ../../../bin.v2/libs/application/test/simple_server_application_with_auto_handler_and_global_context.test/gcc-4.6/debug/threading-multi/simple_server_application_with_auto_handler_and_global_context.o
passed ../../../bin.v2/libs/application/test/simple_server_application_with_auto_handler_and_global_context.test/gcc-4.6/debug/threading-multi/simple_server_application_with_auto_handler_and_global_context.test
...failed updating 1 target...
...skipped 1 target...
...updated 233 targets...
The command "../../../b2 cxxflags="--coverage -std=$CXX_STANDARD" linkflags="--coverage"" exited with 1.
Done. Your build exited with 1.
When using app with singularity, the termination_handler shows strange behaviour:
Here the example:
Project with 2 cpp files - one for main() which is launch app class, second for app class logic (I'm using context in second file, so include <boost/application.hpp> also)
definition of boost::shared_mutex global_context::lock; in context.hpp
if used in multiple translation units will cause following error
4>zmqapp_srv.obj : error LNK2005: "private: static class boost::shared_mutex boost::application::global_context::lock" (?lock@global_context@application@boost@@0Vshared_mutex@3@A) already defined in console_server_app.obj
This issue appears after singularity removal.
Is it intended and I just incorrectly using boost::application API?
After include <boost/application.hpp>
macro LOG_DEBUG became 7
build with g++
#define VALUE_TO_STRING(x) #x
#define VALUE(x) VALUE_TO_STRING(x)
#define VAR_NAME_VALUE(var) #var "=" VALUE(var)
/* Some example here */
#pragma message(VAR_NAME_VALUE(LOG_DEBUG))
#pragma message(VAR_NAME_VALUE(LOG_INFO))
#pragma message(VAR_NAME_VALUE(LOG_ERROR))
#include <boost/application.hpp>
#pragma message(VAR_NAME_VALUE(LOG_DEBUG))
#pragma message(VAR_NAME_VALUE(LOG_INFO))
#pragma message(VAR_NAME_VALUE(LOG_ERROR))
using namespace boost::application;
int main(int argc, char* argv[])
{
return 0;
}
build with
g++ test.cpp -I../thirdparty/boost/include/ -L ../thirdparty/boost/lib-gcc/libboost_*
output
test.cpp:6:42: note: #pragma message: LOG_DEBUG=LOG_DEBUG
#pragma message(VAR_NAME_VALUE(LOG_DEBUG))
^
test.cpp:7:41: note: #pragma message: LOG_INFO=LOG_INFO
#pragma message(VAR_NAME_VALUE(LOG_INFO))
^
test.cpp:8:42: note: #pragma message: LOG_ERROR=LOG_ERROR
#pragma message(VAR_NAME_VALUE(LOG_ERROR))
^
test.cpp:10:42: note: #pragma message: LOG_DEBUG=7
#pragma message(VAR_NAME_VALUE(LOG_DEBUG))
^
test.cpp:11:41: note: #pragma message: LOG_INFO=6
#pragma message(VAR_NAME_VALUE(LOG_INFO))
^
test.cpp:12:42: note: #pragma message: LOG_ERROR=LOG_ERROR
#pragma message(VAR_NAME_VALUE(LOG_ERROR))
This behavior makes our predefined LOG_DEBUG & LOG_INFO not work any more.
But the LOG_ERROR is good.
I cannot find any #define in boost.application. It's confused.
When compiling on windows with mingw, there are several errors in shared_library_load_mode.hpp:
shared_library_load_mode.hpp:168:49: error: 'LOAD_LIBRARY_SEARCH_APPLICATION_DIR' was not declared in this scope
shared_library_load_mode.hpp:168:49: error: 'LOAD_LIBRARY_SEARCH_APPLICATION_DIR' was not declared in this scope
shared_library_load_mode.hpp:170:49: error: 'LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR' was not declared in this scope
shared_library_load_mode.hpp:171:49: error: 'LOAD_LIBRARY_SEARCH_SYSTEM32' was not declared in this scope
shared_library_load_mode.hpp:172:49: error: 'LOAD_LIBRARY_SEARCH_USER_DIRS' was not declared in this scope
I noticed that the aspect-map parallel test fails. System is Ubuntu 13.04 with g++4.8.1 and boost 1.55 (or the most recent from github).
Test-Output is:
aspect_map_test.cpp(124): test my_aspect_map_.find<my_msg_aspect_test>()->say_hi() == "HI" failed in function: 'void parallel_test<LOOP_INTERACTIONS>::use_sleep_remove_aspect1() [with int LOOP_INTERACTIONS = 100]'
aspect_map_test.cpp(112): test my_aspect_map_.size() == 0 failed in function: 'void parallel_test<LOOP_INTERACTIONS>::wait() [with int LOOP_INTERACTIONS = 100]'
I did not yet manage to check why this happens
Boost 1.60.0 has introduced BOOST_USE_WINAPI_VERSION and changed the default compilation behavior (see the Release Notes).
This should be used for all windows-implementations!
As a positive side-effect this will also deprecate the need for the "WinSdkVerVista.h-Patch" introduced by @BurningEnlightenment in Pull Request #40, which is dangerous anyway (breaks other libs using windows-includes).
For me it's problematic to find how to install it.
I even have asked this question on StackOverflow:
http://stackoverflow.com/questions/28212550/how-to-install-boost-modules-in-boost-1-57-application-and-dll
This project is exactly what I want now, maybe installation is a blocker for more people...
..\..\../boost/test/minimal.hpp(123): exception "std::runtime_error: in file '..\..\../boost/application/shared_library.hpp', line 75: shared_library() failed: %1 is not a valid win32 application" caught in function: 'int main(int, char**)'
Propably this is an error with building the library and not with the loader itself, but I do not have access to a windows machine often enough to investigate this further.
For testing i used the mingw bundled with Qt-Creator 3.0
I can't find a way to get PID from application::server
even on POSIX system.
There is a private member server_application_impl::process_id_
with stored pid_t from fork call, but has no interface to access it.
Maybe it worth to implement aspect through which we can obtain it. All we need is to make call or store value returned by one of this functions:
application | Windows | POSIX |
---|---|---|
common | GetCurrentProcessId | getpid |
server | QueryServiceStatusEx | fork |
The library-test fail on my systems. The paths are configured as absolute paths, where I do not/will never have write access to (C:\test... on windows and /test/... on linux). These should be absolute paths.
Sadly I won't get to provide a patch for this before the weekend.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.