Here is a tutorial. I compile succeeded at DEBUG mode, but failed at RELEASE mode. And I got LNK2001 Error.
#include <boost/statechart/event.hpp>
#include <boost/statechart/state
_machine.hpp>
#include <boost/statechart/simple_state.hpp>
#include <boost/statechart/transition.hpp>
namespace sc = boost::statechart;
struct EvStartStop : sc::event< EvStartStop > {};
struct EvReset : sc::event< EvReset > {};
struct Active;
struct StopWatch : sc::state_machine< StopWatch, Active > {};
struct Stopped;
struct Active : sc::simple_state< Active, StopWatch, Stopped >
{
typedef sc::transition< EvReset, Active > reactions;
};
struct Running : sc::simple_state< Running, Active >
{
typedef sc::transition< EvStartStop, Stopped > reactions;
};
struct Stopped : sc::simple_state< Stopped, Active >
{
typedef sc::transition< EvStartStop, Running > reactions;
};
// A state can define an arbitrary number of reactions. That's
// why we have to put them into an mpl::list<> as soon as there
// is more than one of them
// (see Specifying multiple reactions for a state).
int main()
{
StopWatch myWatch;
myWatch.initiate();
myWatch.process_event( EvStartStop() );
myWatch.process_event
( EvStartStop() );
myWatch.process_event( EvStartStop() );
myWatch.process_event( EvReset() );
return 0;
}
//Output
Linking...
statechart.obj : error LNK2001: unresolved external symbol "public: void __thiscall boost::statechart::detail::no_context<struct EvReset>::no_function(struct EvReset const &)" (?no_function@?$no_context@UEvReset@@@
detail@statechart@boost@@QAEXABUEvReset@@@Z)
statechart.obj : error LNK2001: unresolved external symbol "public: void __thiscall boost::statechart::detail::no_context<struct EvStartStop>::no_function(struct EvStartStop const &)" (?no_function@?$no_context@UEvStartStop@@@
detail@statechart@boost@@QAEXABUEvStartStop@@@Z)
i:\programme\test\statechart\Release\statechart.exe : fatal error LNK1120: 2 unresolved externals
How can I solve the problem? Thank you.