iostreams library and zlib/bzip2 support

Hi All, Right now, in order to compile and link to the iostreams library with zlib/bzip2 support, I have to include the .cpp files in my project (as mentioned in the boost docs). I'm not too fond of this idea as I want to keep 3rd-party code outside of my project build. Perhaps I have missed something in the docs, but is there another way to link with the iostreams library without including the .cpp files? Also along these lines ... is there any reason why zlib.cpp and bzip2.cpp are not compiled into libboost_iostreams-*.lib? Many Thanks, Rob

Robert Vinluan wrote:
Right now, in order to compile and link to the iostreams library with zlib/bzip2 support, I have to include the .cpp files in my project (as mentioned in the boost docs). I'm not too fond of this idea as I want to keep 3rd-party code outside of my project build.
Perhaps I have missed something in the docs, but is there another way to link with the iostreams library without including the .cpp files?
Huh ? I don't understand... forgive me for my ignorance, since I'm
probably missing your point, but I just, for example, #include

Hi, I would like to try the boost test library. I see the example here, but I don't know how to compile and run it on Linux, Can anyone please help? /home/yinglcs/data/src/boost_1_33_1/libs/test/example Thank you. Sam __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 The easiest way to do it is to have compiled boost libraries. This means that you have run the bjam install procedure instead of just copying the header files over to /usr/include/boost. With the libs installed, you will need to put -lboost_unit_test_framework on your boost link line. You should now be OK, except for the fact that you might find your test output a little disconcerting. I was expecting something like PERL's test module output, but instead got something which looks like it was generated by g++'s compile error generator. On the other hand, you might want to have a look at cxxtext at http://cxxtest.sourceforge.net/guide.html Evan yinglcs2@yahoo.com wrote:
Hi,
I would like to try the boost test library.
I see the example here, but I don't know how to compile and run it on Linux, Can anyone please help? /home/yinglcs/data/src/boost_1_33_1/libs/test/example
Thank you. Sam
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) iD8DBQFD75ZMpxCQXwV2bJARAo+WAJ49phPUJIhfs6vFmdKOPy2rJcQEVwCgya3s ECi0e8H/+X3wK3sXK0RXDNw= =eKNJ -----END PGP SIGNATURE-----

The easiest way to do it is to have compiled boost libraries. This means that you have run the bjam install procedure instead of just copying the header files over to /usr/include/boost. With the libs installed, you will need to put -lboost_unit_test_framework on your boost link line.
The easiest way is indeed to use a bjam. Just make bjam in boost/buils/src directory. Then run bjam -sTOOLS=gcc <example-name> This command will build both the library (put it in proper place) and an example.
You should now be OK, except for the fact that you might find your test output a little disconcerting. I was expecting something like PERL's test module output
Why? In C++ we should expect something similal to what C++ compilers produce.
but instead got something which looks like it was generated by g++'s compile error generator. On
Yes. And VC++. But if you prefer different output format you could easily enough generate almost any desirable one. (if anyone interrsted to submit this for inclusion into library that maybe considered)
Hi,
I would like to try the boost test library.
I see the example here, but I don't know how to compile and run it on Linux, Can anyone please help? /home/yinglcs/data/src/boost_1_33_1/libs/test/example
Thank you. Sam
P.S. I recommend openning new thread instead of chnaging subject in existent one.

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Gennadiy Rozental wrote:
The easiest way to do it is to have compiled boost libraries. This means that you have run the bjam install procedure instead of just copying the header files over to /usr/include/boost. With the libs installed, you will need to put -lboost_unit_test_framework on your boost link line.
The easiest way is indeed to use a bjam.
Just make bjam in boost/buils/src directory. Then run bjam -sTOOLS=gcc <example-name>
This command will build both the library (put it in proper place) and an example.
You should now be OK, except for the fact that you might find your test output a little disconcerting. I was expecting something like PERL's test module output
Why? In C++ we should expect something similal to what C++ compilers produce.
but instead got something which looks like it was generated by g++'s compile error generator. On
Yes. And VC++. But if you prefer different output format you could easily enough generate almost any desirable one.
Well, I had a look at your docs & came away with unresolved questions regarding how to set differing output formats. The one method I found was to set the log_level to none (which cuts out too much info) didn't seem too appealing. What I was looking for was a way to print out the progress messages (completing test xxx: succeeded/failed) and the message with exceptions on it (just the one line), but nothing more. I guess the question I have regarding formatting is, how do you create a format & then tie it in to a test suite? If you can get me pointed in the right direction I might be able to come up with something. Evan Carew -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) iD8DBQFD7+JZpxCQXwV2bJARAq9AAJ4jOCpg+CsSUF4hDLacLcuz+7SkGQCgqrtl LJcwfEhkiUZu2O9Jjd04Lco= =JTI6 -----END PGP SIGNATURE-----

Yes. And VC++. But if you prefer different output format you could easily enough generate almost any desirable one.
Well, I had a look at your docs & came away with unresolved questions regarding how to set differing output formats. The one method I found was to set the log_level to none (which cuts out too much info) didn't seem too appealing. What I was looking for was a way to print out the progress messages (completing test xxx: succeeded/failed) and the message with exceptions on it (just the one line), but nothing more. I guess the question I have regarding formatting is, how do you create a format & then tie it in to a test suite? If you can get me pointed in the right direction I might be able to come up with something.
It really depends on which version of boost you are using. Lets assume it's latest CVS. Docs wouldn't be too much help - information is way outdated. What you need is to write a custom unit test log formatter. This is the class that implements unit_test_log_formatter interface. See output/compiler_log_formatter.hpp for an example You could register the custom formatter using unit_test_log::set_formatter() call. If you have any more specific questions fell free to ask. Gennadiy

I have a function in STL which add the 'area'
attribute of a list of Rect.
float getTotalAreaPerCent(BlockDataList& bdl) {
return accumulate (bdl.begin(), bdl.end(), 0.0,
add_area_per_cent

yinglcs2@yahoo.com wrote:
I have a function in STL which add the 'area' attribute of a list of Rect.
float getTotalAreaPerCent(BlockDataList& bdl) { return accumulate (bdl.begin(), bdl.end(), 0.0, add_area_per_cent
()); } public binary_function
{ template< class T1, class T2> class add_area_per_cent public: add_area_per_cent() { }
T2 operator() (T2 initial, T1 element) { if (element != NULL) { return initial + element->getAreaPerCent(); } else { return initial; } }
};
Can you please tell me how can I reduce the amount of code and use Boost bind library to achieve the same thing?
You can't simplify your code any further by using Bind, since your function object doesn't hold any state. You can use the simpler function object: struct add_area_per_cent { float operator()( float initial, BlockData* element ) const { return element? initial + element->getAreaPerCent(): initial; } } or function: float add_area_per_cent( float initial, BlockData* element ) { return element? initial + element->getAreaPerCent(): initial; } if you don't need the genericity, but your code is fine as it is.

Leon Mergen wrote:
Huh ? I don't understand... forgive me for my ignorance, since I'm probably missing your point, but I just, for example, #include
and it just works, without linking to any special lib... what exactly are your needs that require linking against a lib? Or is it that bzip2/zlib support needs linking with a boost library ? Regards,
Leon Mergen http://www.solatis.com/
Hi Leon, Thanks for the response. I read my message again and found that it wasn't very clear. Anyway, I'm building the boost iostreams library with zlib support. When I build it as a static library on Windows (i.e. libboost_iostreams-*.lib), everything works fine. I can include the iostreams headers in my code and link my project to the library without any problems. However, when I build iostreams as a dynamic library and link my project to its import library (i.e. boost_iostreams-*.lib), I receive linker errors about unresolved symbols. The unresolved symbols are symbols from the iostreams' zlib component. I did a symbol listing and found that all the symbols declared in ./boost/iostreams/filter/zlib.hpp were available in the static library, but not in the import library. So it seems that the corresponding implementation file, ./libs/iostreams/src/zlib.cpp, is not being compiled into the dynamic library. So I checked the docs and found a small paragraph stating that if I wanted to include zlib.hpp in my code, then I needed to add zlib.cpp to my project as well as define the preprocessor symbol BOOST_IOSTREAMS_NO_LIB. Here's a link to the doc page: http://www.boost.org/libs/iostreams/doc/installation.html It's the first paragraph under the "Building with an IDE or Makefile" section. Anyway, I followed the doc page and added zlib.cpp to my project. I recompiled and relinked to the dynamic library and everything worked. The doc page appears to backup my finding that zlib.cpp isn't being compiled into the dynamic version of the iostreams library. So my question is .... why? Why is zlib.cpp compiled into the static version of the iostreams library, but not the dynamic version? I would really like to link against a dynamic version of iostreams with zlib support without explicitly adding zlib.cpp to my project. Has anyone been able to do this successfully? Thanks, Rob
participants (6)
-
Evan Carew
-
Gennadiy Rozental
-
Leon Mergen
-
Peter Dimov
-
Robert Vinluan
-
yinglcs2@yahoo.com