无法在 Windows 中使用 gcc 3.2.3 构建可用的 yaml-cpp 库(共享或静态)
不幸的是,由于 3rd 方代码库与更高版本的 gcc 存在问题,我被迫使用 gcc 3.2.3 (MinGW)。
使用 gcc 3.2.3,我可以很好地构建静态库(yaml-cpp.a)(通过编辑 CMakeLists.txt 文件以删除“set(LIB_TYPE SHARED)”,但我无法将我的应用程序链接到它总是导致以下错误:
C:/MinGW_2/bin/../lib/gcc-lib/mingw32/3.2.3/../../../libstdc++.a(c++locale. o)(.t ext+0x38c): 对 `strtold' 的未定义引用
在尝试构建共享 yaml-cpp 库时,我遇到了相同的错误。
在网上搜索了一下之后,大多数人似乎通过使用“strtod”而不是“strtold”在他们的项目中解决了这个问题,但我在 yaml-cpp 代码中找不到任何对“strtold”的引用;所以我有点不知所措?
有什么想法吗?
I unfortunately am forced to use gcc 3.2.3 (MinGW) due to the 3rd party code base having issues 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 the 'set(LIB_TYPE SHARED)', but I can't link my application against the library. It always results in the following error:
C:/MinGW_2/bin/../lib/gcc-lib/mingw32/3.2.3/../../../libstdc++.a(c++locale.o)(.t
ext+0x38c): undefined reference to `strtold'
I get the same error when trying to build a shared yaml-cpp library.
After searching the web for a bit, most seem to resolve this problem in their projects by using 'strtod' instead of 'strtold', but I can't find any reference to 'strtold' in the yaml-cpp code; so I'm at a bit of a loss?
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我可以通过定义我自己的 strtold(它使用 strtod)来实现此功能:
诚然,它相当 hacky,但它完成了工作。我希望我也可以检查 gcc 的小版本,但这对于我的环境来说已经足够了,其中 gcc 3.2.3 是唯一使用的版本。
I was able to get this to work by defining my own strtold which uses strtod:
Admittedly, it's quite hacky, but it gets the job done. I wish I could check gcc's minor revision too, but this is sufficient for my environment where gcc 3.2.3 is the only version being used.
看来在内部,
std::stringstream
正在调用strold
。不幸的是,这意味着您无法将其切换为strtod
- 您根本无法使用该特定转换。由于 yaml-cpp 使用 std::stringstream 进行转换,因此我建议删除与 long 相关的转换。在
yaml-cpp/traits.h
中,删除与long
相关的is_numeric
特化,例如:It appears that internally,
std::stringstream
is callingstrold
. Unfortunately, this means that you can't switch it tostrtod
- you simply can't use that particular conversion.Since yaml-cpp uses
std::stringstream
to do its conversion, I suggest removing thelong
-related conversions. Inyaml-cpp/traits.h
, remove theis_numeric
specializations that have to do withlong
, such as: