nanodbc/nanodbc

GCC 4.9 - codecvt not found

lexicalunit opened this issue · 2 comments

From @kowalikm on August 27, 2015 13:55

Hello,

i have problem with compilation on Debian GCC 4.9:

fatal error: codecvt: Not found
#include <codecvt>
                   ^
compilation terminated.

AFAIK codecvt isn't supported by GCC yet.

Copied from original issue: lexicalunit/nanodbc#44

Support for codecvt is provided by the standard library rather than being strictly tied to a compiler implementation. By default, GCC will use libstdc++ as its standard library implementation. On OS X you can actually change that using the compiler flag -stdlib=libc++ as described on this stackoverflow page.

You indicated however that you're on Debian Linux so you don't have this luxury. You are also correct that, as of this writing, libstdc++ does not have full support for codecvt. Particularly, it is missing codecvt_utf8, which is the only thing nanodbc uses from that header. It may be possible to refactor the code to avoid use of this utility, for example using boost.

Note that the code path which makes use of codecvt is only entered in two cases:

  • When a wide string data column is fetched as a std::string.
  • With unicode support enabled for nanodbc, when a string data column is fetched as std::wstring.

If your code isn't doing either of these things, as a workaround you could replace the codecvt_utf8 calls with code to throw a runtime exception indicating that these operations are not currently supported on Linux.

I added an option to build nanodbc using Boost.Locale as the string convert implementation, rather than codecvt.