我尝试执行代码
#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
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。