Boost Serialization: undefined reference to `__assert'

Hello everyone Today, I just happened to download the latest version of cygwin, including gcc 3.4.4. While a simple hello world works perfectly fine, trying to compile this code using a statically linked libserialization.a results in dozens of linker errors, all stating "undefined reference to `__assert'". #include <boost/assign/list_of.hpp> #include <boost/archive/xml_iarchive.hpp> #include <boost/archive/xml_oarchive.hpp> #include <boost/lambda/lambda.hpp> #include <boost/serialization/vector.hpp> #include <iostream> #include <fstream> using namespace boost::lambda; using namespace boost::assign; using namespace boost::archive; using namespace boost::serialization; using namespace std; int main() { { vector<string> v = list_of("123")("Boost")("Serialization"); ofstream ofs("test.xml"); xml_oarchive oxml(ofs); oxml << make_nvp("VectorTest", v); } { vector<string> v; ifstream ifs("test.xml"); xml_iarchive ixml(ifs); ixml >> make_nvp("VectorTest", v); for_each(v.begin(), v.end(), cout << _1 << "\n"); } return 0; } Is this a problem or known issue when using cygwin? I'm using eclipse in addition, by the way. The code works perfectly fine on other platforms, so I imagine it must be a problem when using the serialization library with cygwin. Thanks in advance for any help you can offer me here and best regards Pascal Kesseli

Sounds to me a confusion between not using NDEBUG during compilation and not linking with debug libraries. Robert Ramey "Kesseli Pascal" <pascal_kesseli@hotmail.com> wrote in message news:BAY107-DAV61A681DE4D2FF60DF26F8F2B50@phx.gbl... Hello everyone Today, I just happened to download the latest version of cygwin, including gcc 3.4.4. While a simple hello world works perfectly fine, trying to compile this code using a statically linked libserialization.a results in dozens of linker errors, all stating "undefined reference to `__assert'". #include <boost/assign/list_of.hpp> #include <boost/archive/xml_iarchive.hpp> #include <boost/archive/xml_oarchive.hpp> #include <boost/lambda/lambda.hpp> #include <boost/serialization/vector.hpp> #include <iostream> #include <fstream> using namespace boost::lambda; using namespace boost::assign; using namespace boost::archive; using namespace boost::serialization; using namespace std; int main() { { vector<string> v = list_of("123")("Boost")("Serialization"); ofstream ofs("test.xml"); xml_oarchive oxml(ofs); oxml << make_nvp("VectorTest", v); } { vector<string> v; ifstream ifs("test.xml"); xml_iarchive ixml(ifs); ixml >> make_nvp("VectorTest", v); for_each(v.begin(), v.end(), cout << _1 << "\n"); } return 0; } Is this a problem or known issue when using cygwin? I'm using eclipse in addition, by the way. The code works perfectly fine on other platforms, so I imagine it must be a problem when using the serialization library with cygwin. Thanks in advance for any help you can offer me here and best regards Pascal Kesseli ------------------------------------------------------------------------------ _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

Hi everyone Please have a look at the following code: 1: const regex REPORT_HEADER("^[^()]+((?:\\([^()]*\\)){4,})$"); 2: const regex REPORT_DATA_ITEM("\\(([^()]*?)\\)(.*)"); 3: string headerLine = "P.01(1090618220000)(0008)(15)(3)(1.5.0)(kW)(5.5.0)(kvar)(8.5.0)(kvar)"; 4: smatch match; 5: if(regex_match(headerLine, match, REPORT_HEADER)) { 6: regex_match(lexical_cast<string>(match[1]), match, REPORT_DATA_ITEM); 7: clog << match[1] << endl; 8: regex_match(lexical_cast<string>(match[2]), match, REPORT_DATA_ITEM); 9: clog << match[1] << endl; 10: regex_match(lexical_cast<string>(match[2]), match, REPORT_DATA_ITEM); 11: clog << match[1] << endl; 12: regex_match(lexical_cast<string>(match[2]), match, REPORT_DATA_ITEM); 13: unsigned int numberOfEntries = lexical_cast<unsigned int>(match[1]); 14: string tmp; 15: for(unsigned int i = 0; i < numberOfEntries; ++i) { 16: tmp = match[2]; 17: clog << "1: " << tmp << endl; 18: if(regex_match(tmp, match, REPORT_DATA_ITEM)) { 19: clog << "2: " << match[1] << endl; 20: tmp = match[2]; 21: clog << "3: " << tmp << endl; 22: if(regex_match(tmp, match, REPORT_DATA_ITEM)) { 23: clog << "4: " << match[1] << endl; 24: } 25: } 26: } 27: } Important is actually only the trailing for loop. Running the code as it reads above, the output is as expected: 1090618220000 0008 15 1: (1.5.0)(kW)(5.5.0)(kvar)(8.5.0)(kvar) 2: 1.5.0 3: (kW)(5.5.0)(kvar)(8.5.0)(kvar) 4: kW 1: (5.5.0)(kvar)(8.5.0)(kvar) 2: 5.5.0 3: (kvar)(8.5.0)(kvar) 4: kvar 1: (8.5.0)(kvar) 2: 8.5.0 3: (kvar) 4: kvar However, changing line 18 to: if(regex_match(lexical_cast<string>(match[2]), match, REPORT_DATA_ITEM)) { and thus eliminating the temporary variable tmp, results in the following output: kW kvar 1090618220000 0008 15 1: (1.5.0)(kW)(5.5.0)(kvar)(8.5.0)(kvar) 1: 1: What might be the problem here? Am I misusing the match_results class in some way? Thanks for any help and best regards Pascal

Pascal Kesseli wrote: Sent: Friday, July 31, 2009 6:40 AM
However, changing line 18 to: if(regex_match(lexical_cast<string>(match[2]), match,
REPORT_DATA_ITEM)) {
and thus eliminating the temporary variable tmp, results in the
following
output:
kW kvar 1090618220000 0008 15 1: (1.5.0)(kW)(5.5.0)(kvar)(8.5.0)(kvar) 1: 1:
What might be the problem here? Am I misusing the match_results class in some way?
Thanks for any help and best regards Pascal
match_results stores iterators into the original string. The string returned from lexical_cast goes out of scope as soon as regex_match returns, therefore invalidating the iterators in match_results. HTH Andrew
participants (4)
-
Andrew Holden
-
Kesseli Pascal
-
Pascal Kesseli
-
Robert Ramey