当前位置: 技术问答>linux和unix
【紧急求助】IBM AIX 4.3.3上用gcc 静态链接程序出错,不知为何?
来源: 互联网 发布时间:2015-08-14
本文导语: GCC版本如下: Reading specs from /usr/local/lib/gcc-lib/powerpc-ibm-aix4.3.3.0/3.3/specs Configured with: ../gcc-3.3/configure Thread model: aix gcc version 3.3 静态链接的命令如下,调用的是AIX自带的ld链接器。 logdaemon: GlobalConf.o lo...
GCC版本如下:
Reading specs from /usr/local/lib/gcc-lib/powerpc-ibm-aix4.3.3.0/3.3/specs
Configured with: ../gcc-3.3/configure
Thread model: aix
gcc version 3.3
静态链接的命令如下,调用的是AIX自带的ld链接器。
logdaemon: GlobalConf.o logreader.o errorlog.o main.o toi.o Filter.o api.o libtoistub.a libexpat.a
gcc $(LINKDEFS) -o logdaemon GlobalConf.o logreader.o errorlog.o main.o toi.o api.o Filter.o -Wl,-bloadmap:loadmap -Wl,-bnoquiet -L. -Wl,-bstatic -lbsd -lm -ltoistub -lexpat -ldl -lnsl -lpthread -lstdc++ -lc
结果ld报一堆符号未定义。其输出的loadmap文件显示一堆普通的符号未定义,如errno等。不知是何原因。请帮忙看看。
(ld): halt 4
(ld): setopt r/o->w
(ld): setopt nodelcsect
(ld): savename logdaemon
(ld): filelist 20 2
(ld): i /lib/crt0.o
(ld): i /tmp//ccQp1IH2.o
(ld): i GlobalConf.o
(ld): i logreader.o
(ld): i errorlog.o
(ld): i main.o
(ld): i toi.o
(ld): i api.o
(ld): i Filter.o
(ld): setopt noautoimp
(ld): lib /usr/lib/libbsd.a
(ld): lib /usr/lib/libm.a
(ld): lib ./libtoistub.a
(ld): lib ./libexpat.a
(ld): lib /usr/lib/libdl.a
(ld): lib /usr/lib/libnsl.a
(ld): lib /usr/lib/libpthread.a
(ld): lib /usr/local/lib/gcc-lib/powerpc-ibm-aix4.3.3.0/3.3/../../../libstdc++.a
(ld): lib /usr/lib/libc.a
(ld): i /usr/local/lib/gcc-lib/powerpc-ibm-aix4.3.3.0/3.3/libgcc.a
(ld): i /usr/local/lib/gcc-lib/powerpc-ibm-aix4.3.3.0/3.3/libgcc_eh.a
FILELIST: Number of previously inserted files processed: 20
(ld): exports /tmp//cc4qYyd1.x
EXPORTS: Symbols exported: 7
(ld): initfini _GLOBAL__FI_logdaemon _GLOBAL__FD_logdaemon
(ld): resolve
RESOLVE: 7776 of 36729 symbols were kept.
(ld): addgl /usr/lib/glink.o
ADDGL: Glink code added for 4 symbols.
(ld): er full
ld: 0711-318 ERROR: Undefined symbols were found.
The following symbols are in error:
Symbol Inpndx TY CL Source-File(Object-File) OR Import-File{Shared-object}
RLD: Address Section Rld-type Referencing Symbol
----------------------------------------------------------------------------------------------
_system_configuration [2] ER UA strncat.s(/usr/lib/libc.a[strncat.o])
00000224 .data R_POS [10]
_system_configuration [18] ER UA (/usr/lib/libbsd.a[shr.o])
00001054 .data R_POS [220]
_system_configuration [94] ER UA (/usr/lib/libnsl.a[shr.o])
0000fa1c .data R_POS [510]
_system_configuration [26] ER UA (/usr/lib/libpthread.a[shr_xpg5.o])
00002e84 .data R_POS [494]
_system_configuration [500] ER UA (/usr/lib/libc.a[shr.o])
000436b4 .data R_POS [622]
errno [28] ER RW ToiStub.c(./libtoistub.a[ToiStub.o])
000022a0 .data R_POS [260]
errno [0] ER UA (/usr/lib/libbsd.a[shr.o])
00000f88 .data R_POS [118]
errno [30] ER RW (/usr/local/lib/gcc-lib/powerpc-ibm-aix4.3.3.0/3.3/../../../libstdc++.a[libstdc++.so.5])
200221ac .data R_POS [434]
errno [0] ER UA (/usr/lib/libpthread.a[shr_xpg5.o])
00003168 .data R_POS [864]
errno [8] ER UA (/usr/lib/libc.a[shr.o])
000436c0 .data R_POS [628]
errno [54] ER RW main.cpp(main.o)
00002d40 .data R_POS [374]
errno [18] ER RW errorlog.cpp(errorlog.o)
000006c0 .data R_POS [86]
errno [70] ER RW GlobalConf.cpp(GlobalConf.o)
00004e1c .data R_POS [466]
errno [4] ER RW (/lib/crt0.o)
000000b0 .data R_POS [20]
disclaim [58] ER DS (/usr/lib/libc.a[shr.o])
00043748 .data R_POS [696]
sbrk [294] ER DS (/usr/lib/libc.a[shr.o])
0004374c .data R_POS [698]
close [54] ER DS (/usr/lib/libnsl.a[shr.o])
0000fab4 .data R_POS [586]
fstatx [98] ER DS (/usr/lib/libc.a[shr.o])
000437bc .data R_POS [754]
statx [362] ER DS (/usr/lib/libc.a[shr.o])
000437c0 .data R_POS [756]
.__quous [114] ER XO ../../../../../../../src/oncplus/usr/lib/libnsl/rpc/clnt_dg.c(/usr/lib/libnsl.a[shr.o])
00013620 .text R_RBA [1967]
Reading specs from /usr/local/lib/gcc-lib/powerpc-ibm-aix4.3.3.0/3.3/specs
Configured with: ../gcc-3.3/configure
Thread model: aix
gcc version 3.3
静态链接的命令如下,调用的是AIX自带的ld链接器。
logdaemon: GlobalConf.o logreader.o errorlog.o main.o toi.o Filter.o api.o libtoistub.a libexpat.a
gcc $(LINKDEFS) -o logdaemon GlobalConf.o logreader.o errorlog.o main.o toi.o api.o Filter.o -Wl,-bloadmap:loadmap -Wl,-bnoquiet -L. -Wl,-bstatic -lbsd -lm -ltoistub -lexpat -ldl -lnsl -lpthread -lstdc++ -lc
结果ld报一堆符号未定义。其输出的loadmap文件显示一堆普通的符号未定义,如errno等。不知是何原因。请帮忙看看。
(ld): halt 4
(ld): setopt r/o->w
(ld): setopt nodelcsect
(ld): savename logdaemon
(ld): filelist 20 2
(ld): i /lib/crt0.o
(ld): i /tmp//ccQp1IH2.o
(ld): i GlobalConf.o
(ld): i logreader.o
(ld): i errorlog.o
(ld): i main.o
(ld): i toi.o
(ld): i api.o
(ld): i Filter.o
(ld): setopt noautoimp
(ld): lib /usr/lib/libbsd.a
(ld): lib /usr/lib/libm.a
(ld): lib ./libtoistub.a
(ld): lib ./libexpat.a
(ld): lib /usr/lib/libdl.a
(ld): lib /usr/lib/libnsl.a
(ld): lib /usr/lib/libpthread.a
(ld): lib /usr/local/lib/gcc-lib/powerpc-ibm-aix4.3.3.0/3.3/../../../libstdc++.a
(ld): lib /usr/lib/libc.a
(ld): i /usr/local/lib/gcc-lib/powerpc-ibm-aix4.3.3.0/3.3/libgcc.a
(ld): i /usr/local/lib/gcc-lib/powerpc-ibm-aix4.3.3.0/3.3/libgcc_eh.a
FILELIST: Number of previously inserted files processed: 20
(ld): exports /tmp//cc4qYyd1.x
EXPORTS: Symbols exported: 7
(ld): initfini _GLOBAL__FI_logdaemon _GLOBAL__FD_logdaemon
(ld): resolve
RESOLVE: 7776 of 36729 symbols were kept.
(ld): addgl /usr/lib/glink.o
ADDGL: Glink code added for 4 symbols.
(ld): er full
ld: 0711-318 ERROR: Undefined symbols were found.
The following symbols are in error:
Symbol Inpndx TY CL Source-File(Object-File) OR Import-File{Shared-object}
RLD: Address Section Rld-type Referencing Symbol
----------------------------------------------------------------------------------------------
_system_configuration [2] ER UA strncat.s(/usr/lib/libc.a[strncat.o])
00000224 .data R_POS [10]
_system_configuration [18] ER UA (/usr/lib/libbsd.a[shr.o])
00001054 .data R_POS [220]
_system_configuration [94] ER UA (/usr/lib/libnsl.a[shr.o])
0000fa1c .data R_POS [510]
_system_configuration [26] ER UA (/usr/lib/libpthread.a[shr_xpg5.o])
00002e84 .data R_POS [494]
_system_configuration [500] ER UA (/usr/lib/libc.a[shr.o])
000436b4 .data R_POS [622]
errno [28] ER RW ToiStub.c(./libtoistub.a[ToiStub.o])
000022a0 .data R_POS [260]
errno [0] ER UA (/usr/lib/libbsd.a[shr.o])
00000f88 .data R_POS [118]
errno [30] ER RW (/usr/local/lib/gcc-lib/powerpc-ibm-aix4.3.3.0/3.3/../../../libstdc++.a[libstdc++.so.5])
200221ac .data R_POS [434]
errno [0] ER UA (/usr/lib/libpthread.a[shr_xpg5.o])
00003168 .data R_POS [864]
errno [8] ER UA (/usr/lib/libc.a[shr.o])
000436c0 .data R_POS [628]
errno [54] ER RW main.cpp(main.o)
00002d40 .data R_POS [374]
errno [18] ER RW errorlog.cpp(errorlog.o)
000006c0 .data R_POS [86]
errno [70] ER RW GlobalConf.cpp(GlobalConf.o)
00004e1c .data R_POS [466]
errno [4] ER RW (/lib/crt0.o)
000000b0 .data R_POS [20]
disclaim [58] ER DS (/usr/lib/libc.a[shr.o])
00043748 .data R_POS [696]
sbrk [294] ER DS (/usr/lib/libc.a[shr.o])
0004374c .data R_POS [698]
close [54] ER DS (/usr/lib/libnsl.a[shr.o])
0000fab4 .data R_POS [586]
fstatx [98] ER DS (/usr/lib/libc.a[shr.o])
000437bc .data R_POS [754]
statx [362] ER DS (/usr/lib/libc.a[shr.o])
000437c0 .data R_POS [756]
.__quous [114] ER XO ../../../../../../../src/oncplus/usr/lib/libnsl/rpc/clnt_dg.c(/usr/lib/libnsl.a[shr.o])
00013620 .text R_RBA [1967]
|
gcc $(LINKDEFS) -o logdaemon GlobalConf.o logreader.o errorlog.o main.o toi.o api.o Filter.o -Wl,-bloadmap:loadmap -Wl,-bnoquiet -L. -Wl,-bstatic -lbsd -lm -ltoistub -lexpat -ldl -lnsl -lpthread -lstdc++ -lc
你看看是不是因为, .O 文件联接的顺序有问题。
顺序注意事项: 包含被定义函数的.O ,应该放到,调用函数的.O的后面, 越是通用,放在越后面。
例如: errorno 如果在errorlog.o 中定义了, main.o 中又用到了话,应该把errlorlog.o 放在
main.o 后面。
这个问题,我是遇到过的,但是IBM AIX 4.3.3 系统没有用过,不过这个连接规则应该还是适用的。
你看看是不是因为, .O 文件联接的顺序有问题。
顺序注意事项: 包含被定义函数的.O ,应该放到,调用函数的.O的后面, 越是通用,放在越后面。
例如: errorno 如果在errorlog.o 中定义了, main.o 中又用到了话,应该把errlorlog.o 放在
main.o 后面。
这个问题,我是遇到过的,但是IBM AIX 4.3.3 系统没有用过,不过这个连接规则应该还是适用的。