Failed to create useful yaml-cpp library (shared or static) with gcc 3.2.3 on Windows

Unfortunately, I am forced to use gcc 3.2.3 (MinGW) due to a database of third-party codes having problems with later versions of gcc.

With gcc 3.2.3, I can build a static library (yaml-cpp.a) just fine (by editing the CMakeLists.txt file to remove "set (LIB_TYPE SHARED)", but I can't link my application against the library. This always leads to following error:

C: / MinGW_2 / bin /../ Library / GCC Pb / mingw32 / 3.2.3 /../../../ libstdC ++, and (C ++ locale.o) (i.e. ext + 0x38c ): undefined reference to `strtold '

I get the same error when trying to create a yaml-cpp shared library.

After searching the Internet a bit, most of them seem to solve this problem in their projects using 'strtod' instead of 'strtold', but I cannot find a link to 'strtold' in yaml-cpp code; so i'm a little lost?

Any ideas?

+3
source share
2 answers

I managed to get this to work by specifying my own strtold that uses strtod:

#if (__MINGW32__) && (__GNUC__) && (__GNUC__ < 4)
extern "C" {
  long double strtold(const char *__restrict__ nptr, char **__restrict__ endptr) {
      return strtod(nptr, endptr);
  }
}
#endif

Admittedly, he is pretty hacky, but he is doing his job. I wish I could also check out a small revision of gcc, but this is enough for my environment where gcc 3.2.3 is used.

+2
source

, < <20 > strold. , , strtod - .

yaml-cpp std::stringstream , long - . yaml-cpp/traits.h is_numeric, long, :

template <> struct is_numeric <long double> { enum { value = true }; };
0

Source: https://habr.com/ru/post/1782696/


All Articles