LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 850|回复: 9

一个编译时遇到的问题

[复制链接]
发表于 2007-3-27 22:17:26 | 显示全部楼层 |阅读模式
make时,执行下面这条命令时
if c89 -DHAVE_CONFIG_H -I. -I. -I..  -DSYSTEM_DATA_DIR=\""/usr/share"\"   -O2 -Wall -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/freetype2 -I/usr/include/libpng12   -MT common.o -MD -MP -MF ".deps/common.Tpo" -c -o common.o common.c; \
        then mv -f ".deps/common.Tpo" ".deps/common.Po"; else rm -f ".deps/common.Tpo"; exit 1; fi

出现错误:
common.c:30: error: expected declaration specifiers or '...' before '_llseek'
common.c:30: error: expected declaration specifiers or '...' before 'fd'
common.c:30: error: expected declaration specifiers or '...' before 'ulong'
common.c:30: error: expected declaration specifiers or '...' before 'hi'
common.c:30: error: expected declaration specifiers or '...' before 'ulong'
common.c:30: error: expected declaration specifiers or '...' before 'lo'
common.c:30: error: expected declaration specifiers or '...' before 'res'
common.c:30: error: expected declaration specifiers or '...' before 'wh'

而common.c第30行的内容是:
extern _syscall5(int, _llseek, uint, fd, ulong, hi, ulong, lo, loff_t *, res, uint, wh)
/* warning: ISO C does not allow extra `;' outside of a function */

请问如何解决这个问题呢?
INSALL中有这样一行:
   You can give `configure' initial values for configuration parameters
by setting variables in the command line or in the environment.  Here
is an example:
     ./configure CC=c89 CFLAGS=-O2 LIBS=-lposix

但我这样执行configure有错误:
checking for C compiler default output file name... configure: error: C compiler cannot create executables
See `config.log' for more details.
发表于 2007-3-27 22:44:46 | 显示全部楼层
编译时报错虽然在 common.c 的 30 行, 但是错误可能是前面的代码引起的.

configure 的错误首先确认下系统中有 c89 并且在你的 PATH 路径中. 另外, config.log 也是很有必要看一下的.
回复 支持 反对

使用道具 举报

发表于 2007-3-28 07:26:33 | 显示全部楼层
Post by chenxingchen
make时,执行下面这条命令时
if c89 -DHAVE_CONFIG_H -I. -I. -I..  -DSYSTEM_DATA_DIR=\""/usr/share"\"   -O2 -Wall -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/freetype2 -I/usr/include/libpng12   -MT common.o -MD -MP -MF ".deps/common.Tpo" -c -o common.o common.c; \
        then mv -f ".deps/common.Tpo" ".deps/common.Po"; else rm -f ".deps/common.Tpo"; exit 1; fi

出现错误:
common.c:30: error: expected declaration specifiers or '...' before '_llseek'
common.c:30: error: expected declaration specifiers or '...' before 'fd'
common.c:30: error: expected declaration specifiers or '...' before 'ulong'
common.c:30: error: expected declaration specifiers or '...' before 'hi'
common.c:30: error: expected declaration specifiers or '...' before 'ulong'
common.c:30: error: expected declaration specifiers or '...' before 'lo'
common.c:30: error: expected declaration specifiers or '...' before 'res'
common.c:30: error: expected declaration specifiers or '...' before 'wh'

而common.c第30行的内容是:
extern _syscall5(int, _llseek, uint, fd, ulong, hi, ulong, lo, loff_t *, res, uint, wh)
/* warning: ISO C does not allow extra `;' outside of a function */

请问如何解决这个问题呢?
INSALL中有这样一行:
   You can give `configure' initial values for configuration parameters
by setting variables in the command line or in the environment.  Here
is an example:
     ./configure CC=c89 CFLAGS=-O2 LIBS=-lposix

但我这样执行configure有错误:
checking for C compiler default output file name... configure: error: C compiler cannot create executables
See `config.log' for more details.
What package are you building?

Which distro are you using?  What is you compiler version?
回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-3-28 16:19:59 | 显示全部楼层
编译的是一个叫LiPe的可以直接编辑硬盘(分区表)数据的软件。
我用的是Debian Testing,c89是有的,也可以正常运行。
错误好像是声明处产生的。
回复 支持 反对

使用道具 举报

发表于 2007-3-28 20:23:06 | 显示全部楼层
会否缺少某些 headers?即 xxx-dev 的包?

LiPe 有什麽依赖?用 dpkg 检查一下依赖的包是否满足
回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-3-28 20:40:46 | 显示全部楼层
源里没有这个东西,它在sourceforge的网址是
http://sourceforge.net/projects/ptedit/

我拿gcc 3.4编译的结果是:
common.c:30: error: syntax error before "_llseek"
common.c:34: warning: return type defaults to `int'
common.c: In function `_syscall5':
common.c:35: error: syntax error before '{' token
common.c:37: error: parameter `bytes' is initialized
common.c:37: error: `starting_sector' undeclared (first use in this function)
common.c:37: error: (Each undeclared identifier is reported only once
common.c:37: error: for each function it appears in.)
common.c:37: confused by earlier errors, bailing out

拿gcc-4.1编译的结果是:
common.c:30: error: expected declaration specifiers or '...' before '_llseek'
common.c:30: error: expected declaration specifiers or '...' before 'fd'
common.c:30: error: expected declaration specifiers or '...' before 'hi'
common.c:30: error: expected declaration specifiers or '...' before 'lo'
common.c:30: error: expected declaration specifiers or '...' before 'res'
common.c:30: error: expected declaration specifiers or '...' before 'wh'
common.c:34: warning: return type defaults to 'int'
common.c: In function '_syscall5':
common.c:35: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
common.c:54: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
common.c:73: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
common.c:105: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
common.c:128: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
common.c:134: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
common.c:152: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
common.c:171: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
common.c:192: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
common.c:210: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
common.c:228: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
common.c:30: error: parameter name omitted
common.c:30: error: parameter name omitted
common.c:30: error: parameter name omitted
common.c:30: error: parameter name omitted
common.c:30: error: parameter name omitted
common.c:30: error: parameter name omitted
common.c:256: error: expected '{' at end of input



问题是这个声明行好像可能有问题,下面的倒数第二行是30行,就是出错的行
#include <stdio.h>
#include <string.h>

#include "common.h"

extern uint sector_size;

extern _syscall5(int, _llseek, uint, fd, ulong, hi, ulong, lo, loff_t *, res, uint, wh)
/* warning: ISO C does not allow extra `;' outside of a function */
回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-3-28 21:04:02 | 显示全部楼层
好像是_syscall5的问题,不知现在写涉及_syscall5的程序应如何编写,编译命令如何编写?
回复 支持 反对

使用道具 举报

发表于 2007-3-28 21:04:19 | 显示全部楼层
第一帖你说 configure 的时候有 "C compiler cannot create executables" 错误信息,configure 通不过是不会生成 Makefile 的,那麽上面 make 的结果是怎样出来的?

另,新版 gcc 对语法比较严格,看似这个玩意均未能满足 gcc-3.4 及 gcc-4.1 的要求,软件本身推荐用什麽版本来编译?
回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-3-28 21:20:18 | 显示全部楼层
是这样的,我直接执行
./configure
是可以的,也可以生成Makefile

但执行
./configure CC=c89 CFLAGS=-O2 LIBS=-lposix
时不行。

不知道用_syscall如何在现在的gcc上使用,它是要用这个做系统调用的。
软件好像没有说推荐的版本。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-3-29 16:42:02 | 显示全部楼层
有人知道应该如何解决吗?
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表