我试图用arm-linux-gnueabi-g ++交叉编译c ++文件:
make CROSS_COMPILE=arm-linux-gnueabi- all
但是会发生错误:
arm-linux-gnueabi-g++ -O2 -c -oa32.o PMCTestA.cpp
In file included from PMCTest.h:54:0,
from PMCTestA.cpp:24:
PMCTestLinux.h: In member function ‘void CCounters::GetProcessorVendor()’:
PMCTestLinux.h:63:73: error: impossible constraint in ‘asm’
make: *** [a32.o] Error 1
以下是第61行PMCTestLinux.h中代码的一部分:
static void Cpuid (int Output[4], int aa) {
int a, b, c, d;
__asm("cpuid" : "=a"(a),"=b"(b),"=c"(c),"=d"(d) : "a"(aa),"c"(0) : );
Output[0] = a;
Output[1] = b;
Output[2] = c;
Output[3] = d;
}
static inline void Serialize () {
// serialize CPU
__asm__ __volatile__ ( "xorl %%eax, %%eax \n cpuid " : : : "%eax","%ebx","%ecx","%edx" );
}
static inline int Readtsc() {
// read time stamp counter
int r;
__asm__ __volatile__ ( "rdtsc" : "=a"(r) : : "%edx");
return r;
}
static inline int Readpmc(int nPerfCtr) {
// read performance monitor counter number nPerfCtr
int r;
__asm__ __volatile__ ( "rdpmc" : "=a"(r) : "c"(nPerfCtr) : "%edx");
return r;
}
有没有人知道这个错误?我不确定问题是否与编译器有关。我的系统是Ubuntu 10.04,arm-linux-gnueabi-g ++的版本是4.7.3