This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/41005] [C++0x] Unable to link fstream open and ctor with std::string argument.
- From: "jwakely dot gcc at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 10 Aug 2009 20:05:10 -0000
- Subject: [Bug libstdc++/41005] [C++0x] Unable to link fstream open and ctor with std::string argument.
- References: <bug-41005-8829@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #6 from jwakely dot gcc at gmail dot com 2009-08-10 20:05 -------
(In reply to comment #5)
> Instead of instantiating that code in every object a single explicit
> instantiation is provided in libstdc++.so, that's the purpose of
> src/fstream-inst.cc
... but in this case it fails to provide an explicit instantiation of the new
C++0x members because src/fstream-inst.cc is not compiled with -std=c++0x or
-std=gnu++0x
So the library tells the compiler not to instantiate the templates in your
code, promising to provide explicit instantiations, and then fails to provide
the explicit instantiations. So the workaround I gave in comment #3 provides
them in your program. Another workaround would be to compile with
-D_GLIBCXX_EXTERN_TEMPLATE=0, which disables the extern template feature,
causing the compiler to implicitly instantiate the templates in every file that
needs them, and then rely on the linker to merge the duplicate definitions.
But the right fix is just to ensure src/fstream-inst.cc is compiled in C++0x
mode, so that the instantiations are present in libstdc++.so and you don't need
any workaround.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41005