使用quadmath的G 4.6.3 Linux中的四倍精度
发布时间:2020-12-14 01:55:46 所属栏目:Linux 来源:网络整理
导读:我尝试执行代码 #include quadmath.h#include iostreamint 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':t
我尝试执行代码
#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 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |