Fourth precision in g ++ 4.6.3 Linux using quadmath

I'm trying to execute code

#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; } 

with teams

 g++ test.cpp -o test 

I get an error message:

 /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 

Version:

 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. 

How can I fix the problem?

+6
source share
1 answer

I see the same behavior:

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

One way is to include a header using this template:

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

then:

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

All Articles