Linux   发布时间:2022-05-08  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了使用quadmath的G 4.6.3 Linux中的四倍精度大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我尝试执行代码

#include <quadmath.h>
#include <iostream>
int main()
{
  char* y = new char[1000];
  quadmath_snprintf(y,1000,"%Qf",1.0q);
  std::cout << y << std::endl;
  return 0;
}

用命令

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

大佬总结

以上是大佬教程为你收集整理的使用quadmath的G 4.6.3 Linux中的四倍精度全部内容,希望文章能够帮你解决使用quadmath的G 4.6.3 Linux中的四倍精度所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: