Robert Shuler
Robert Shuler

Reputation: 1

make error using GNU/GCC quad precision library

When using Cygwin and GCC under Win 7 and the quad precision library:

gcc -c lquad.c

... this runs OK, but

gcc lquad.o

... produces the following error:

/tmp/ccLM2lOn.o:lquad.c:(.text+0xdb3): undefined reference to `sqrtq'

collect2: error: ld returned 1 exit status

I have #include quadmath.h in a C source, and the __float128 type works, but not the functions (e.g. sqrtq above). This header file has all the relevant externs, e.g.:

extern __float128 sqrtq (__float128) __quadmath_throw;

I found a dll cygquadmath-0.dll which definitely has these functions in it. It is in 3 places in the Cygwin installation. Additionally, I copied it to Windows\System, but that did not help.

There is a related question here, but nothing helped me there and it is not exactly the same error: Quadruple Precision in C++ (GCC)

Upvotes: 0

Views: 551

Answers (1)

learning_frog
learning_frog

Reputation: 325

You are looking for a compiler solution when what you need is a linker solution: Your code is compiling as it should, so no change in the code would solve your problem:

/tmp/ccLM2lOn.o:lquad.c:(.text+0xdb3): undefined reference to `sqrtq'

collect2: error: ld returned 1 exit status

The undefined reference to errors indicate a function needed by your object is in another library. As suggested by @Marc Glisse, try adding -lquadmath to your linker line.

Upvotes: 1

Related Questions