I try to use boost signals and have the following code from the
tutorial.
#include
#include <iostream>
struct HelloWorld
{
void operator()() const
{
std::cout << "Hello, World!" << std::endl;
}
};
int main()
{
// Signal with no arguments and a void return value
boost::signal sig;
// Connect a HelloWorld slot
HelloWorld hello;
sig.connect(hello);
// Call all of the slots
sig();
}
This compiles but gives these errors while linking:
/usr/bin/ld: warning: libstdc++.so.3, needed by
/usr/local/lib//libboost_signals.so, may conflict with libstdc++.so.4
test.o: In function
`_ZN5boost4slotINS_8functionIFvvENS_6detail8function8unusableES5_S5_S5_
S5_S5_S5_S5_S5_S5_EEEC1I10HelloWorldEERKT_':
test.o(.gnu.linkonce.t._ZN5boost4slotINS_8functionIFvvENS_6detail8funct
ion8unusableES5_S5_S5_S5_S5_S5_S5_S5_S5_EEEC1I10HelloWorldEERKT_+0xac):
undefined reference to
`boost::signals::detail::slot_base::create_connection()' test.o: In
function
`_ZN5boost7signal0IvNS_10last_valueIvEEiSt4lessIiENS_8functionIFvvENS_6
detail8function8unusableES9_S9_S9_S9_S9_S9_S9_S9_S9_EEE7connectERKNS_4s
lotISA_EE':
test.o(.gnu.linkonce.t._ZN5boost7signal0IvNS_10last_valueIvEEiSt4lessIi
ENS_8functionIFvvENS_6detail8function8unusableES9_S9_S9_S9_S9_S9_S9_S9_
S9_EEE7connectERKNS_4slotISA_EE+0x83): undefined reference to
`boost::signals::detail::signal_base_impl::connect_slot(boost::any
const&, boost::any const&, std::vector > const&)' test.o: In
function
`_ZN5boost7signal0IvNS_10last_valueIvEEiSt4lessIiENS_8functionIFvvENS_6
detail8function8unusableES9_S9_S9_S9_S9_S9_S9_S9_S9_EEEclEv':
test.o(.gnu.linkonce.t._ZN5boost7signal0IvNS_10last_valueIvEEiSt4lessIi
ENS_8functionIFvvENS_6detail8function8unusableES9_S9_S9_S9_S9_S9_S9_S9_
S9_EEEclEv+0x15): undefined reference to
`boost::signals::detail::call_notification::call_notification(boost::sh
ared_ptrboost::signals::detail::signal_base_impl const&)'
test.o(.gnu.linkonce.t._ZN5boost7signal0IvNS_10last_valueIvEEiSt4lessIi
ENS_8functionIFvvENS_6detail8function8unusableES9_S9_S9_S9_S9_S9_S9_S9_
S9_EEEclEv+0x155): undefined reference to
`boost::signals::detail::call_notification::~call_notification()'
test.o(.gnu.linkonce.t._ZN5boost7signal0IvNS_10last_valueIvEEiSt4lessIi
ENS_8functionIFvvENS_6detail8function8unusableES9_S9_S9_S9_S9_S9_S9_S9_
S9_EEEclEv+0x1c7): undefined reference to
`boost::signals::detail::call_notification::~call_notification()'
test.o: In function
`_ZN5boost7signal0IvNS_10last_valueIvEEiSt4lessIiENS_8functionIFvvENS_6
detail8function8unusableES9_S9_S9_S9_S9_S9_S9_S9_S9_EEEC2ERKS2_RKS4_':
test.o(.gnu.linkonce.t._ZN5boost7signal0IvNS_10last_valueIvEEiSt4lessIi
ENS_8functionIFvvENS_6detail8function8unusableES9_S9_S9_S9_S9_S9_S9_S9_
S9_EEEC2ERKS2_RKS4_+0xa6): undefined reference to
`boost::signals::detail::signal_base::~signal_base()' test.o: In
function `boost::signals::connection::~connection()':
test.o(.gnu.linkonce.t._ZN5boost7signals10connectionD1Ev+0x16):
undefined reference to `boost::signals::connection::disconnect() const'
test.o: In function
`boost::signals::detail::signal_base::signal_base(boost::function2boost::function_base >
const&)':
test.o(.gnu.linkonce.t._ZN5boost7signals6detail11signal_baseC2ERKNS_9fu
nction2IbNS_3anyES4_NS_21empty_function_policyENS_20empty_function_mixi
nESaINS_13function_baseEEEE+0x41): undefined reference to
`boost::signals::detail::signal_base_impl::signal_base_impl(boost::func
tion2boost::function_base >
const&)' test.o: In function
`_ZN5boost7signal0IvNS_10last_valueIvEEiSt4lessIiENS_8functionIFvvENS_6
detail8function8unusableES9_S9_S9_S9_S9_S9_S9_S9_S9_EEED2Ev':
test.o(.gnu.linkonce.t._ZN5boost7signal0IvNS_10last_valueIvEEiSt4lessIi
ENS_8functionIFvvENS_6detail8function8unusableES9_S9_S9_S9_S9_S9_S9_S9_
S9_EEED2Ev+0x11): undefined reference
to`boost::signals::trackable::~trackable()'
test.o(.gnu.linkonce.t._ZN5boost7signal0IvNS_10last_valueIvEEiSt4lessIi
ENS_8functionIFvvENS_6detail8function8unusableES9_S9_S9_S9_S9_S9_S9_S9_
S9_EEED2Ev+0x1f): undefined reference
to`boost::signals::detail::signal_base::~signal_base()' test.o: In
function `void
boost::checked_deleteboost::signals::detail::signal_base_impl(boost::
signals::detail::signal_base_impl*)':
test.o(.gnu.linkonce.t._ZN5boost14checked_deleteINS_7signals6detail16si
gnal_base_implEEEvPT_+0x19): undefined reference
to`boost::signals::detail::signal_base_impl::~signal_base_impl()'
My compiler is gcc 3.2 on FreeBSD.
g++ -o signals test.cpp -I/usr/local/include -L/usr/local/lib/
-lboost_signals
Do you have an idea what I am doing wrong?