我试图用Informix编译一个简单的Cobol时遇到麻烦,它编译,但它没有链接并生成可执行文件
这是我得到的消息:
ld: 0711-317 ERROR: Undefined symbol: .GETENV
ld: 0711-317 ERROR: Undefined symbol: .ECO_DB
ld: 0711-317 ERROR: Undefined symbol: .ECO_SQC
ld: 0711-317 ERROR: Undefined symbol: .ECO_XIM
ld: 0711-317 ERROR: Undefined symbol: .ECO_STM
ld: 0711-317 ERROR: Undefined symbol: .ECO_OC
ld: 0711-317 ERROR: Undefined symbol: .ECO_BOC
ld: 0711-317 ERROR: Undefined symbol: .ECO_SLC
ld: 0711-317 ERROR: Undefined symbol: .ECO_CMT
ld: 0711-317 ERROR: Undefined symbol: .ECO_CDB
ld: 0711-317 ERROR: Undefined symbol: .ECO_DCON
ld: 0711-317 ERROR: Undefined symbol: .ECO_CONN
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
make: The error code from the last command is 8.
我虽然这是一个libpath的问题,但这是我的.profile。
export PATH=$PATH:/usr/bin:/etc:/usr/sbin:/usr/ucb:$HOME/bin:/usr/bin/X11:/sbin:/usr/informix/lib:.
export INFORMIXDIR=/usr/informix
export PATH=$PATH:$INFORMIXDIR/bin
export INFORMIXCOB=cob2
export INFORMIXCOBDIR=/usr/lpp/cobol
export INFORMIXCOBTYPE=ibm
export INFORMIXCOBDIR=/usr/lpp/cobol
export COBDIR=/usr/lpp/cobol
export INFORMIXCOB=cob2
export LIBPATH=$LIBPATH:/usr/informix/lib:/usr/informix/lib/esql:/usr/lpp/cobol/lib
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lpp/cobol/lib:/usr/informix/lib:/usr/informix/lib/esql
我尝试了几件但没有结果......
这是我的作品,但我也尝试使用相同的结果cob2 objet.o。
这是makefile
这是我的作品,但我也尝试使用相同的结果cob2 objet.o。
################################################################################
# Licensed Materials - Property of IBM
#
# ? Copyright IBM Corp. 2013
#
# The source code is provided "AS IS" without warranty of any kind. It is
# provided solely as a sample. It may be used, executed, copied, and modified
# for internal use only by Licensee without royalty.
################################################################################
################################################################################
#
# This makefile template can be used to build your AIX COBOL project. Comments
# are provided to help you understand how it works, and to help you edit it for
# your needs. There are 2 main sections:
# 1. Variables Section - defines targets to build, commands to use, and
# command options
# 2. Rules Section - defines how to build the targets. For each target, it
# provides the commands to run to build them.
#
################################################################################
# Add any other file extensions you will build or build from here
.SUFFIXES:
.SUFFIXES: .cbl .eco
################################################################################
# VARIABLES SECTION
#
# Define variables to control various targets, commands, comand options that are
# used in various places in the makefile
################################################################################
## BUILD TARGETS -- Define all targets to build. These are the final targets of
## the build, usually an exectable (linked objects), executables (batch programs),
## or a library (linked objects intended to be linked to by consuming projects).
## You may explicitly list your final target(s) by uncommenting the following
## lines, and commenting the automatic setting of TARGET below
#TARGETS = PROGRAM1 \
# PROGRAM2.exe \
# PROGRAM3
## If your project only contains batch and/or CICS programs and is simple
## enough, you can have the makefile determine the final targets automatically
## by uncommenting this line and changing "*.cbl *.sqb" to the source
## file extensions you use, as well as adding/removing the
## corresponding ' -e sed "s/\.cbl//" ' arguments to 'sed'
TARGETS = `ls -1 *.cbl *.eco 2> /dev/null | sed -e "s/\.cbl//" -e "s/\.eco//"`
## COMPILE COMMAND
## Single-threaded compile
COB = cob2
## COMPILE OPTIONS
## You will want to add your include paths here too (where copybooks are, if not
## in same directory as source), eg. -I/include/path1 -I/include/path2
COB_OPTS = -g
ESQLCOBOL = esqlcobol
## Link/bind options
LINK_OPTS=
## SQL COMPILE SETTINGS -- Uncomment and set the following variables if you use
## embedded SQL in your source
## DB2_DIR: DB2 install location
## DB_NAME: Database name
## DB_USER: DB2 userid
## DB_PASS: DB2 user password
#DB2_DIR = /opt/IBM/db2/V9.7
#DB_NAME =
#DB_USER =
#DB_PASS =
## Compile options for embedded SQL
#DB2_COB_OPTS = -qLIB -q"SQL('database $(DB_NAME) user $(DB_USER) using $(DB_PASS)')"
## DB2 Precompiler
DB2 = db2
DB2_PREP = $(DB2) prep
DB2_PREP_OPTS = target ibmcob
################################################################################
# RULES SECTION
#
# This section controls how targets are built from dependencies.
# The rule will get run if the dependencies change (become newer than the target)
# There are two types of rules:
# 1. Explicit rule. Builds one explicit target from an explicit list of
# dependencies
# <target>: <dependencies>
# <tab> <rules>
# Example:
# PROGRAM.exe: PROGRAM.cbl MYCOPY.cpy
# cob2 PROGRAM.cbl -o PROGRAM.exe -I./
# 2. Implicit rule. Builds targets with a specified file extension from a
# source file with the same basename and with a specified file extension. If
# only the target is specified then it builds a target with no file extension.
# .<target_extension>.<source_extension>:
# <tab> <rules>
# Example 1: For any .o targets that need to be built, if a .cbl file exists
# with the same name
# .cbl.o:
# cob2 $< -o $@
# Example 2: For any executable targets that need to be built with no file
# extension, if a .cbl file exists with the same name
# .cbl:
# cob2 $< -o $@
################################################################################
# 'all' is the default makefile target that is built for 'make' with no arguments
all: $(TARGETS)
## This rule builds batch COBOL source files to an exectuable program with the
## same basename as the source file with no file extension
.cbl:
$(COB) $< -o $@ $(COB_OPTS) $(DB2_COB_OPTS) $(LINK_OPTS)
## prar ficheros informix
.eco:
$(ESQLCOBOL) $< -o $@
## .SQB (EMBEDDED SQL) RULES FOR COMPILER VERSION 4.1.1.10 OR LATER
## Comment these .SQB rules if using compiler version 4.1.1.9 or earlier, and
## uncomment the .SQB rules following for compiler version 4.1.1.9 or earlier.
## This rule builds embedded SQL source in .sqb files.
.sqb:
$(COB) $< -o $@ $(COB_OPTS) $(DB2_COB_OPTS) $(LINK_OPTS)
## .SQB (EMBEDDED SQL) RULES FOR COMPILER VERSION 4.1.1.9 OR EARLIER
## Comment above .SQB rules if using compiler version 4.1.1.9 or earlier, and
## uncomment this rule.
## This rule preprocesses embedded SQL files, to produce .cbl files that will
## be compiled as usual
#.sqb.cbl:
# $(DB2) connect to $(DB_NAME) user $(DB_USER) using $(DB_PASS)
# $(DB2_PREP) $< $(DB2_PREP_OPTS)
## The clean rule gets run when you run 'make clean', which is the default
## Clean Build command for AIX COBOL projects in RD AIX & Linux. It should
## clean up all files created by the build. It is useful if you want to build
## from scratch (eg. if you change a copybook included by many source files).
clean:
rm -f $(TARGETS) core *.lst *.adt *.adt2 cmpout.xml
这是预处理后的cobol源
0001 identification division.
0002 program-id. 'pruifx'.
0003 author. lmfa.
0004 date-written. Junio 2014.
0005
0006 ******************************************************************
0007 * prueba COBOL sql AIX (INFORMIX) *
0008 ******************************************************************
0009
0010 environment division.
0011 configuration section.
0012 special-names.
0013 decimal-point is comma.
0014
0015 input-output section.
0020 data division.
0025 working-storage section.
0026
0053 * exec sql include sqlca end-exec.
*************************************************************
* Title: sqlca.ibm
* Sccsid: @(#)sqlca.ibm 9.1 10/06/96 15:13:54
* Description:
* SQLCA include file for IBM COBOL Set for AIX 1.1
*************************************************************
77 SQLNOTFOUND PIC S9(10) VALUE 100.
01 SQLCA.
05 SQLCODE PIC S9(9) COMPUTATIONAL-5.
05 SQLERRM.
49 SQLERRML PIC S9(4) COMPUTATIONAL-5.
49 SQLERRMC PIC X(70).
05 SQLERRP PIC X(8).
05 SQLERRD OCCURS 6 TIMES
PIC S9(9) COMPUTATIONAL-5.
05 SQLWARN.
10 SQLWARN0 PIC X(1).
10 SQLWARN1 PIC X(1).
10 SQLWARN2 PIC X(1).
10 SQLWARN3 PIC X(1).
10 SQLWARN4 PIC X(1).
10 SQLWARN5 PIC X(1).
10 SQLWARN6 PIC X(1).
10 SQLWARN7 PIC X(1).
0053 * exec sql include tabdes end-exec.
*EXEC SQL BEGIN DECLARE SECTION END-EXEC.
01 TABDES.
02 DESCOD PICTURE X(3).
02 DESCLA PICTURE X(15).
02 DESDES PICTURE X(62).
*EXEC SQL END DECLARE SECTION END-EXEC.
0054
0055 ****** Definicion de variables para tablas *******************
0238 * exec sql begin declare section end-exec.
01 base-datos PICTURE x(32).
01 cnt-total PICTURE s9(4) value 200.
01 cnt-totals redefines cnt-total PICTURE s9(4).
01 cnt-pendientes PICTURE 9(4) value 0.
01 sql-area PICTURE x(6) value '119953'.
01 sql-fecha PICTURE x(10) value '23.05,201-'.
01 sql-gm PICTURE xx value 'GM'.
01 sql-rmp PICTURE xxx value 'RMP'.
01 sql-m1 PICTURE x(50) value '*'.
01 sql-m2 PICTURE xx value '*'.
01 sql-m3 PICTURE xxx value '*'.
0254 * exec sql end declare section end-exec.
0056
01 xor1 pic x(40) value '1234567890'.
01 xor2 pic x(40) value '0987654321'.
01 p1 pointer.
01 aa pic 9 value zeros.
01 cc pic 99 value 11.
01 campo pic x(64000).
01 P pointer.
01 ix-base pic x(13) value 'INFORMIX_BASE'.
01 ix-server pic x(14) value 'INFORMIXSERVER'.
*Beginning of ESQL/COBOL temporary variables.
77 SQLCODETMP PIC S9(9) COMP-5.
77 SQLWARNTMP PIC S9(9) COMP-5.
77 SQLSTATE PIC X(5).
77 SQLTYPE PIC S9(9) COMP-5.
77 SQLLEN PIC S9(9) COMP-5.
77 SQLINAME PIC S9(9) COMP-5.
77 SQLITYPE PIC S9(9) COMP-5.
77 SQLILEN PIC S9(9) COMP-5.
77 SQLTEXTLEN PIC S9(9) COMP-5.
77 SQL2TEXTLEN PIC S9(9) COMP-5.
77 SQL3TEXTLEN PIC S9(9) COMP-5.
77 SQLINCNT PIC S9(9) COMP-5.
77 SQLUSEFLAG PIC S9(9) COMP-5.
77 SQLOUTCNT PIC S9(9) COMP-5.
77 SQLDIRECTION PIC S9(9) COMP-5.
77 SQLVALUE PIC S9(9) COMP-5.
77 SQLSCRFLAG PIC S9(9) COMP-5.
77 SQLOBJLEN PIC S9(9) COMP-5.
77 SQLBINDTYPE PIC X(1).
77 SQLDUMLEN PIC S9(9) COMP-5 VALUE 1.
77 SQLOBJECT PIC X(18).
77 SQLTEXT PIC X(18).
77 SQL2TEXT PIC X(18).
77 SQL3TEXT PIC X(18).
77 SQLDUMMY PIC X(1) VALUE ' '.
77 ECO-DSH PIC X(7) VALUE 'eco_dsh'.
77 ECO-USH PIC X(7) VALUE 'eco_ush'.
77 ECO-GST PIC X(7) VALUE 'eco_gst'.
77 ECO-SQC PIC X(7) VALUE 'eco_sqc'.
77 ECO-LYR PIC X(7) VALUE 'eco_lyr'.
77 ECO-MSG PIC X(7) VALUE 'eco_msg'.
77 ECO-SQU PIC X(7) VALUE 'eco_squ'.
77 ECO-IQU PIC X(7) VALUE 'eco_iqu'.
77 ECO-SIG PIC X(7) VALUE 'eco_sig'.
77 ECO-SQS PIC X(7) VALUE 'eco_sqs'.
77 ECO-SQE PIC X(7) VALUE 'eco_sqe'.
77 ECO-SQB PIC X(7) VALUE 'eco_sqb'.
77 ECO-SQBCB PIC X(9) VALUE 'eco_sqbcb'.
77 ECO-SQD PIC X(7) VALUE 'eco_sqd'.
77 ECO-DTS PIC X(7) VALUE 'eco_dts'.
77 ECO-DAI PIC X(7) VALUE 'eco_dai'.
77 ECO-DSI PIC X(7) VALUE 'eco_dsi'.
77 ECO-DTC PIC X(7) VALUE 'eco_dtc'.
77 ECO-DTX PIC X(7) VALUE 'eco_dtx'.
77 ECO-INX PIC X(7) VALUE 'eco_inx'.
77 ECO-FIN PIC X(7) VALUE 'eco_fin'.
77 ECO-FFL PIC X(7) VALUE 'eco_ffl'.
77 ECO-DTCVASC PIC X(11) VALUE 'eco_dtcvasc'.
77 ECO-DTTOASC PIC X(11) VALUE 'eco_dttoasc'.
77 ECO-INCVASC PIC X(11) VALUE 'eco_incvasc'.
77 ECO-INTOASC PIC X(11) VALUE 'eco_intoasc'.
77 ECO-IMN PIC X(7) VALUE 'eco_imn'.
77 ECO-IDN PIC X(7) VALUE 'eco_idn'.
77 ECO-IDI PIC X(7) VALUE 'eco_idi'.
77 ECO-DAT PIC X(7) VALUE 'eco_dat'.
77 ECO-DAY PIC X(7) VALUE 'eco_day'.
77 ECO-DEF PIC X(7) VALUE 'eco_def'.
77 ECO-FMT PIC X(7) VALUE 'eco_fmt'.
77 ECO-JUL PIC X(7) VALUE 'eco_jul'.
77 ECO-MDY PIC X(7) VALUE 'eco_mdy'.
77 ECO-STR PIC X(7) VALUE 'eco_str'.
77 ECO-TDY PIC X(7) VALUE 'eco_tdy'.
*End of ESQL/COBOL temporary variables.
77 SQLTEXT01 PIC X(32) VALUE 'set isolation to committed re
- 'ad '.
77 SQLTEXTLEN01 PIC S9(9) COMP-5 VALUE 32.
77 SQLTEXT02 PIC X(44) VALUE 'select * from tabdes where de
- 'scod = ''UBC'' '.
77 SQLTEXTLEN02 PIC S9(9) COMP-5 VALUE 44.
77 SQLTEXT03 PIC X(44) VALUE 'select * from tabdes where de
- 'scod = ''UBC'' '.
77 SQLTEXTLEN03 PIC S9(9) COMP-5 VALUE 44.
local-storage section.
linkage section.
01 xor-campo pic x(64000).
0111
0231==*=================================================================
0232 procedure division.
0234
0235 Principal section.
Set P to address of ix-base
Call "getenv" using by value P returning base-datos
0497 * display 'INFORMIX_BASE' upon MY-ENV-NAME
0498 * accept base-datos from MY-ENV-VALUE
.
empezar.
move 'xxxxx@xxxxxx' to base-datos
0499 * exec sql database :base-datos end-exec
MOVE 0 TO SQLVALUE
MOVE 32 TO SQLOBJLEN
CALL 'eco_db' USING base-datos, SQLVALUE, SQLOBJLEN
CALL 'eco_sqc' USING SQLCA, SQLCODETMP, SQLWARNTMP, SQLSTATE
0500
0501 if not (sqlcode = zeros or = -377)
0502 display 'OpBD'
0503 go to sql-error
0504 end-if
0505
move 'set lock mode to wait 30' to sql-m1
* exec sql
* execute immediate :sql-m1
* end-exec
MOVE 50 TO SQLTEXTLEN
CALL 'eco_xim' USING sql-m1, SQLTEXTLEN
CALL 'eco_sqc' USING SQLCA, SQLCODETMP, SQLWARNTMP, SQLSTATE
display 'sqlcode->' sqlcode
0509
0511 *-----------------------------------------------------------------
0513 * exec sql
0514 * set isolation to committed read
0515 * end-exec
MOVE 0 TO SQLINCNT
CALL 'eco_stm' USING SQLTEXT01, SQLINCNT, SQLTEXTLEN01
CALL 'eco_sqc' USING SQLCA, SQLCODETMP, SQLWARNTMP, SQLSTATE
.
move spaces to tabdes
* exec sql
* select *
* into :tabdes
* from tabdes
* where descod = 'UBC'
* end-exec
MOVE 0 TO SQLINCNT
MOVE 3 TO SQLOUTCNT
CALL 'eco_oc' USING SQLOUTCNT
MOVE 233 TO SQLTYPE
MOVE 3 TO SQLLEN
CALL 'eco_boc' USING SQLTYPE, DESCOD OF tabdes, SQLLEN
MOVE 15 TO SQLLEN
CALL 'eco_boc' USING SQLTYPE, DESCLA OF tabdes, SQLLEN
MOVE 62 TO SQLLEN
CALL 'eco_boc' USING SQLTYPE, DESDES OF tabdes, SQLLEN
MOVE 0 TO SQLVALUE
CALL 'eco_slc' USING SQLTEXT02, SQLINCNT, SQLOUTCNT, SQLVALU
- E, SQLTEXTLEN02
CALL 'eco_sqc' USING SQLCA, SQLCODETMP, SQLWARNTMP, SQLSTATE
display 'TABDES:' tabdes
.
*---------------------------------------------------------------
* exec sql commit work end-exec
CALL 'eco_cmt'
CALL 'eco_sqc' USING SQLCA, SQLCODETMP, SQLWARNTMP, SQLSTATE
* exec sql close database end-exec
CALL 'eco_cdb'
CALL 'eco_sqc' USING SQLCA, SQLCODETMP, SQLWARNTMP, SQLSTATE
* exec sql disconnect all end-exec
MOVE 2 TO SQLVALUE
MOVE 0 TO SQL2TEXTLEN
CALL 'eco_dcon' USING SQLVALUE, SQLDUMMY, SQL2TEXTLEN
CALL 'eco_sqc' USING SQLCA, SQLCODETMP, SQLWARNTMP, SQLSTATE
* display 'INFORMIXSERVER' upon environment-name
* display 'predesa2' upon environment-value
move 'xxxxxx@xxxxxx' to base-datos
0871 * exec sql
0872 * connect to default with concurrent transaction
0873 * end-exec
MOVE 1 TO SQLVALUE
MOVE 0 TO SQLTEXTLEN
MOVE 0 TO SQL2TEXTLEN
MOVE 0 TO SQL3TEXTLEN
MOVE 0 TO SQLOBJLEN
MOVE 1 TO SQLUSEFLAG
CALL 'eco_conn' USING SQLVALUE, SQLDUMMY, SQLDUMMY, SQLDUMMY
, SQLDUMMY, SQLUSEFLAG, SQLTEXTLEN, SQL2TEXTLEN, SQL3TEXTLEN,
SQLOBJLEN
CALL 'eco_sqc' USING SQLCA, SQLCODETMP, SQLWARNTMP, SQLSTATE
0499 * exec sql database :base-datos end-exec
MOVE 0 TO SQLVALUE
MOVE 32 TO SQLOBJLEN
CALL 'eco_db' USING base-datos, SQLVALUE, SQLOBJLEN
CALL 'eco_sqc' USING SQLCA, SQLCODETMP, SQLWARNTMP, SQLSTATE
0500
0501 if not (sqlcode = zeros or = -377)
0502 display 'OpBD'
0503 go to sql-error
0504 end-if
0505
move 'set lock mode to wait 30' to sql-m1
* exec sql
* execute immediate :sql-m1
* end-exec
MOVE 50 TO SQLTEXTLEN
CALL 'eco_xim' USING sql-m1, SQLTEXTLEN
CALL 'eco_sqc' USING SQLCA, SQLCODETMP, SQLWARNTMP, SQLSTATE
display 'sqlcode->' sqlcode
move spaces to tabdes
* exec sql
* select *
* into :tabdes
* from tabdes
* where descod = 'UBC'
* end-exec
MOVE 0 TO SQLINCNT
MOVE 3 TO SQLOUTCNT
CALL 'eco_oc' USING SQLOUTCNT
MOVE 233 TO SQLTYPE
MOVE 3 TO SQLLEN
CALL 'eco_boc' USING SQLTYPE, DESCOD OF tabdes, SQLLEN
MOVE 15 TO SQLLEN
CALL 'eco_boc' USING SQLTYPE, DESCLA OF tabdes, SQLLEN
MOVE 62 TO SQLLEN
CALL 'eco_boc' USING SQLTYPE, DESDES OF tabdes, SQLLEN
MOVE 0 TO SQLVALUE
CALL 'eco_slc' USING SQLTEXT03, SQLINCNT, SQLOUTCNT, SQLVALU
- E, SQLTEXTLEN03
CALL 'eco_sqc' USING SQLCA, SQLCODETMP, SQLWARNTMP, SQLSTATE
display 'TABDES:' tabdes
* exec sql commit work end-exec
CALL 'eco_cmt'
CALL 'eco_sqc' USING SQLCA, SQLCODETMP, SQLWARNTMP, SQLSTATE
* exec sql close database end-exec
CALL 'eco_cdb'
CALL 'eco_sqc' USING SQLCA, SQLCODETMP, SQLWARNTMP, SQLSTATE
* exec sql disconnect all end-exec
MOVE 2 TO SQLVALUE
MOVE 0 TO SQL2TEXTLEN
CALL 'eco_dcon' USING SQLVALUE, SQLDUMMY, SQL2TEXTLEN
CALL 'eco_sqc' USING SQLCA, SQLCODETMP, SQLWARNTMP, SQLSTATE
* display 'INFORMIXSERVER' upon environment-name
* display 'desaobr2' upon environment-value
go to empezar.
.
sql-error.
display 'Sqlerror->' sqlcode
stop run
.
任何帮助将不胜感激
答案 0 :(得分:2)
因为COBOL for AIX编译器默认情况下将程序名称折叠为大写,如果您的COBOL源包含对混合或小写字符的C函数的调用,则此函数将折叠为大写字符。链接器将找不到该程序,并将生成指示未解析符号的错误消息。
您可以使用PGMNAME编译器选项来控制COBOL for AIX编译器如何处理名称。默认值为PGMNAME(UPPER),但您可以使用PGMNAME(MIXED)按原样处理程序名,而不会截断,转换或折叠为大写。当您使用PGMNAME(MIXED)时,请记住使用程序名的文字格式,即使程序名成为文字字符串,例如&#34; programname&#34;或者您将看到以下消息:
IGYDS1046-E用户定义的单词被发现为&#34; PROGRAM-ID&#34; &#34; PGMNAME(MIXED)&#34;下的名称编译器选项。
当&#34; PGMNAME(MIXED)&#34;实际上,对于&#34; PROGRAM-ID&#34;名称。该名称以其大写格式接受。
此外,在链接时,您需要指定包含以&#34; eco _&#34;开头的例程的Informix库。在您指定的makefile中,我没有看到列出的任何Informix库或目标文件。