红联Linux门户
Linux帮助

ubuntu 14.04搭建32位编译环境,及取消了ia32-libs包的替代方案

发布时间:2017-03-13 09:41:34来源:linux网站作者:☆Ronny丶
在14.04版本中取消了ia32-libs包的安装,可以安装下面的库替代:
apt-get install lib32z1 lib32ncurses5 lib32bz2-1.0 libc6-dev-i386
 
编译32位程序:
// print data time by using system call
#include <stdio.h>
#include <time.h>
int main() {
time_t tt;
struct tm *t;
asm volatile (
"mov $0,%%ebx\n\t" // set ebx to 0
"mov $0xd,%%eax\n\t" // call the 13th system call function
"int $0x80\n\t" 
"mov %%eax,%0\n\t" //save the eax to  tt
:"=m" (tt)
);
printf("tt = %x\n", (unsigned int)tt);
t = localtime(&tt);
printf("time:%d:%d:%d:%d:%d:%d\n",
t->tm_year + 1900,
t->tm_mon,
t->tm_mday,
t->tm_hour,
t->tm_min,
t->tm_sec);
return 0;
}
 
编译方法:
gcc -o print_data print_data.c -m32
 
本文永久更新地址:http://www.linuxdiyf.com/linux/29124.html