使用quadmath的G 4.6.3 Linux中的四倍精度

我尝试执行代码

#include 

用命令

g++ test.cpp -o test

我收到错误:

/tmp/cctqto7E.o: In function `main':
test.cpp:(.text+0x51): undefined reference to `quadmath_snprintf(char*,unsigned int,char const*,...)'
collect2: ld returned 1 exit status

版本是:

g++ --version
g++ (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3
Copyright (C) 2011 Free Software Foundation,Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

我该如何解决这个问题?

最佳答案
我看到了同样的行为:

~/coding/q$g++ test.cpp -lquadmath
/tmp/ccYdHwL5.o: In function `main':
test.cpp:(.text+0x51): undefined reference to `quadmath_snprintf(char*,...)'
collect2: ld returned 1 exit status

一种解决方法是使用此模式包含标头:

extern "C" {
#include "quadmath.h"
}

之后:

~/coding/q$g++ test.cpp -lquadmath
~/coding/q$./a.out 
1.000000

相关文章

文章浏览阅读1.8k次,点赞63次,收藏54次。Linux下的目录权限...
文章浏览阅读1.6k次,点赞44次,收藏38次。关于Qt的安装、Wi...
本文介绍了使用shell脚本编写一个 Hello
文章浏览阅读1.5k次,点赞37次,收藏43次。【Linux】初识Lin...
文章浏览阅读3k次,点赞34次,收藏156次。Linux超详细笔记,...
文章浏览阅读6.8k次,点赞109次,收藏114次。【Linux】 Open...