Chinaunix首页 | 论坛 | 博客
  • 博客访问: 7175779
  • 博文数量: 510
  • 博客积分: 12019
  • 博客等级: 上将
  • 技术积分: 6836
  • 用 户 组: 普通用户
  • 注册时间: 2005-08-01 16:46
文章分类

全部博文(510)

文章存档

2022年(2)

2021年(6)

2020年(59)

2019年(4)

2018年(10)

2017年(5)

2016年(2)

2015年(4)

2014年(4)

2013年(16)

2012年(47)

2011年(65)

2010年(46)

2009年(34)

2008年(52)

2007年(52)

2006年(80)

2005年(22)

分类: C/C++

2010-07-11 14:13:21

在64位机器上 编译内联汇编时候遇到错误
Error: suffix or operands invalid for `push
Error: suffix or operands invalid for `pop'
主要是pushl popl等造成。
以下是在网上找的一个列子

#include
int main
(void)
{
        
char *str="Hello, Gcc Inline Assembly World!";

        
__asm__ __volatile__ (      
                        
"pushl %0;"  
                        
"call puts;"
                        
:          
                        
:"m"(str)    
                                     
                        
);
        return 
0;
}

需要熟悉64指令集方能正确处理。但是若要在64位上正确编译32位,则 需要增加 -m32参数
gcc -m32 test.c

然而会报错
/usr/include/gnu/stubs.h:7:27: error: gnu/stubs-32.h: 没有那个文件或目录
这个错误主要是没有安装multilib包

在ubuntu 下安装如下
sudo apt-get install   g++-4.4-multilib


以上问题是指64位下编译32位,如果直接编译64呢? 还希望各位高手赐教!
阅读(4601) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~

chinaunix网友2011-05-26 09:26:09

64 编译32位应用 Software发布于 2008-1-26 | 834次阅读 字号: 大 中 小 (网友评论 0 条) 我要评论 告知gcc编译器编译的平台是 i386,CFLAGS 必须添加 -m32 参数. 2) 用 linux32 命令在configure改一下CHOST,设置一下编译环境 linux32 命令使用前后区别 staff-1:~/src/lame-3.96.1# ./configure checking build system type… x86_64-unknown-linux-gnu checking host system type… x86_64-unknown-linux-gnu staff-1:~/src/lame-3.96.1# linux32 ./configure checking build system type… i686-pc-linux-gnu checking host system type… i686-pc-linux-gnu 3) 如果编译的程序是32位的,所需要的动