#11301 closed Bugs (worksforme)
Boost 1.58 compile error with atomic when plain C++ is used
Reported by: | Owned by: | timblechmann | |
---|---|---|---|
Milestone: | To Be Determined | Component: | atomic |
Version: | Boost 1.58.0 | Severity: | Showstopper |
Keywords: | Cc: | Andrey.Semashev@… |
Description
The short program below ends in
fatal error: boost/atomic/detail/caps_gcc-atomic.hpp: No such file or directory
as BOOST_ATOMIC_EMULATED ends up not being defined. Found on Ubuntu 15.04, 32 and 64 bit, using g++ 4.9.2. I can overcome it by commenting out the #if !(defined(BOOST_ATOMIC_EMULATED)) in both
atomic/capabilities.hpp atomic/detail/operations_lockfree.hpp
(This was in the context of headers-only Boost subset package I maintain for R; the actual commit earlier today is here: https://github.com/eddelbuettel/bh/commit/5238ac85b1afc32544612e615adac3aa279f3807
Dirk
#include <iostream> #include <boost/math/special_functions/gamma.hpp> int main(int argc, char *argv[]) { std::cout << "Value: " << boost::math::lgamma(10.0) << std::endl; }
Change History (5)
comment:1 by , 7 years ago
Cc: | added |
---|---|
Resolution: | → worksforme |
Status: | new → closed |
comment:2 by , 7 years ago
Thanks for the quick follow-up. I am glad that it is not a general issue in Boost; it is definitely an issue on my side with this "BH" package I construct for R (via use of bcp).
Note that the bug only manifests itself without -std=c++11. If you set that, all is good.
Here is complete file:
// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; indent-tabs-mode: nil; compile-command: "g++ -I/usr/local/lib/R/site-library/BH/include boost_atomic_test.cpp -o boost_atomic_test; ./boost_atomic_test"; -*- #include <iostream> #include <boost/math/special_functions/gamma.hpp> int main(int argc, char *argv[]) { std::cout << "Value: " << boost::math::lgamma(10.0) << std::endl; }
and if I M-x compile that I get
Compilation started at Thu May 14 05:12:04
g++ -I/usr/local/lib/R/site-library/BH/include boost_atomic_test.cpp -o boost_atomic_test; ./boost_atomic_test In file included from /usr/local/lib/R/site-library/BH/include/boost/atomic/atomic.hpp:19:0, from /usr/local/lib/R/site-library/BH/include/boost/atomic.hpp:12, from /usr/local/lib/R/site-library/BH/include/boost/math/special_functions/detail/bernoulli_details.hpp:42, from /usr/local/lib/R/site-library/BH/include/boost/math/special_functions/bernoulli.hpp:16, from /usr/local/lib/R/site-library/BH/include/boost/math/special_functions/gamma.hpp:35, from boost_atomic_test.cpp:4: /usr/local/lib/R/site-library/BH/include/boost/atomic/capabilities.hpp:22:63: fatal error: boost/atomic/detail/caps_gcc_atomic.hpp: No such file or directory #include BOOST_ATOMIC_DETAIL_HEADER(boost/atomic/detail/caps_) ^
Dirk
comment:2 by , 7 years ago
Thanks for the quick follow-up. I am glad that it is not a general issue in Boost; it is definitely an issue on my side with this "BH" package I construct for R (via use of bcp).
Note that the bug only manifests itself without -std=c++11. If you set that, all is good.
Here is complete file:
// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; indent-tabs-mode: nil; compile-command: "g++ -I/usr/local/lib/R/site-library/BH/include boost_atomic_test.cpp -o boost_atomic_test; ./boost_atomic_test"; -*- #include <iostream> #include <boost/math/special_functions/gamma.hpp> int main(int argc, char *argv[]) { std::cout << "Value: " << boost::math::lgamma(10.0) << std::endl; }
and if I M-x compile that I get
Compilation started at Thu May 14 05:12:04
g++ -I/usr/local/lib/R/site-library/BH/include boost_atomic_test.cpp -o boost_atomic_test; ./boost_atomic_test In file included from /usr/local/lib/R/site-library/BH/include/boost/atomic/atomic.hpp:19:0, from /usr/local/lib/R/site-library/BH/include/boost/atomic.hpp:12, from /usr/local/lib/R/site-library/BH/include/boost/math/special_functions/detail/bernoulli_details.hpp:42, from /usr/local/lib/R/site-library/BH/include/boost/math/special_functions/bernoulli.hpp:16, from /usr/local/lib/R/site-library/BH/include/boost/math/special_functions/gamma.hpp:35, from boost_atomic_test.cpp:4: /usr/local/lib/R/site-library/BH/include/boost/atomic/capabilities.hpp:22:63: fatal error: boost/atomic/detail/caps_gcc_atomic.hpp: No such file or directory #include BOOST_ATOMIC_DETAIL_HEADER(boost/atomic/detail/caps_) ^
Dirk
comment:3 by , 7 years ago
If you used bcp to create your package then quite a few headers won't be copied. This is because bcp does not support unfolding macros which are used to construct some header names in Boost.Atomic. You will have to copy these headers manually. Basically, you need to copy all files from boost/atomic/detail.
comment:4 by , 7 years ago
Oh, I see. We have been doing this for some time now with bcp and have not yet been bitten, but I understand that bcp may indeed have issues. That creates a bit of a wrinkle for the process.
Can you take a real quick glance at the constructor script here:
https://github.com/eddelbuettel/bh/blob/master/local/scripts/CreateBoost.sh
Maybe other libraries need some post-processing too. That said, we had almost 40 other packages depend on BH, and so far without issues.
I cannot reproduce this, the code compiles without errors on my system (Kubuntu 15.04, x86_64, Boost 1.58). In fact it doesn't even include Boost.Atomic anywhere.
BOOST_ATOMIC_EMULATED
should only be defined when the target platform is not supported or doesn't have atomic ops, so it is expected not to be defined.There is nowhere in the code where caps_gcc-atomic.hpp is included, the correct file name in 1.58 is caps_gcc_atomic.hpp (note the underscore instead of minus) and this file is present. The gcc_atomic part comes from boost/atomic/detail/platform.hpp:38. My guess is that you have an incorrectly modified copy of Boost.