Boost-users
Threads by month
- ----- 2025 -----
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2003 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2002 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2001 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2000 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1999 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1998 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1997 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
April 2014
- 85 participants
- 77 discussions
Hi,
I use async_read of boost::asio to receive network data. After a
complete 'packet' was read (which needs 2 async read calls) I want to
call a user defined handler. Therefore, I introduced a new templater
parameter in my callback methods. Unfortunately, my code ends in a
compile error.
If I outcomment the handler call, than it compiles fine. But with the
call of the handler object, I got a conversion error.
At first I want to describe my code on some excerpts:
----------------------------------------------------------------------------------------
In 'startProcessing' I use perfect forwarding for the callback object.
template<typename T>
void startProcessing(T&& handler,bool activateNoDelay = true)
{
//
m_socket.set_option(asio::ip::tcp::no_delay(activateNoDelay ));
//
startAsyncRead(std::forward<T>(handler));
}
----------------------------------------------------------------------------------------
'startAsynRead' has two overloads. One for boost::bind objects and one
for all other. The boost bind objects are encased with boost::protect to
prevent an evaluation of boost::bind in the later binds.
//
template<typename T>
void startAsyncRead(T handler) { startAsyncReadImpl(handler); }
//overload for boost bind objects necessary
template<typename R, typename F, typename L>
void startAsyncRead(boost::_bi::bind_t<R, F, L> handler)
{
startAsyncReadImpl(boost::protect(handler));
}
----------------------------------------------------------------------------------------
'startAsyncReadImpl' calls asio::async_read and uses boost::bind to
commit the handler object as a third parameter.
//
template<typename T>
void startAsyncReadImpl(T&& handler)
{
//at first we need to read the header information
auto& buf = m_headerInBuffer.getBuffer();
boost::asio::async_read(
m_socket,
boost::asio::buffer(buf.begin(), buf.size()),
boost::asio::transfer_exactly(buf.size()),
boost::bind(&CMessageChannel::handleAsyncReadHeader<T>,
this,_1, _2, std::forward<T>(handler))
);
}
----------------------------------------------------------------------------------------
'handleAsyncReadHeader' does some stuff and than calls asio::async_read
with another method.
//
template<typename T>
void handleAsyncReadHeader(const boost::system::error_code& error,
std::size_t bytes_transferred, T handler)
{
. . .
boost::asio::async_read(
m_socket,
boost::asio::buffer(buf.begin(), buf.size()),
boost::asio::transfer_exactly(size),
boost::bind(&CMessageChannel::handleAsyncReadBody<T>,
this, _1, _2,handler)
);
}
----------------------------------------------------------------------------------------
Finally, 'handleAsyncReadBody' has to do the wished call of the handler.
//
template<typename T>
inline void CMessageChannel::handleAsyncReadBody(const
boost::system::error_code& error, std::size_t bytes_transferred, T handler)
{
...
handler(Packet(m_headerInBuffer.getShort(4), bytes_transferred,
m_currReadBuffer));
}
----------------------------------------------------------------------------------------
And here a call of start process:
void testPacket(Packet& packet) {}
. . .
conn->startProcessing(boost::bind(&CMessageServer::testPacket, this, _1));
----------------------------------------------------------------------------------------
I use Visual Studio 2013 and got the following error message:
1>D:\libraries\cpp\boost\boost_1_55_0\boost/bind/bind.hpp(313): error
C2664: 'void
boost::_mfi::mf1<void,tuc::nw::CMessageServer,tuc::nw::Packet
&>::operator ()(T *,A1) const' : Konvertierung von Argument 2 von 'const
tuc::nw::Packet' in 'tuc::nw::Packet &' nicht möglich
-> can't convert argument 2 'const tuc::nw::Packet' to tuc::nw::Packet &
I never use const in my call chain. It seems that boost::protect
introduces the const for the parameter. And I have no idea how to fix it :(
----------------------------------------------------------------------------------------
Here is the complete error message:
1>------ Erstellen gestartet: Projekt: network, Konfiguration: Release
Win32 ------
1> MessageChannel.cpp
1> MessageServer.cpp
1>D:\libraries\cpp\boost\boost_1_55_0\boost/bind/bind.hpp(313): error
C2664: 'void
boost::_mfi::mf1<void,tuc::nw::CMessageServer,tuc::nw::Packet
&>::operator ()(T *,A1) const' : Konvertierung von Argument 2 von 'const
tuc::nw::Packet' in 'tuc::nw::Packet &' nicht möglich
1> with
1> [
1> T=tuc::nw::CMessageServer
1> , A1=tuc::nw::Packet &
1> ]
1> Durch die Konvertierung gehen Qualifizierer verloren
1>
D:\libraries\cpp\boost\boost_1_55_0\boost/bind/bind_template.hpp(47):
Siehe Verweis auf die Instanziierung der gerade kompilierten
Funktions-template "void
boost::_bi::list2<boost::_bi::value<T>,boost::arg<1>>::operator
()<F,boost::_bi::list1<const A1 &>>(boost::_bi::type<void>,F &,A &,int)".
1> with
1> [
1> T=tuc::nw::CMessageServer *
1> ,
F=boost::_mfi::mf1<void,tuc::nw::CMessageServer,tuc::nw::Packet &>
1> , A1=tuc::nw::Packet
1> , A=boost::_bi::list1<const tuc::nw::Packet &>
1> ]
1>
D:\libraries\cpp\boost\boost_1_55_0\boost/bind/bind_template.hpp(47):
Siehe Verweis auf die Instanziierung der gerade kompilierten
Funktions-template "void
boost::_bi::list2<boost::_bi::value<T>,boost::arg<1>>::operator
()<F,boost::_bi::list1<const A1 &>>(boost::_bi::type<void>,F &,A &,int)".
1> with
1> [
1> T=tuc::nw::CMessageServer *
1> ,
F=boost::_mfi::mf1<void,tuc::nw::CMessageServer,tuc::nw::Packet &>
1> , A1=tuc::nw::Packet
1> , A=boost::_bi::list1<const tuc::nw::Packet &>
1> ]
1>
D:\libraries\cpp\boost\boost_1_55_0\boost/bind/protect.hpp(60): Siehe
Verweis auf die Instanziierung der gerade kompilierten
Funktions-template "void
boost::_bi::bind_t<void,boost::_mfi::mf1<void,tuc::nw::CMessageServer,tuc::nw::Packet
&>,boost::_bi::list2<boost::_bi::value<T>,boost::arg<1>>>::operator
()<A1>(const A1 &)".
1> with
1> [
1> T=tuc::nw::CMessageServer *
1> , A1=tuc::nw::Packet
1> ]
1>
D:\libraries\cpp\boost\boost_1_55_0\boost/bind/protect.hpp(60): Siehe
Verweis auf die Instanziierung der gerade kompilierten
Funktions-template "void
boost::_bi::bind_t<void,boost::_mfi::mf1<void,tuc::nw::CMessageServer,tuc::nw::Packet
&>,boost::_bi::list2<boost::_bi::value<T>,boost::arg<1>>>::operator
()<A1>(const A1 &)".
1> with
1> [
1> T=tuc::nw::CMessageServer *
1> , A1=tuc::nw::Packet
1> ]
1>
G:\Quellcode\nc-programming\nc-libs\nc-libs/network/MessageChannel.h(196):
Siehe Verweis auf die Instanziierung der gerade kompilierten
Funktions-template "void
boost::_bi::protected_bind_t<boost::_bi::bind_t<void,boost::_mfi::mf1<void,tuc::nw::CMessageServer,tuc::nw::Packet
&>,boost::_bi::list2<boost::_bi::value<T>,boost::arg<1>>>>::operator
()<tuc::nw::Packet>(const A1 &)".
1> with
1> [
1> T=tuc::nw::CMessageServer *
1> , A1=tuc::nw::Packet
1> ]
1>
G:\Quellcode\nc-programming\nc-libs\nc-libs/network/MessageChannel.h(196):
Siehe Verweis auf die Instanziierung der gerade kompilierten
Funktions-template "void
boost::_bi::protected_bind_t<boost::_bi::bind_t<void,boost::_mfi::mf1<void,tuc::nw::CMessageServer,tuc::nw::Packet
&>,boost::_bi::list2<boost::_bi::value<T>,boost::arg<1>>>>::operator
()<tuc::nw::Packet>(const A1 &)".
1> with
1> [
1> T=tuc::nw::CMessageServer *
1> , A1=tuc::nw::Packet
1> ]
1>
G:\Quellcode\nc-programming\nc-libs\nc-libs/network/MessageChannel.h(179):
Siehe Verweis auf die Instanziierung der gerade kompilierten
Funktions-template "void
tuc::nw::CMessageChannel::handleAsyncReadBody<T>(const
boost::system::error_code &,size_t,T)".
1> with
1> [
1>
T=boost::_bi::protected_bind_t<boost::_bi::bind_t<void,boost::_mfi::mf1<void,tuc::nw::CMessageServer,tuc::nw::Packet
&>,boost::_bi::list2<boost::_bi::value<tuc::nw::CMessageServer
*>,boost::arg<1>>>>
1> ]
1>
G:\Quellcode\nc-programming\nc-libs\nc-libs/network/MessageChannel.h(127):
Siehe Verweis auf die Instanziierung der gerade kompilierten
Funktions-template "void
tuc::nw::CMessageChannel::handleAsyncReadHeader<T>(const
boost::system::error_code &,size_t,T)".
1> with
1> [
1>
T=boost::_bi::protected_bind_t<boost::_bi::bind_t<void,boost::_mfi::mf1<void,tuc::nw::CMessageServer,tuc::nw::Packet
&>,boost::_bi::list2<boost::_bi::value<tuc::nw::CMessageServer
*>,boost::arg<1>>>>
1> ]
1>
G:\Quellcode\nc-programming\nc-libs\nc-libs/network/MessageChannel.h(117):
Siehe Verweis auf die Instanziierung der gerade kompilierten
Funktions-template "void
tuc::nw::CMessageChannel::startAsyncReadImpl<boost::_bi::protected_bind_t<boost::_bi::bind_t<void,boost::_mfi::mf1<void,tuc::nw::CMessageServer,tuc::nw::Packet
&>,boost::_bi::list2<boost::_bi::value<T>,boost::arg<1>>>>>(boost::_bi::protected_bind_t<boost::_bi::bind_t<void,boost::_mfi::mf1<void,tuc::nw::CMessageServer,tuc::nw::Packet
&>,boost::_bi::list2<boost::_bi::value<T>,boost::arg<1>>>> &&)".
1> with
1> [
1> T=tuc::nw::CMessageServer *
1> ]
1>
G:\Quellcode\nc-programming\nc-libs\nc-libs/network/MessageChannel.h(76): Siehe
Verweis auf die Instanziierung der gerade kompilierten
Funktions-template "void
tuc::nw::CMessageChannel::startAsyncRead<void,boost::_mfi::mf1<void,tuc::nw::CMessageServer,tuc::nw::Packet
&>,boost::_bi::list2<boost::_bi::value<T>,boost::arg<1>>>(boost::_bi::bind_t<void,boost::_mfi::mf1<void,tuc::nw::CMessageServer,tuc::nw::Packet
&>,boost::_bi::list2<boost::_bi::value<T>,boost::arg<1>>>)".
1> with
1> [
1> T=tuc::nw::CMessageServer *
1> ]
1> MessageServer.cpp(43): Siehe Verweis auf die Instanziierung
der gerade kompilierten Funktions-template "void
tuc::nw::CMessageChannel::startProcessing<boost::_bi::bind_t<void,boost::_mfi::mf1<void,tuc::nw::CMessageServer,tuc::nw::Packet
&>,boost::_bi::list2<boost::_bi::value<T>,boost::arg<1>>>>(boost::_bi::bind_t<void,boost::_mfi::mf1<void,tuc::nw::CMessageServer,tuc::nw::Packet
&>,boost::_bi::list2<boost::_bi::value<T>,boost::arg<1>>> &&,bool)".
1> with
1> [
1> T=tuc::nw::CMessageServer *
1> ]
========== Erstellen: 0 erfolgreich, 1 fehlerhaft, 0 aktuell, 0
übersprungen ==========
2
1

installing boost getting error "ld: symbol(s) not found for architecture x86_64" on OSX 10.9.2
by Corentin Hamel 02 Apr '14
by Corentin Hamel 02 Apr '14
02 Apr '14
Hi everyone,
I hope this is the right place to ask my question.
I'm trying to build boost 1.55.0 for python on OSX 10.9.2 but i'm encountering the following error "ld: symbol(s) not found for architecture x86_64" and I'm really blocked. I read it might be related to the standard c++ library which changed with maverick to be libc++ by default. But even adding
cxxflags="-stdlib=libstdc++" when executing ./b2 didn't help.
Here is what I did following the boost tutorial:
download boost_1_55_0.tar
./bootstrap.sh --with-libraries=python toolset=darwin
./b2 include="/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/"
And I get the following error:
link.jam: No such file or directory
Building the Boost C++ Libraries.
error: No best alternative for /python_for_extensions
next alternative: required properties: <python>2.7 <target-os>darwin
matched
next alternative: required properties: <python>2.7 <target-os>darwin
matched
error: No best alternative for /python_for_extensions
next alternative: required properties: <python>2.7 <target-os>darwin
matched
next alternative: required properties: <python>2.7 <target-os>darwin
matched
Component configuration:
- python : building
darwin.link.dll bin.v2/libs/python/build/darwin-4.2.1/release/threading- multi/libboost_python.dylib
Undefined symbols for architecture x86_64:
"_PyFile_FromString", referenced from:
boost::python::exec_file(boost::python::str, boost::python::api::object, boost::python::api::object) in exec.o
"_PyFile_AsFile", referenced from:
boost::python::exec_file(boost::python::str, boost::python::api::object, boost::python::api::object) in exec.o
"_PyEval_GetGlobals", referenced from:
boost::python::eval(boost::python::str, boost::python::api::object, boost::python::api::object) in exec.o
boost::python::exec(boost::python::str, boost::python::api::object, boost::python::api::object) in exec.o
boost::python::exec_statement(boost::python::str, boost::python::api::object, boost::python::api::object) in exec.o
boost::python::exec_file(boost::python::str, boost::python::api::object, boost::python::api::object) in exec.o
"_PyRun_StringFlags", referenced from:
........
"_PyExc_StopIteration", referenced from:
boost::python::objects::stop_iteration_error() in iterator.o
"_PyNumber_InPlaceAdd", referenced from:
boost::python::api::operator+=(boost::python::api::object&, boost::python::api::object const&) in object_operators.o
"_PyUnicodeUCS2_FromEncodedObject", referenced from:
_encode_string_unaryfunc in builtin_converters.o
"_PyErr_NoMemory", referenced from:
boost::python::handle_exception_impl(boost::function0<void>) in errors.o
"_PyDict_New", referenced from:
boost::python::detail::dict_base::dict_base() in dict.o
boost::python::detail::dict_base::dict_base() in dict.o
_instance_get_dict in class.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
"g++" -dynamiclib -Wl,-single_module -install_name "libboost_python.dylib" -o "bin.v2/libs/python/build/darwin-4.2.1/release/threading-multi/libboost_python.dylib" "bin.v2/libs/python/build/darwin-4.2.1/release/threading-multi/numeric.o" "bin.v2/libs/python/build/darwin-4.2.1/release/threading-multi/list.o" "bin.v2/libs/python/build/darwin-4.2.1/release/threading-multi/long.o" "bin.v2/libs/python/build/darwin-4.2.1/release/threading-multi/dict.o" "bin.v2/libs/python/build/darwin-4.2.1/release/threading-multi/tuple.o" "bin.v2/libs/python/build/darwin-4.2.1/release/threading-multi/str.o" "bin.v2/libs/python/build/darwin-4.2.1/release/threading-multi/slice.o" "bin.v2/libs/python/build/darwin-4.2.1/release/threading-multi/converter/from_python.o" "bin.v2/libs/python/build/darwin-4.2.1/release/threading-multi/converter/registry.o" "bin.v2/libs/python/build/darwin-4.2.1/release/threading-multi/converter/type_id.o" "bin.v2/libs/python/build/darwin-4.2.1/release/threading-multi/object/enum.o" "bin.v2/libs/python/build/darwin-4.2.1/release/threading-multi/object/class.o" "bin.v2/libs/python/build/darwin-4.2.1/release/threading-multi/object/function.o" "bin.v2/libs/python/build/darwin-4.2.1/release/threading-multi/object/inheritance.o" "bin.v2/libs/python/build/darwin-4.2.1/release/threading-multi/object/life_support.o" "bin.v2/libs/python/build/darwin-4.2.1/release/threading-multi/object/pickle_support.o" "bin.v2/libs/python/build/darwin-4.2.1/release/threading-multi/errors.o" "bin.v2/libs/python/build/darwin-4.2.1/release/threading-multi/module.o" "bin.v2/libs/python/build/darwin-4.2.1/release/threading-multi/converter/builtin_converters.o" "bin.v2/libs/python/build/darwin-4.2.1/release/threading-multi/converter/arg_to_python_base.o" "bin.v2/libs/python/build/darwin-4.2.1/release/threading-multi/object/iterator.o" "bin.v2/libs/python/build/darwin-4.2.1/release/threading-multi/object/stl_iterator.o" "bin.v2/libs/python/build/darwin-4.2.1/release/threading-multi/object_protocol.o" "bin.v2/libs/python/build/darwin-4.2.1/release/threading-multi/object_operators.o" "bin.v2/libs/python/build/darwin-4.2.1/release/threading-multi/wrapper.o" "bin.v2/libs/python/build/darwin-4.2.1/release/threading-multi/import.o" "bin.v2/libs/python/build/darwin-4.2.1/release/threading-multi/exec.o" "bin.v2/libs/python/build/darwin-4.2.1/release/threading-multi/object/function_doc_signature.o" -headerpad_max_install_names -Wl,-dead_strip -no_dead_strip_inits_and_terms
...failed darwin.link.dll bin.v2/libs/python/build/darwin-4.2.1/release/threading- multi/libboost_python.dylib...
...skipped <pstage/lib>libboost_python.dylib for lack of <pbin.v2/libs/python/build/darwin- 4.2.1/release/threading-multi>libboost_python.dylib...
...failed updating 1 target...
...skipped 1 target...
Thanks for your help!
Corentin Hamel
Software Engineer
Rocketboots
Level 11, 189 Kent Street
Sydney NSW 2000
2
5