6
我嘗試執行代碼四精度使用quadmath
#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.
我該如何解決這個問題?
感謝。 [code]'g ++ test.cpp -o test -lquadmath ./test 1.000000' – dStack
我正在使用GCC 5.3.0並且此解決方法不起作用。 – ajeh
這對我有用,並且將選項-lquadmath添加到gcc命令讓我的C程序也可以工作。 – atmelino