Question

I am using Qt and want to include the ttmath library. It tested fine on Windows XP and Windows 7. I use Qt-creator on Ubuntu now and when I try to compile the project it gives me following error:

.../ttmathuint_x86.h:637: error: inconsistent operand constraints in an 'asm'
 : "cc", "memory" );
                   ^

Part of the code looks like this:

#ifdef __GNUC__
uint dummy, dummy2;

__asm__  __volatile__(

        "xorl %%edx, %%edx    \n"
        "negl %%eax           \n"  // CF=1 if rax!=0 , CF=0 if rax==0

    "1:                                 \n"
        "movl (%%esi,%%edx,4), %%eax    \n"
        "sbbl %%eax, (%%ebx,%%edx,4)    \n"

        "incl %%edx                     \n"
        "decl %%ecx                     \n"
        "jnz 1b                         \n"

        "adc %%ecx, %%ecx               \n"

    : "=c" (c), "=a" (dummy), "=d" (dummy2)
    : "0" (b),  "1" (c), "b" (p1), "S" (p2)
    : "cc", "memory" );

#endif

The error only shows when I add parser to my project like one from the last example, here: http://www.ttmath.org/samples

I have no idea why that doesn't work since I know little about assembly or compilation process.

I read on the internet that the resolution is to add QMAKE_CXXFALGS = -fno-gcse in my ".pro" file but it didn't work.

No correct solution

OTHER TIPS

The reason for this error is the -fPIC or -fpic compiler flag which indicates that position independent code should be emitted. To locate variables it uses a global offset table whose pointer is stored in ebx. Therefore with this flag you are not allowed to use ebx in inline assembly.

According to https://software.intel.com/en-us/blogs/2014/12/26/new-optimizations-for-x86-in-upcoming-gcc-50-32bit-pic-mode this is changed in GCC 5.0. The library probably changes your flags so you have to see if you can change your code.

In my case I could solve it updating my gcc to version 5.0

This is the source link https://askubuntu.com/questions/618474/how-to-install-the-latest-gcurrently-5-1-in-ubuntucurrently-14-04 and these are the commands they suggest (and the ones I used):

sudo add-apt-repository ppa:ubuntu-toolchain-r/test sudo apt-get update sudo apt-get install gcc-5 g++-5

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 60 --slave /usr/bin/g++ g++ /usr/bin/g++-5

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top