当前位置: 技术问答>linux和unix
AIX5.3上gcc编译的问题
来源: 互联网 发布时间:2016-06-27
本文导语: 我在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 -bl...
我在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代码:
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
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
#include
#include /* TUXEDO Header File */
#include /* 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 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
|
tuxedo也是商业软件哎
你的simpserv.c用tuxedo,用gcc比较麻烦。
简单的编译工作?
自己写个quine.c就可以了。
[code=Batch]
$ printf '#include nint main(){char *p = "#include %%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]
|
正是。
tuxedo程序最后要用buildserver/buildclient来链接的,所以呢,
^_^,老老实实用AIX自己的xlC吧,毕竟这些都是商业软件,与开源的gcc本来就不合。
当然如果你清楚buildserver/buildclient的细节,当然可以自己构造命令行用gcc链接。
如果要试试gcc是否已经成功安装,下载个开源软件比如vim, ctags, cscope之类的来试验。
|
没的main()函数,这个是可执行文件的入口
|
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对象文件,这种情况下编绎不会出错,但是你执行的话加载器无法定位程序入口,所以出错
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对象文件,这种情况下编绎不会出错,但是你执行的话加载器无法定位程序入口,所以出错
|