I'm trying to compile a library written with C++11 features using GCC 5.1 on Ubuntu. However, it complains std::unique_ptr
is not defined.
gcc (Ubuntu 5.1.0-0ubuntu11~14.04.1) 5.1.0
g++ (Ubuntu 5.1.0-0ubuntu11~14.04.1) 5.1.0
CXX flags:
-std=c++11 -Wall -Wextra -Weffc++ -pedantic
Output:
error: ‘unique_ptr’ in namespace ‘std’ does not name a template type
std::unique_ptr< detail::RegexImpl > m_pimpl;
However, I'm able to compile the exact same code on OSX.
Apple LLVM version 6.1.0 (clang-602.0.49) (based on LLVM 3.6.0svn)
CXX flags:
-stdlib=libc++ -std=c++11 -Wall -Wextra -Weffc++ -pedantic
What am I doing wrong?
You're not doing anything wrong. The library's source is missing an #include <memory>
.
This is simply an unfortunate error by the author of the library. It's surprisingly commonplace for people to rely on certain standard headers just so happening to include other standard headers on their particular implementation, without checking that they're using all the #include
statements that they should.
You could hack the #include
in for now but, long term, you should raise a bug with the library author and maybe even contribute a patch, if the project accepts patches.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With