Discussion:
[boost] [chrono] Header only library build and boost::system dependency
Edward Diener
2016-05-04 04:05:41 UTC
Permalink
The documentation for chrono says:

"How to Build Boost.Chrono as a Header Only Library?

When BOOST_CHRONO_HEADER_ONLY is defined the lib is header-only.

If in addition BOOST_USE_WINDOWS_H is defined <windows.h> is included,
otherwise files in boost/detail/win are used to reduce the impact of
including <windows.h>.

However, you will either need to define
BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING or link with Boost.System. "

So I have:

#define BOOST_CHRONO_HEADER_ONLY
#define BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
#include <boost/chrono.hpp>

followed by some code using chrono, and I still get when linking my exe:

gcc.link
C:\Programming\VersionControl\modular-boost\build\boost\bin.v2\libs\cxx_dual\test\test_chrono.test\gcc-mingw-5.3\debug\test_chrono.exe
C:\Programming\VersionControl\modular-boost\build\boost\bin.v2\libs\cxx_dual\test\test_chrono.test\gcc-mingw-5.3\debug\test_chrono.o:
In function `_static_initialization_and_destruction_0':
E:\Programming\VersionControl\modular-boost\libs\cxx_dual\test/../../../boost/system/error_code.hpp:221:
undefined reference to `boost::system::generic_category()'
E:\Programming\VersionControl\modular-boost\libs\cxx_dual\test/../../../boost/system/error_code.hpp:222:
undefined reference to `boost::system::generic_category()'
E:\Programming\VersionControl\modular-boost\libs\cxx_dual\test/../../../boost/system/error_code.hpp:223:
undefined reference to `boost::system::system_category()'
collect2.exe: error: ld returned 1 exit status

Is there a way to use chrono without having to link boost::system ?


_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Vicente J. Botet Escriba
2016-05-04 05:17:28 UTC
Permalink
Post by Edward Diener
"How to Build Boost.Chrono as a Header Only Library?
When BOOST_CHRONO_HEADER_ONLY is defined the lib is header-only.
If in addition BOOST_USE_WINDOWS_H is defined <windows.h> is included,
otherwise files in boost/detail/win are used to reduce the impact of
including <windows.h>.
However, you will either need to define
BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING or link with
Boost.System. "
#define BOOST_CHRONO_HEADER_ONLY
#define BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
#include <boost/chrono.hpp>
gcc.link
C:\Programming\VersionControl\modular-boost\build\boost\bin.v2\libs\cxx_dual\test\test_chrono.test\gcc-mingw-5.3\debug\test_chrono.exe
undefined reference to `boost::system::generic_category()'
undefined reference to `boost::system::generic_category()'
undefined reference to `boost::system::system_category()'
collect2.exe: error: ld returned 1 exit status
Is there a way to use chrono without having to link boost::system ?
Hi,

Please fill a Trac ticket so that I don't forget to check this.

Coud you try to replace in boost/chrono/detail/system.hpp:

#include <boost/system/error_code.hpp>

with

#if defined BOOST_CHRONO_PROVIDE_HYBRID_ERROR_HANDLING
#include <boost/system/error_code.hpp>
#endif


I will come to you on a week.

Vicente

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Edward Diener
2016-05-04 10:06:02 UTC
Permalink
Post by Vicente J. Botet Escriba
Post by Edward Diener
"How to Build Boost.Chrono as a Header Only Library?
When BOOST_CHRONO_HEADER_ONLY is defined the lib is header-only.
If in addition BOOST_USE_WINDOWS_H is defined <windows.h> is included,
otherwise files in boost/detail/win are used to reduce the impact of
including <windows.h>.
However, you will either need to define
BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING or link with
Boost.System. "
#define BOOST_CHRONO_HEADER_ONLY
#define BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
#include <boost/chrono.hpp>
gcc.link
C:\Programming\VersionControl\modular-boost\build\boost\bin.v2\libs\cxx_dual\test\test_chrono.test\gcc-mingw-5.3\debug\test_chrono.exe
undefined reference to `boost::system::generic_category()'
undefined reference to `boost::system::generic_category()'
undefined reference to `boost::system::system_category()'
collect2.exe: error: ld returned 1 exit status
Is there a way to use chrono without having to link boost::system ?
Hi,
Please fill a Trac ticket so that I don't forget to check this.
I will do that if I can't figure out a PR.
Post by Vicente J. Botet Escriba
#include <boost/system/error_code.hpp>
with
#if defined BOOST_CHRONO_PROVIDE_HYBRID_ERROR_HANDLING
#include <boost/system/error_code.hpp>
#endif
It's not from boost/chrono/detail/system.hpp. Everything in there is
already protected by:

#if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING

which I am defining according to the doc instructions.
Post by Vicente J. Botet Escriba
I will come to you on a week.
Vicente
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Edward Diener
2016-05-04 13:08:57 UTC
Permalink
skipped...
Hi,
Please fill a Trac ticket so that I don't forget to check this.
I filed a Trac ticket at https://svn.boost.org/trac/boost/ticket/12176.
#include <boost/system/error_code.hpp>
with
#if defined BOOST_CHRONO_PROVIDE_HYBRID_ERROR_HANDLING
#include <boost/system/error_code.hpp>
#endif
I will come to you on a week.
Vicente
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Marc Glisse
2016-05-04 05:26:00 UTC
Permalink
Post by Edward Diener
gcc.link
C:\Programming\VersionControl\modular-boost\build\boost\bin.v2\libs\cxx_dual\test\test_chrono.test\gcc-mingw-5.3\debug\test_chrono.exe
undefined reference to `boost::system::generic_category()'
undefined reference to `boost::system::generic_category()'
undefined reference to `boost::system::system_category()'
collect2.exe: error: ld returned 1 exit status
Is there a way to use chrono without having to link boost::system ?
BOOST_SYSTEM_NO_DEPRECATED ? I don't understand how this hasn't been made
the default yet...
--
Marc Glisse

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Edward Diener
2016-05-04 10:25:03 UTC
Permalink
Post by Marc Glisse
Post by Edward Diener
gcc.link
C:\Programming\VersionControl\modular-boost\build\boost\bin.v2\libs\cxx_dual\test\test_chrono.test\gcc-mingw-5.3\debug\test_chrono.exe
undefined reference to `boost::system::generic_category()'
undefined reference to `boost::system::generic_category()'
undefined reference to `boost::system::system_category()'
collect2.exe: error: ld returned 1 exit status
Is there a way to use chrono without having to link boost::system ?
BOOST_SYSTEM_NO_DEPRECATED ? I don't understand how this hasn't been
made the default yet...
Defining BOOST_SYSTEM_NO_DEPRECATED worked in my code. Perhaps the
chrono documentation just needs to be updated to specify that
BOOST_SYSTEM_NO_DEPRECATED needs to be defined also in order not to link
boost::system.


_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Loading...