提问人:Ian 提问时间:2/17/2023 最后编辑:Simon SobischIan 更新时间:2/21/2023 访问量:77
在 RHEL 上链接 COBOL DB2 的静态文件时出错
Error Linking a Static File for COBOL DB2 on RHEL
问:
在遇到错误的 RHEL 8.6 服务器上编译/链接 DB2 的 COBOL 代码。
运行命令:
cob2 -F/etc/cob2.cfg -v myfile.cbl -L/opt/IBM/db2/V11.5/lib32 -I/opt/IBM/db2/V11.5/include/cobol_a -ldb2 -q"size(16384k)" -L. linkfile.a -o myfile.exe
db2level 信息标记为 “DB2 v11.5.0.0”、“s1906101300”、“DYN1906101300AMD64” 和修订包 “0”。产品安装在 “/opt/IBM/db2/V11.5”
cob2 -V Program cob2 Version 1.1.0 Built Mon Sep 27 10:39:30 2021
错误信息:
/usr/bin/ld: /usr/lib/gcc/x86_64-redhat-linux/8/../../../../lib/Scrtl.0(.text+0x1c): unresolvable R_386_GOTOFF relocation against symbol '__libc_csu_fini'
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: error ld returned 1 exit status.
尝试更改各种选项,但现在选项用完了。 我期待/希望有一个干净的编译和链接,以及可用的 .exe 文件。
No CFLAGS and/or LDFLAGS set.
gcc -v Using built-in specs. COLLECT GCC=gcc COLLECT LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/8/lto-wrapper OFFLOAD_TARGET_NAMES=nvptx-none OFFLOAD_TARGET_DEFAULT=1 Target: x86_64-redhat-linux Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,lto --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable- __cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-objext --enable-linkr-build-id --with-gcc-major-version-only --with-linker-hash-style=gnu --enable-plugin --enable-initfini-array --with-isl --disable-libmpx --enable-offload-targets=nvptx-none --without-cuda-driver --enable-gnu-indirect-function --enable-cet --with-tune-generic --with-arch_32=x86-64 --build=x86_64-redhat-linux Thread model: posix gcc version 8.5.0 20210514 (Red Hat 8.5.0-10) (GCC)
Incoming argument vector for cob2... [ 0] - 4: cpb2 [ 1] - 2: -# [ 2] - 15: -F/etc/cob2.cfg [ 3] - 2: -v [ 4] - 18: /tmp/out/myfile.cbl [ 5] - 10: linkfile.a [ 6] - 26: -L/opt/IBM/db2/V11.5/lib32 [ 7] - 36: -I/opt/IBM/db2/V11.5/include/cobol_a [ 8] - 5: -ldb2 [ 9] - 14: -qsize(16384K) [10] - 2: -o [11] - 20: /code/bin/myfile.exe
Outgoing environment variables... PATH: /opt/ibm/cobol/1.1.0/usr/bin/:/usr/bin:/etc:/usr/sbin:/usr/ucb:/home/user1///bin/usr/bin/X11:/sbin:/:/code/bin:/code/scripts/home/user1//sqllib/bin LIBPATH: /home/user1//sqllib/lib:/usr/lib:/lib LD_LIBRARY_PATH: /opt/ibm/cobol/rte/usr/lib/:/opt/ibm/cobol/rte/:/opt/ibm/cobol1.1.0/usr/lib:home/user1/sqllib/lib32:/home/user1//sqllib/lib32/gskit NLSPATH: /opt/ibm/cobol/rte/usr/lib/usr/share/locale/%L/%N:/opt/ibm/cobol/rte/usr/share/locale/%L/%N:/opt/ibm/cobol/1.1.0/usr/share/locale/%L/%N:/opt/IBM/db2/V11.5/msg/%L/%N:/opt/IBM/db2/V11.5/msg/en_US/%N SYSLIB: /opt/IBM/db2/V11.5/include/cobol_a:/opt/IBM/db2/V11.5/include/cobol_a
Outgoing argument vector for /opt/ibm/cobol/1.1.0/usr/bin/cob3 ... [ 0] - 33 /opt/ibm/cobol/1.1.0/usr/bin/cob3 [ 1] - 14 -qsize(16384K)
exec: /opt/ibm/cobol/1.1.0/usr/bin/cob3 -qsize(16384K) /tmp/myfile.cbl
Outgoing argument vector for /usr/bin/gcc ... [ 0] - 12: /usr/bin/gcc [ 1] - 4: -m32 [ 2] - 7: -shared [ 3] - 5: -fPIC [ 4] - 9: -rdynamic [ 5] - 28: -fasynchronous -unwind -tables [ 6] - 20: -W1, --hash-style=gnu [ 7] - 18: -W1, --export-dynam [ 8] - 14: -W1, -Bsymbolic [ 9] - 14: -W1, --build-id [10] - 22: -W1, --enable-new-dtags [11] - 11: -W1, -zrelro [12] - 9: -W1, -znow [13] - 10: -W1, -zdefs [14] - 18: -W1, -z,noexecstack [15] - 12: -W1, -znotext [16] - 27: -W1, ---allow-shlib-undefined [17] - 4: -pie [18] - 5: -fPIE [19] - 15: --fwhole-program [20] - 15: -W1, --as-needed [21] - 8: myfile.o [22] - 10: linkfile.a [23] - 26: -L/opt/IBM/db2/V11.5/lib32 [24] - 5: ldb2 [25] - 2: -o [26] - 19: /code/bin/myfile.exe [27] - 15: -W1, --no-omagic [28] - 13: -W1, Bdynamic [29] - 15: -W1, --as-needed [30] - 31: L/opt/ibm/cobol/1.1.0/usr/lib/ [31] - 29: L/opt/ibm/cobol/rte/usr/lib/ [32] - 10: -lcob2_32s [33] - 10: -lcob2_32r [34] - 9: -ldfp_32r [35] - 3: -lm [36] - 9: -lpthread [37] - 150: -W1, -rpath,/opt/ibm/cobol/rte/usr/lib/:/opt/ibm/cobol/rte/:/opt/ibm/cobol/1.1.0/usr/lib/:/home/user1//sqllib/lib32:/home/user1/sqllib/lib32/gskit
exec: /usr/bin/gcc -m32 -shared -fPIC -rdynamic -fasynchronous -unwind -tables -W1, --hash-style=gnu -W1, --export-dynam -W1, -Bsymbolic -W1, --build-id -W1, --enable-new-dtags -W1, -zrelro -W1, -znow -W1, -zdefs -W1, -z,noexecstack -W1, -znotext -W1, ---allow-shlib-undefined -pie -fPIE --fwhole-program -W1, --as-needed myfile.o linkfile.a -L/opt/IBM/db2/V11.5/lib32 ldb2 -o /code/bin/myfile.exe -W1, --no-omagic -W1, Bdynamic -W1, --as-needed L/opt/ibm/cobol/1.1.0/usr/lib/ L/opt/ibm/cobol/rte/usr/lib/ -lcob2_32s -lcob2_32r -ldfp_32r -lm -lpthread -W1, -rpath,/opt/ibm/cobol/rte/usr/lib/:/opt/ibm/cobol/rte/:/opt/ibm/cobol/1.1.0/usr/lib/:/home/user1//sqllib/lib32:/home/user1/sqllib/lib32/gskit
答:
1赞
mao
2/20/2023
#1
当存在不兼容的编译/链接选项和对象/库文件时,您会收到此错误。
在您的情况下,您的库可能使用与 cob2 的默认值不同的编译选项构建,从而导致症状。linkfile.a
要解决此问题,您应该安排使用与 cobol 对象文件类似的选项进行重建(通常该选项很重要,可能还有其他选项),或者使用已经以兼容方式构建的其他库。linkfile.a
-fPIC
如果无法做到这一点,则需要规划一种不同的方式,以便将 COBOL 与 中提供的功能进行交互,因此请咨询该功能的开发人员以获取建议。linkfile.a
评论
linkfile.a
cob2
gcc -v
cob2
-#
cob2
CFLAGS
LDFLAGS
cobc -std=ibm-strict