>>>>>>>>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
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
It did pass compilation.
It is the link stage that failed.
Hi kris,
Thank you very very very much!
It works!
;)
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