When 64-bit COBOL dll called from Smalltalk application, getting "Cannot access <PgmName> in DLL" Er

Installed Visual COBOL for Visual Studio 2019 on Windows Server 2012. I have created a project and loaded my COBOL program which has PROCEDURE DIVISION USING parameters. These parameters were declared in Linkage Section. I have set the Configuration as "Release" and Platform as "x64". I want to generate a 64-bit dll which will be accessed by Smalltalk application in 64-bit environment. We had a 32-bit dll from same COBOL program which is working fine with 32-bit Smalltalk application. Could someone help?


Rahul KK

  • Adding some more information...

    32-bit dll was generated using IBM VisualAge COBOL on XP machine which is working fine with Smalltalk 32-bit application so far. Now, as part of upgradation to 64-bit, used Visual COBOL to create 64-bit dll and while accessing it from Smalltalk 64-bit application, it is getting an error "Cannot access <PgmName> in dll".

    It is a simple COBOL program which has few variables declared in Working-Storage and few in Linkage Section which will be passed from Smalltalk application. Originally, it has PROCEDURE DIVISION USING Parm1, Parm2, Parm3, Parm4 RETURNING Returncode. Since, RETURNING is throwing an error in Visual COBOL, removed RETURNING. i.e. PROCEDURE DIVISION USING Parm1, Parm2, Parm3, Parm4, Returncode.



    Rahul KK

  • I am not familiar with the calling mechanism used by Smalltalk to call a .DLL so I am not sure what it is expecting as far as a call-convention is concerned. Is it trying to call a standard cdecl or WINAPI?

    Can you please show me what the Smalltalk call looks like?

    The RETURNING phrase of the procedure division header is allowed in Visual COBOL for native procedural programs only if one of the mainframe dialects is being specified, i.e. $SET DIALECT"ENTCOBOL". If you use the default DIALECT"MF" then you can return a value on the GOBACK or EXIT statement:

       GOBACK RETURNING returncode.

    Since you had a working 32-bit version of the Smalltalk program, were you able to get that working with a 32-bit version of the Micro Focus .DLL before trying the 64-bit .DLL?


  • Thanks Chris for quick response.
    Please find below the sample Smalltalk code where COBOL dll is called.

    In01 Pic x(30)
    In02 Pic x(30)
    In03 Pic x(30)
    Out01 Pic x(01)

    |res args|

    (Lib at:#Test01) isNil
    ifTrue:[^ nil,].
    args := Array new:4.
    args at: 1 put:(str01 justifyLeft: 30).
    args at: 2 put:(str02 justifyLeft: 30).
    args at: 3 put:(str03 justifyLeft: 30).
    args at: 4 put:(String space: 1).

    res := (Lib at: #Test01) callWithArguments: args. ---> COBOL Test01.dll will be called here
    res = 0
    ifFalse: [ ^ ('Error....', res printString) asMessage ].
    ^ (args at:4).

    In COBOL program, Linkage Section has 5 variables.

    Linkage Section.
    01 IN01 PIC X(30).
    01 IN02 PIC X(30).
    01 IN03 PIC X(30).
    01 OUT01 PIC X(01).
    01 RC PIC 9(9) BINARY.


    I have created a 32-bit dll from Visual COBOL trial version and tried accessing it from Smalltalk 32-bit environment and it is not working. We are getting same error message "Cannot access <TEST01> in DLL TEST01".

    I have set the configuration as "Release" and Platform as "x86" to generate 32-bit dll.

    Do I need to change any settings/options? Please advise.

    Also, I noticed that size of 32-bit dll generated in IBM VisualAge is around 400k whereas in Visual COBOL it is only 120k.  

    Rahul KK

  • The Smalltalk source is not useful. You need to consult the documentation for your Smalltalk implementation and find out what Windows calling convention it uses.

    You can check to see what symbols your COBOL DLL exports using the Microsoft dumpbin or depends utilities, or a variety of others. Documentation and further information about this process is available online.

    The size of a DLL produced by a different compiler is irrelevant.

  • There could be a number of different reasons for the error, but I suspect that the dll simply failed to load. Any COBOL dll will, by default, have a direct reference to the COBOL run-time dll so if that cannot be found the dll will fail to load. To see if that is the case try launching the SmallTalk application from a Visual COBOL (or Enterprise Developer) command prompt. If you don't get the error then that was the problem and you should be able to resolve it by one of the following :

    1. In the IDE, in the Properties for the project When building the COBOL DLL, on the COBOL Link page select the Dynamic option.

    2. Ensure that PATH includes the VIsual COBOL product's bin folder prior to launching the SmallTalk application eg by creating a batch file.

    If it is not that then you will need to check call-conventions and/or the case of the exported names as mentioned by the other replies.