Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

HELP: crazy from DLL invoking from PL1 on IBM Rational Developer for System z (Windows platform)

20 views
Skip to first unread message

kelvin

unread,
Nov 17, 2009, 5:08:31 AM11/17/09
to
I am trying to invoke external dll from PL1 with IBM Rational
Developer for System z tools under the windows platform for several
days. unfortunately, I did not pass the compilation. Any help would be
greately appreciated!

>>>>>>>>method in the test.dll which written by C++>>>>>>>>
int test1(char* str1)
{
strcpy(str1,"testtest1111111111111");
return 1;
}
>>>>>>>>>>>>>>>>>test.dll>>>>>>>>>>>>>>>>>>>>>>>>>
The dll file have been passed test.

>>>>>>>>>>>>>>>>>>>>>>calldll.pli>>>>>>>>>>>>>>>>>>>>
*process langlvl(saa2);
*process or('|');
*process prefix(nofofl);

calldll: proc() options(main);

dcl test1 external('test1') entry((*)CHAR(100));
dcl inputStr CHAR(1) dimension(100) INIT((*)'');

put skip list ( 'inputStr=' ,inputStr);
CALL test1(inputStr);
put skip list ( 'inputStr=' ,inputStr);

end calldll;
>>>>>>>>>>>>>>>>>>>>>>calldll.pli>>>>>>>>>>>>>>>>>>>>

The step of compilation:
1) pli calldll
------------------------------screen
snapshot:-------------------------------------
5724-B67 IBM(R) PL/I for Windows 7.5
Copyright (C) IBM Corporation 1996,2008
Licensed Material - Property of IBM. All rights reserved.
--------------------------------------------------------------------------------------------
2) ilink calldll.obj /stack:80000 test.lib
------------------------------screen
snapshot:-------------------------------------
Copyright (C) IBM Corporation 1988, 1998.
Copyright (C) Microsoft Corp. 1988, 1989.
All rights reserved.


calldll.obj(E:\IBM\rationalsdp\workspace\pl1calldll\pli\calldll.pli) :
error LNK2029: "?test1" : unresolved external


There was 1 error detected
--------------------------------------------------------------------------------------------

Thanks in Advance!

Best regards,
Kelvin

Peter Flass

unread,
Nov 17, 2009, 6:48:40 AM11/17/09
to
Is C++ doing "name mangling?" What is the external name generated for
test1? This "feature" of C and C++ is the biggest POS ever invented,
and causes more problems and incompatibilities than just about anything
else except the other features of C and C++.

kris1980

unread,
Nov 17, 2009, 6:51:43 AM11/17/09
to

Hi,

1) Create a def file (test.def):

01: LIBRARY test.dll
02: EXPORTS
03: _test1

2) Create an import lib (test.lib)

ilib.exe /GENI test.def

3) Create a interface file (test.cpy)

%dcl #__TEST_INC__ char ext;
%if #__TEST_INC__ = '' %then %do;
%#__TEST_INC__ = 'Y';

dcl test1 ext('_test1')
entry(char(*) varz byaddr) /* name */
returns(type fixed bin(31))
options(byvalue nodescriptor linkage(cdecl));

%end; /* #__TEST_INC__ */

4) compile link and run...

I think the external name must be different from declaration name:

dcl test1 ext('_test1')
or
dcl test1forpl1 ext('test1')

kris


robin

unread,
Nov 17, 2009, 7:43:02 PM11/17/09
to
"kelvin" <shaoj...@gmail.com> wrote in message
news:2ce10b20-a140-4960...@m7g2000prd.googlegroups.com...

|I am trying to invoke external dll from PL1 with IBM Rational
| Developer for System z tools under the windows platform for several
| days. unfortunately, I did not pass the compilation.

It did pass compilation.
It is the link stage that failed.

kelvin

unread,
Nov 17, 2009, 9:50:20 PM11/17/09
to

Hi kris,

Thank you very very very much!
It works!

kris1980

unread,
Nov 23, 2009, 10:10:51 AM11/23/09
to

;)

I found a new way...
(I found a new way... pseudo dynamic)

1) Don't create a def file ;)
2) Don't create an import lib ;)
3) Create a interface file (test.inc)

%dcl #__TEST_INC__ char ext;
%if #__TEST_INC__ = '' %then %do;
%#__TEST_INC__ = 'Y';

dcl test1 ext('test/test1')


entry(char(*) varz byaddr) /* name */
returns(type fixed bin(31))

options(byvalue nodescriptor linkage(cdecl) fetchable);

%end; /* #__TEST_INC__ */

4) compile link and run...

kris


0 new messages