This question already has an answer here:
I'm trying to print a quadruple precision vector using GCC 4.7.1 in CodeBlocks. This is the code:
#include <iostream>
#include <vector>
#include <quadmath.h>
...
int width = 46;
char buf[128];
for (std::vector<__float128>::const_iterator i = sol_r.begin(); i != sol_r.end(); ++i)
{
int n = quadmath_snprintf (buf, sizeof buf, "%+-#*.20Qe", width, *i);
if ((size_t) n < sizeof buf)
{
std::cout << buf << ' ';
}
}
I get this error: undefined reference to 'quadmath_snprintf(char*, unsigned int, char const*, ...)'
. What am I doing wrong?
Concerning the duplicate claim, the answer indicated as duplicate contains indeed part of the solution, but it is a general question including several different problems.
Users having problems in printing a quadruple precision vectors are most probably inexperienced (as I am) and would benefit more from a more concise answer and/or more precise sources.
The question asked here can be solved by checking out:
https://gcc.gnu.org/ml/gcc-help/2011-06/msg00148.html (add header as extern)
What is an undefined reference/unresolved external symbol error and how do I fix it? (link the relevant library as libquadmath
)
Aucun commentaire:
Enregistrer un commentaire