Specialised Projects > Compiler Based Assembler

GCC libquadmath

(1/5) > >>

jj2007:
Anybody able to compile that without errors?


--- Code: ---#include <conio.h>
#include <C:\MinGW\lib\gcc\mingw32\4.8.1\include\quadmath.h>
// OPT_Linker C:\MinGW\lib\gcc\mingw32\4.8.1\libquadmath.a

int main ()
{
  __float128 r;

  r = strtoflt128("1.2345678", NULL); // undefined reference to `strtoflt128'
  r = 123.456; // OK

  _getch();
}

--- End code ---

See How to output 128 bits to the screen?

GoneFishing:
Hi Johen,

I was able to compile this on Ubuntu 14.04 :


--- Code: ---#include <stdio.h>
#include <quadmath.h>
// gcc ./quadmath.c  -o quadmath -lquadmath

int main ()
{
  __float128 r;

  r = strtoflt128("1.2345678", NULL); // undefined reference to `strtoflt128'
  r = 123.456; // OK

  getchar();
}

--- End code ---

jj2007:
Thanks :icon14:
No luck on Windows, though.

TWell:

--- Code: ---#include <stdio.h>
#include <quadmath.h>
// gcc ./quadmath.c  -o quadmath -lquadmath
// gcc quadmath.c -o quadmath -Wl,-Bstatic -lquadmath

int main ()
{
  __float128 r;
  char buf[128];

  r = strtoflt128("1.2345678", NULL); // undefined reference to `strtoflt128'
  r = 123.456; // OK
//  quadmath_snprintf (buf, sizeof buf, "%Qa", r);
  quadmath_snprintf (buf, sizeof buf, "%Qf\n", r);
  printf(buf);
  getchar();
  return 0;
}

--- End code ---

--- Code: ---123.456000
--- End code ---

jj2007:
Thanks, Tim, and congrats :icon_mrgreen:

So are these your linker options?

gcc quadmath.c -o quadmath -Wl,-Bstatic -lquadmath

My results:

--- Code: ---C:\TDM-GCC-32\bin\gcc.exe -Wl,-Bstatic -lquadmath -o tmp.exe "Tmp.cpp"
--- End code ---

--- Code: ---C:\Users\Jochen\AppData\Local\Temp\cceeec7X.o:Tmp.cpp:(.text+0x29): undefined reference to `strtoflt128'
C:\Users\Jochen\AppData\Local\Temp\cceeec7X.o:Tmp.cpp:(.text+0xc9): undefined reference to `quadmath_snprintf'
C:/TDM-GCC-32/bin/../lib/gcc/mingw32/4.9.2/../../../../mingw32/bin/ld.exe: C:\Users\Jochen\AppData\Local\Temp\cceeec7X.o: bad reloc address 0x7 in section `.text$getchar[_getchar]'
C:/TDM-GCC-32/bin/../lib/gcc/mingw32/4.9.2/../../../../mingw32/bin/ld.exe: final link failed: Invalid operation
collect2.exe: error: ld returned 1 exit status
--- End code ---

If I remove the comma (-Wl -Bstatic), it tells me unrecognized command line option '-Wl', so I assume the comma has a meaning.

My installation is less than three years old. Most of the time C/C++ code compiles and runs fine, but this one gives me the creeps :(

C:\MinGW\mingw32\lib\gcc\mingw32\4.8.1\libquadmath.a 570236 bytes, 5.10.2013
C:\MinGW\mingw32\lib\gcc\mingw32\4.8.1\include\quadmath.h 9030 bytes, 5.10.2013

P.S.: I love passing hours and hours on the Internet watching how others despair :t

But in the end, own trial and error may advance humanity more quickly :biggrin:
--- Code: ---#include <stdio.h>
#include <quadmath.h>
// gcc ./quadmath.c  -o quadmath -lquadmath
// gcc quadmath.c -o quadmath
// OxPT_Linker -Wl,-Bstatic -lquadmath
// OxPT_Linker -Wl,-Bdynamic -lquadmath
// OxPT_Linker -Wl,-Bstatic "C:\MinGW\mingw32\lib\gcc\mingw32\4.8.1\libquadmath.a"
// OxPT_Linker -Wl,-Bdynamic C:\TDM-GCC-32\bin\libquadmath-0.dll
// OPT_Linker C:\TDM-GCC-32\bin\libquadmath-0.dll ; HEY, THIS ONE WORKS!!!!
int main ()
{
  __float128 r;
  char buf[128];
  for (int i=0;i<128;i++) buf[i]=0;
  // __asm("int $3");
  r = strtoflt128("1.2345678", NULL); // undefined reference to `strtoflt128'
  // __asm("nop");
  // r = 123.456; // OK
  quadmath_snprintf (buf, sizeof buf, "%Qa", r);
  quadmath_snprintf (buf, sizeof buf, "%Qf\n", r);
  printf("Buffer: [%s]", buf);
  getchar();
  return 0;
}

--- End code ---

Output: Buffer: [0x1.3c0ca2a5b1d5d0818d3359c99ff2p+0]

Not yet the expected result, but since I've seen some similar results in desperate posts on the web (e.g. That code produced -3.8518598887744717061119558851698546e-34 error on my box), it can only be a question of weeks until I find the magic trick :icon_mrgreen:

Navigation

[0] Message Index

[#] Next page

Go to full version