AIX5.3上gcc编译的问题

tdy218 2009-08-25 03:55:29
我在AIX装了gcc,然后放了个应用想用它编译,结果出来一些问题,俺对这东西不懂,还请路过的朋友帮忙看下.
gcc simpserv.c -o simpserv -I/home/tuxedo/tux81/tuxedo8.1/include
ld: 0711-317 ERROR: Undefined symbol: .main
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
collect2: ld returned 8 exit status

simpserv.c代码:

#include <stdio.h>
#include <ctype.h>
#include <atmi.h> /* TUXEDO Header File */
#include <userlog.h> /* TUXEDO Header File */

#if defined(__STDC__) || defined(__cplusplus)
tpsvrinit(int argc, char *argv[])
#else
tpsvrinit(argc, argv)
int argc;
char **argv;
#endif
{
argc = argc;
argv = argv;

userlog("Welcome to the simple server");
return(0);
}

#ifdef __cplusplus
extern "C"
#endif
void
#if defined(__STDC__) || defined(__cplusplus)
TOUPPER(TPSVCINFO *rqst)
#else
TOUPPER(rqst)
TPSVCINFO *rqst;
#endif
{
int i;
for(i = 0; i < rqst->len-1; i++)
rqst->data[i] = toupper(rqst->data[i]);
tpreturn(TPSUCCESS, 0, rqst->data, 0L, 0);
}

Tuxedo用到的头文件在下面的路径中:
/home/tuxedo/tux81/tuxedo8.1/include (已在编译时加进去了)

接着我又编译了一个c的源文件,结果出来更多的异常:
gcc simpcl.c -o simpcl -I/home/tuxedo/tux81/tuxedo8.1/include
simpcl.c: In function 'main':
simpcl.c:34: warning: incompatible implicit declaration of built-in function 'exit'
simpcl.c:40: warning: incompatible implicit declaration of built-in function 'exit'
simpcl.c:43: warning: incompatible implicit declaration of built-in function 'strlen'
simpcl.c:50: warning: incompatible implicit declaration of built-in function 'exit'
simpcl.c:57: warning: incompatible implicit declaration of built-in function 'exit'
simpcl.c:60: warning: incompatible implicit declaration of built-in function 'strcpy'
simpcl.c:71: warning: incompatible implicit declaration of built-in function 'exit'
ld: 0711-317 ERROR: Undefined symbol: .tpinit
ld: 0711-317 ERROR: Undefined symbol: .tpalloc
ld: 0711-317 ERROR: Undefined symbol: .tpterm
ld: 0711-317 ERROR: Undefined symbol: .tpfree
ld: 0711-317 ERROR: Undefined symbol: .tpcall
ld: 0711-317 ERROR: Undefined symbol: ._tmget_tperrno_addr
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
collect2: ld returned 8 exit status


...全文
1226 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
tdy218 2009-08-28
  • 打赏
  • 举报
回复
基本上搞定了.再次谢谢诸位!

exec gcc -maix64 $GCCCMD
最终编译虽然出来很多看似异常的东东,不过居然生成想要的东西了.
$buildserver -f simpserv.c -o simpserv -s TOUPPER -v
gccedit -q64 -D_LARGE_FILES -D__XCOFF32__ -D__XCOFF64__ -brtl -qstaticinline -I$TUXDIR/include -o simpserv BS-4b056.c -L${TUXDIR}/lib simpserv.c -brtl -qstaticinline -ltux -lbuft -lfml -lfml32 -lengine -lpthread
gcc: unrecognized option '-q64'
gcc: unrecognized option '-qstaticinline'
gcc: unrecognized option '-qstaticinline'
In file included from BS-4b056.c:3:
/home/tuxedo/tux81/tuxedo8.1/include/atmi.h:439: warning: 'struct tm' declared inside parameter list
/home/tuxedo/tux81/tuxedo8.1/include/atmi.h:439: warning: its scope is only this definition or declaration, which is probably not what you want
In file included from simpserv.c:3:
/home/tuxedo/tux81/tuxedo8.1/include/atmi.h:439: warning: 'struct tm' declared inside parameter list
/home/tuxedo/tux81/tuxedo8.1/include/atmi.h:439: warning: its scope is only this definition or declaration, which is probably not what you want
ld: 0711-224 WARNING: Duplicate symbol: .tpsvrinit
ld: 0711-224 WARNING: Duplicate symbol: .userlog
ld: 0711-224 WARNING: Duplicate symbol: userlog
ld: 0711-224 WARNING: Duplicate symbol: tpsvrinit
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.


$buildclient -f simpcl.c -o simpcl -v
gccedit -I$TUXDIR/include -o simpcl -qstaticinline -L${TUXDIR}/lib -q64 -D_LARGE_FILES -D__XCOFF32__ -D__XCOFF64__ simpcl.c -brtl $TUXDIR/lib/tpinit.o -ltux -lbuft -lfml -lfml32 -lengine -lpthread
gcc: unrecognized option '-qstaticinline'
gcc: unrecognized option '-q64'
In file included from simpcl.c:15:
/home/tuxedo/tux81/tuxedo8.1/include/atmi.h:439: warning: 'struct tm' declared inside parameter list
/home/tuxedo/tux81/tuxedo8.1/include/atmi.h:439: warning: its scope is only this definition or declaration, which is probably not what you want
simpcl.c: In function 'main':
simpcl.c:43: warning: incompatible implicit declaration of built-in function 'strlen'
simpcl.c:60: warning: incompatible implicit declaration of built-in function 'strcpy'


$ls -l
total 1344
-rw-rw-rw- 1 tuxedo staff 1597 Aug 28 01:46 ULOG.082809
-rwxr-xr-x 1 tuxedo staff 78 Aug 28 01:32 gccedit
-rwxr-xr-x 1 tuxedo staff 65163 Aug 28 01:53 simpcl
-rw-r--r-- 1 tuxedo staff 1826 Aug 31 2004 simpcl.c
-rwxr-xr-x 1 tuxedo staff 62676 Aug 28 01:45 simpserv
-rw-r--r-- 1 tuxedo staff 1017 Aug 24 15:50 simpserv.c
-rw-r--r-- 1 tuxedo staff 0 Aug 28 01:45 stderr
-rw-r--r-- 1 tuxedo staff 0 Aug 28 01:45 stdout
-rwxr-xr-x 1 tuxedo staff 53181 Aug 28 01:51 tdy218
-rw-r--r-- 1 tuxedo staff 72 Aug 26 17:31 tdy218.c
-rw-r--r-- 1 tuxedo staff 281 Aug 27 16:28 tux.env
-rw-r--r-- 1 tuxedo staff 475136 Aug 25 17:03 tuxconfig
-rw-r--r-- 1 tuxedo staff 676 Aug 24 16:01 ubbsimple


$tmboot -y
Booting all admin and server processes in /home/tuxedo/app/simpapp/tuxconfig
INFO: BEA Tuxedo, Version 8.1, 64-bit, Patch Level (none)
INFO: Serial #: 454493271161-2664947729544, Expiration NONE, Maxusers 1000000
INFO: Licensed to: Customer

Booting admin processes ...

exec BBL -A :
process id=205014 ... Started.

Booting server processes ...

exec simpserv -A :
process id=413748 ... Started.
2 processes started.


$simpcl tdy218
Returned string is: TDY218

tdy218 2009-08-27
  • 打赏
  • 举报
回复
很不错,我下午也找到了,不过还是谢谢大家! 尤其是楼上这位朋友.
我照OTN上那篇帖子做了,还有错误.
貌似是小机上gcc相关的rpm包没装全,我得再去下载.
tdy218 2009-08-27
  • 打赏
  • 举报
回复
谢谢楼上这位朋友的耐心讲解.Linux/Unix C编译环境比Java的还复杂!

那Linux/Unix下Tuxedo的编译环境该怎么去做那?
$buildserver -f simpserv.c -o simpserv -s TOUPPER -v
cc -q64 -D_LARGE_FILES -D__XCOFF32__ -D__XCOFF64__ -brtl -qstaticinline -I$TUXDIR/include -o simpserv BS-55008.c -L${TUXDIR}/lib simpserv.c -brtl -qstaticinline -ltux -lbuft -lfml -lfml32 -lengine -lpthread
sh: cc: not found
CMDTUX_CAT:1832: ERROR: can't execute cc -q64 -D_LARGE_FILES -D__XCOFF32__ -D__XCOFF64__ -brtl -qstaticinline -I$TUXDIR/include -o simpserv BS-55008.c -L${TUXDIR}/lib simpserv.c -brtl -qstaticinline -ltux -lbuft -lfml -lfml32 -lengine -lpthread

这里的sh: cc: not found指的可是xlc?假如安装上了,这个编译环境该如何搭建?

引用
当然如果你清楚buildserver/buildclient的细节,当然可以自己构造命令行用gcc链接。

这个又该如何构建?


mymtom 2009-08-27
  • 打赏
  • 举报
回复
mymtom 2009-08-27
  • 打赏
  • 举报
回复

$ printf '#include <stdio.h>\nint main(){char *p = "#include <stdio.h>%%cint main(){char *p = %%c%%s%%c; printf(p, 10, 34, p, 34, 10);}%%c\"; printf(p, 10, 34, p, 34, 10);}\n' > quine.c
$ make quine
mymtom 2009-08-27
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 tdy218 的回复:]
刚去找了些vim、csope相关的资料看了看,对我来说有点复杂.
我学Java的,Windows平台上的VC++6.0勉强会用,一遇到原理性的东西不行了.
xlc是 商业软件  估计用不了.
对于我这简单的使用,就编译一些简单的应用,还用gcc的话,还需要如何配置或安装 相关的文件使这个编译器能够完成简单的编译工作?

[/Quote]
tuxedo也是商业软件哎
你的simpserv.c用tuxedo,用gcc比较麻烦。
简单的编译工作?
自己写个quine.c就可以了。
[code=Batch]
$ printf '#include <stdio.h>\nint main(){char *p = "#include <stdio.h>%%cint main(){char *p = %%c%%s%%c; printf(p, 10, 34, p, 34, 10);}%%c\"; printf(p, 10, 34, p, 34, 10);}\n' > quine.c
$ make quine
[/code]

tdy218 2009-08-26
  • 打赏
  • 举报
回复
刚去找了些vim、csope相关的资料看了看,对我来说有点复杂.
我学Java的,Windows平台上的VC++6.0勉强会用,一遇到原理性的东西不行了.
xlc是 商业软件 估计用不了.
对于我这简单的使用,就编译一些简单的应用,还用gcc的话,还需要如何配置或安装 相关的文件使这个编译器能够完成简单的编译工作?
mymtom 2009-08-26
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 nevil 的回复:]
gcc simpserv.c -o simpserv -I/home/tuxedo/tux81/tuxedo8.1/include
ld: 0711-317 ERROR: Undefined symbol: .main
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
collect2: ld returned 8 exit status


后来我试试这样编译,虽然编译通过了,但执行的时候又报错了.
$gcc -c simpserv.c -o simpserv -I/home/tuxedo/tux81/tuxedo8.1/include

这是你没有定入main()函数作为程序入口,加-c表明gcc只是进预处理,编译,和汇编,成生.o对象文件,这种情况下编绎不会出错,但是你执行的话加载器无法定位程序入口,所以出错
[/Quote]
正是。
tuxedo程序最后要用buildserver/buildclient来链接的,所以呢,
^_^,老老实实用AIX自己的xlC吧,毕竟这些都是商业软件,与开源的gcc本来就不合。

当然如果你清楚buildserver/buildclient的细节,当然可以自己构造命令行用gcc链接。
如果要试试gcc是否已经成功安装,下载个开源软件比如vim, ctags, cscope之类的来试验。
nevil 2009-08-26
  • 打赏
  • 举报
回复
gcc simpserv.c -o simpserv -I/home/tuxedo/tux81/tuxedo8.1/include
ld: 0711-317 ERROR: Undefined symbol: .main
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
collect2: ld returned 8 exit status



后来我试试这样编译,虽然编译通过了,但执行的时候又报错了.
$gcc -c simpserv.c -o simpserv -I/home/tuxedo/tux81/tuxedo8.1/include

这是你没有定入main()函数作为程序入口,加-c表明gcc只是进预处理,编译,和汇编,成生.o对象文件,这种情况下编绎不会出错,但是你执行的话加载器无法定位程序入口,所以出错
nevil 2009-08-26
  • 打赏
  • 举报
回复
simpcl.c:34: warning: incompatible implicit declaration of built-in function 'exit'
simpcl.c:40: warning: incompatible implicit declaration of built-in function 'exit'
simpcl.c:43: warning: incompatible implicit declaration of built-in function 'strlen'
simpcl.c:50: warning: incompatible implicit declaration of built-in function 'exit'
simpcl.c:57: warning: incompatible implicit declaration of built-in function 'exit'
simpcl.c:60: warning: incompatible implicit declaration of built-in function 'strcpy'
simpcl.c:71: warning: incompatible implicit declaration of built-in function 'exit'

这些表示你没有引入特定的头文件,比如eixt()需要stdlib.h
ShowMan 2009-08-26
  • 打赏
  • 举报
回复
这个程序看起来怪怪的,不知道如何下手。
tdy218 2009-08-26
  • 打赏
  • 举报
回复
应该不是应用的问题,这两个应用是一个这个交易中间价自带的例子.
后来我试试这样编译,虽然编译通过了,但执行的时候又报错了.
$gcc -c simpserv.c -o simpserv -I/home/tuxedo/tux81/tuxedo8.1/include
//模仿Windows平台上的VC98编译.
执行的时候报错:
Could not load program simpserv:
The .loader section does not exist.
CMDTUX_CAT:819: INFO: Process id=319514 Assume started (pipe).


启动这个交易中间价的时候不需要编译客户端.接着我又编译了一下客户端,报出来很多问题:
gcc -c simpcl.c -o simpcl -I/home/tuxedo/tux81/tuxedo8.1/include
simpcl.c: In function 'main':
simpcl.c:34: warning: incompatible implicit declaration of built-in function 'exit'
simpcl.c:40: warning: incompatible implicit declaration of built-in function 'exit'
simpcl.c:43: warning: incompatible implicit declaration of built-in function 'strlen'
simpcl.c:50: warning: incompatible implicit declaration of built-in function 'exit'
simpcl.c:57: warning: incompatible implicit declaration of built-in function 'exit'
simpcl.c:60: warning: incompatible implicit declaration of built-in function 'strcpy'
simpcl.c:71: warning: incompatible implicit declaration of built-in function 'exit'

这个客户端也是那个中间价自带的例子,应该没问题.
现在我怀疑gcc编译的过程有点问题.
在使用GCC编译程序时,编译过程可以被细分为四个阶段:
◆ 预处理(Pre-Processing)
◆ 编译(Compiling)
◆ 汇编(Assembling)
◆ 链接(Linking)
按照这几部一步步的编译产生的异常也是一样的,请问这该怎么办?
tux.env文件内容:
export TUXDIR=/home/tuxedo/tux81/tuxedo8.1;
export APPDIR=/home/tuxedo/app/simpapp;
export PATH=$TUXDIR/bin:$APPDIR:$PATH;
export LIBPATH=$TUXDIR/lib:$LIBPATH;
export LD_LIBRARY_PATH=$TUXDIR/lib:$LD_LIBRARY_PATH;
export TUXCONFIG=$APPDIR/tuxconfig
export LANG=C;
export NLSPATH=$TUXDIR/local/C;


yhf365 2009-08-25
  • 打赏
  • 举报
回复
除了驱动程序之外,
一般的c程序都是需要有main函数的,
不然找不到程序入口。

我看不是gcc的问题,代码的问题
快乐田伯光 2009-08-25
  • 打赏
  • 举报
回复
没的main()函数,这个是可执行文件的入口

23,114

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 应用程序开发区
社区管理员
  • 应用程序开发区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧