0

嗨,我是 cobol 的初学者,在编译这个 sendmail 程序时需要帮助。我需要使用 OpenVMS 上的 COBOL 程序向 SMTP 域发送邮件。你能帮我解决这个编译错误吗?

COBOl 程序

identification division.
program-id. sendmail.
data division.
working-storage section.
01 stat pic s9(9) comp.
01 context pic 9(9) comp value 0.
01 null-item.
03 filler pic 9(4) comp value 0.
03 filler pic 9(4) comp value 0.
03 filler pic 9(9) comp value 0.
03 filler pic 9(9) comp value 0.
01 dummy-len pic 9(9) comp.
01 subject pic x(12) value 'test subject'.
01 subject-item.
03 subject-len pic 9(4) comp value 12.
03 filler pic 9(4) comp value external mail$_send_subject.
03 subject-addr pointer value reference subject.
03 filler pointer value reference dummy-len.
03 filler pic 9(9) comp value 0.
01 first_addressee pic x(64) value 'hein'.
01 second_addressee pic x(64) value 'heinvandenheuvel@xxx.yyy'.
01 addr-item.
03 addr-user-len pic 9(4) comp value 64.
03 filler pic 9(4) comp value external mail$_send_username.
03 addr-user-addr pointer value reference first_addressee.
03 filler pointer value reference dummy-len.
03 filler pic 9(9) comp value 0.
01 line1 pic x(6) value 'line 1'.
01 line2 pic x(6) value 'line 2'.
01 body-item.
03 body-file-len pic 9(4) comp value 6.
03 filler pic 9(4) comp value external mail$_send_record.
03 body-file-addr pointer value reference line1.
03 filler pointer value reference dummy-len.
03 filler pic 9(9) comp value 0.
procedure division.
main.
initialize context
call 'mail$send_begin' using context, null-item, null-item giving stat
if stat is failure
call 'lib$signal' using by value stat
else
call 'mail$send_add_attribute' using context, subject-item, null-item
giving stat
if stat is failure
call 'lib$signal' using by value stat
else
call 'mail$send_add_address' using context, addr-item, null-item
giving stat
if stat is failure
call 'lib$signal' using by value stat
end-if
set addr-user-addr to reference of second_addressee
call 'mail$send_add_address' using
context, addr-item, null-item
giving stat
if stat is failure
call 'lib$signal' using by value stat
else
call 'mail$send_add_bodypart' using
context, body-item, null-item
giving stat
if stat is failure
call 'lib$signal' using by value stat
else
set body-file-addr to reference of line2
call 'mail$send_add_bodypart' using
context, body-item, null-item
giving stat
if stat is failure
call 'lib$signal' using by value stat
else
call 'mail$send_message' using
context, null-item, null-item
giving stat
if stat is failure
call 'lib$signal' using by value stat
end-if
end-if
end-if
end-if
end-if
if stat is failure
call 'mail$send_abort' using context, null-item, null-item
giving stat
if stat is failure
call 'lib$signal' using by value stat
end-if
else
call 'mail$send_end' using context, null-item, null-item
giving stat
if stat is failure
call 'lib$signal' using by value stat
end-if
end-if
exit program.

编译时出错

I%ILINK-W-NUDFSYMS, 3 undefined symbols:
%ILINK-I-UDFSYM,        MAIL$_SEND_RECORD
%ILINK-I-UDFSYM,        MAIL$_SEND_SUBJECT
%ILINK-I-UDFSYM,        MAIL$_SEND_USERNAME
%ILINK-W-USEUNDEF, undefined symbol MAIL$_SEND_SUBJECT referenced
        section: $LOCAL$
        offset: %X000000000000003A
        module: SENDMAIL
        file: $DISK54:[DEVL.OHN.UH15]TENDMAIL.OBJ;3
%ILINK-W-USEUNDEF, undefined symbol MAIL$_SEND_USERNAME referenced
        section: $LOCAL$
        offset: %X00000000000000CA
        module: SENDMAIL
        file: $DISK54:[DEVL.OHN.UH15]TENDMAIL.OBJ;3
%ILINK-W-USEUNDEF, undefined symbol MAIL$_SEND_RECORD referenced
        section: $LOCAL$
        offset: %X00000000000000EA
        module: SENDMAIL
        file: $DISK54:[DEVL.OHN.UH15]TENDMAIL.OBJ;3
%ILINK-W-USEUNDEF, undefined symbol MAIL$_SEND_SUBJECT referenced
        section: $LOCAL$
        offset: %X0000000000000258
        module: SENDMAIL
        file: $DISK54:[DEVL.OHN.UH15]TENDMAIL.OBJ;3
%ILINK-W-USEUNDEF, undefined symbol MAIL$_SEND_USERNAME referenced
        section: $LOCAL$
        offset: %X0000000000000330
        module: SENDMAIL
        file: $DISK54:[DEVL.OHN.UH15]TENDMAIL.OBJ;3
%ILINK-W-USEUNDEF, undefined symbol MAIL$_SEND_RECORD referenced
        section: $LOCAL$
        offset: %X00000000000003D8
        module: SENDMAIL
        file: $DISK54:[DEVL.OHN.UH15]TENDMAIL.OBJ;3
$               set noverify
4

1 回答 1

2

上面的 Cobol 程序请求链接器在外部提供(邮件)符号的值。

您必须为它提供 MAIL$ 符号,例如通过创建帮助模块 MAILDEF 例如:

$ cre maildef.mar
.TITLE MAILDEF
$MAILDEF GLOBAL
$MAILMSGDEF GLOBAL
.END
Exit
$ macr maildef
$ cob mail
$ link mail,maildef

祝你好运,海因

于 2014-03-29T13:51:32.260 回答