ERROR: (11) Cannot find C runtime library

I have just completed an installation of Visual COBOL for Eclipse and trying to compile and run a program. It compiles fine but gives this linking error. I assume it is some additional library or path that is not correctly configured. This is running on Windows 10. This is a simple test program from a class. The only thing different is it uses a sequential file that I can see.

Here is the link step

cobol.link.cfg.New_Configuration:
[cobollink] Linking (64-bit) CarSales.exe...
[cobollink] Micro Focus COBOL - CBLLINK utility
[cobollink] Version 6.0.0.69 (C) Copyright 1984-2020 Micro Focus or one of its affiliates.
[cobollink]
[cobollink] ERROR: (11) Cannot find C runtime library
[cobollink] Link complete with errors
[cobollink]

 

Program Listing

IDENTIFICATION DIVISION.
PROGRAM-ID. COMPUTEVERBS.

ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT CARSALESFILE ASSIGN TO "CARSALES.DAT"
ORGANIZATION IS LINE SEQUENTIAL.


DATA DIVISION.
FILE SECTION.
FD CARSALESFILE.
01 SALESDETAILS.
88 ENDOFSALESFILE VALUE HIGH-VALUES.
02 SALESPERSONNAME.
05 LASTNAME PIC X(15).
05 FIRSTNAME PIC X(10).

02 QUARTERLYSALES.
05 Q1-SALES PIC 9(7).
05 Q2-SALES PIC 9(7).
05 Q3-SALES PIC 9(7).
05 Q4-SALES PIC 9(7).
02 CARTOTAL PIC 9(3).

WORKING-STORAGE SECTION.

01 WS-DATE.
05 WS-YEAR PIC 99.
05 WS-MONTH PIC 99.
05 WS-DAY PIC 99.
01 WS-QUARTERLYSALES.
05 WS-Q1-SALES PIC 9(8) VALUE ZEROES.
05 WS-Q2-SALES PIC 9(8) VALUE ZEROES.
05 WS-Q3-SALES PIC 9(8) VALUE ZEROES.
05 WS-Q4-SALES PIC 9(8) VALUE ZEROES.
01 WS-CAR-SALES.
05 WS-SALESPERSON-YEARLY PIC 9(10) VALUE ZEROES.
05 WS-YEARLY-SALES PIC 9(12) VALUE ZEROES.
05 WS-CAR-PRICE-AVERAGE PIC 9(12).
05 WS-TOTAL-CAR-SALES PIC 9999 VALUE ZEROES.
05 WS-DISPLAY-AVERAGE PIC $$$,$$$,$$$.99.
05 WS-CARS-MINUS-10 PIC 9(4).

01 HEADING-LINE.

05 FILLER PIC X(16) VALUE 'SALESPERSON NAME'.
05 FILLER PIC X(20) VALUE SPACES.
05 FILLER PIC X(11) VALUE 'QTR 1 SALES'.
05 FILLER PIC X(2) VALUE SPACES.
05 FILLER PIC X(11) VALUE 'QTR 2 SALES'.
05 FILLER PIC X(2) VALUE SPACES.
05 FILLER PIC X(11) VALUE 'QTR 3 SALES'.
05 FILLER PIC X(2) VALUE SPACES.
05 FILLER PIC X(11) VALUE 'QTR 4 SALES'.
05 FILLER PIC X(4) VALUE SPACES.
05 FILLER PIC X(12) VALUE 'YEARLY SALES'.
05 FILLER PIC X(37) VALUE SPACES.

01 DETAIL-LINE.
05 FILLER PIC X(5) VALUE SPACES.
05 DET-FNAME PIC X(10).
05 FILLER PIC X(5) VALUE SPACES.
05 DET-LNAME PIC X(15).
05 FILLER PIC X(1) VALUE SPACES.
05 DET-Q1-SALES PIC $$,$$$,$$9.
05 FILLER PIC X(3) VALUE SPACES.
05 DET-Q2-SALES PIC $$,$$$,$$9.
05 FILLER PIC X(3) VALUE SPACES.
05 DET-Q3-SALES PIC $$,$$$,$$9.
05 FILLER PIC X(3) VALUE SPACES.
05 DET-Q4-SALES PIC $$,$$$,$$9.
05 FILLER PIC X(3) VALUE SPACES.
05 DET-YEARLYSALES PIC $$,$$$,$$$,$$9.
05 FILLER PIC X(19) VALUE SPACES.

01 DETAIL-TOTAL-LINE1.
05 FILLER PIC X(5) VALUE SPACES.
05 FILLER PIC X(10).
05 FILLER PIC X(5) VALUE SPACES.
05 FILLER PIC X(15).
05 FILLER PIC X(1) VALUE SPACES.
05 FILLER PIC X(10) VALUE "==========".
05 FILLER PIC X(3) VALUE SPACES.
05 FILLER PIC X(10) VALUE "==========".
05 FILLER PIC X(3) VALUE SPACES.
05 FILLER PIC X(10) VALUE "==========".
05 FILLER PIC X(3) VALUE SPACES.
05 FILLER PIC X(10) VALUE "==========".
05 FILLER PIC X(7) VALUE SPACES.
05 FILLER PIC X(10) VALUE "==========".
05 FILLER PIC X(19) VALUE SPACES.

01 DETAIL-TOTAL-LINE.
05 FILLER PIC X(5) VALUE SPACES.
05 FILLER PIC X(10).
05 FILLER PIC X(5) VALUE SPACES.
05 FILLER PIC X(15) VALUE "TOTALS: ".
05 FILLER PIC X(1) VALUE SPACES.
05 DET-Q1-TOT-SALES PIC $$,$$$,$$9.
05 FILLER PIC X(3) VALUE SPACES.
05 DET-Q2-TOT-SALES PIC $$,$$$,$$9.
05 FILLER PIC X(3) VALUE SPACES.
05 DET-Q3-TOT-SALES PIC $$,$$$,$$9.
05 FILLER PIC X(3) VALUE SPACES.
05 DET-Q4-TOT-SALES PIC $$,$$$,$$9.
05 FILLER PIC X(3) VALUE SPACES.
05 DET-TOT-YEARLYSALES PIC $$,$$$,$$$,$$9.
05 FILLER PIC X(19) VALUE SPACES.

 

PROCEDURE DIVISION.
0100-OPENFILE.
OPEN INPUT CARSALESFILE.
DISPLAY HEADING-LINE.
READ CARSALESFILE
AT END SET ENDOFSALESFILE TO TRUE
END-READ.
PERFORM 0200-PROCESS-SALES UNTIL ENDOFSALESFILE.

 

0200-PROCESS-SALES.

* MOVE FIRSTNAME TO DET-FNAME
MOVE LASTNAME TO DET-LNAME
MOVE Q1-SALES TO DET-Q1-SALES
MOVE Q2-SALES TO DET-Q2-SALES
MOVE Q3-SALES TO DET-Q3-SALES
MOVE Q4-SALES TO DET-Q4-SALES


ADD Q1-SALES TO WS-Q1-SALES,
WS-SALESPERSON-YEARLY
ADD Q2-SALES TO WS-Q2-SALES,
WS-SALESPERSON-YEARLY
ADD Q3-SALES TO WS-Q3-SALES,
WS-SALESPERSON-YEARLY
ADD Q4-SALES TO WS-Q4-SALES,
WS-SALESPERSON-YEARLY
MOVE WS-SALESPERSON-YEARLY TO DET-YEARLYSALES
ADD WS-SALESPERSON-YEARLY TO WS-YEARLY-SALES
MOVE ZEROES TO WS-SALESPERSON-YEARLY
DISPLAY DETAIL-LINE

IF CARTOTAL IS NUMERIC THEN
COMPUTE WS-TOTAL-CAR-SALES = WS-TOTAL-CAR-SALES
CARTOTAL
ELSE
DISPLAY "THE VALUE FOR THE NBR OF CARS SOLD IS INVALID"
END-IF.

READ CARSALESFILE
AT END SET ENDOFSALESFILE TO TRUE
END-READ.

SUBTRACT 10 FROM WS-TOTAL-CAR-SALES
GIVING WS-CARS-MINUS-10.

* END-PERFORM.

MOVE WS-Q1-SALES TO DET-Q1-TOT-SALES.
MOVE WS-Q2-SALES TO DET-Q2-TOT-SALES.
MOVE WS-Q3-SALES TO DET-Q3-TOT-SALES.
MOVE WS-Q4-SALES TO DET-Q4-TOT-SALES.
MOVE WS-YEARLY-SALES TO DET-TOT-YEARLYSALES.
DISPLAY DETAIL-TOTAL-LINE1.
DISPLAY DETAIL-TOTAL-LINE.
DISPLAY WS-CARS-MINUS-10.

COMPUTE WS-CAR-PRICE-AVERAGE =
WS-YEARLY-SALES/WS-TOTAL-CAR-SALES.
MOVE WS-CAR-PRICE-AVERAGE TO WS-DISPLAY-AVERAGE.
DISPLAY " ".
DISPLAY "TOTAL CAR SALES: ",
WS-TOTAL-CAR-SALES.
DISPLAY "AVERAGE CAR PRICE: ",WS-DISPLAY-AVERAGE.

CLOSE CARSALESFILE.

 


STOP RUN.

END PROGRAM COMPUTEVERBS.

  • Does this occur on all programs and projects?

    Since this is a 64-bit build it would be looking for the 64-bit version of the C library msvcrt.lib when linking.
    These libraries should be installed by Visual COBOL if they are not already installed.

    The first thing I would recommend is to try to Repair Visual COBOL from Control Panel-->Installed Programs.

    If that doesn't fix it then:
    Open up a Visual COBOL 64-bit command prompt from the Start Menu and issue the following command:

    cblms -Q

    This should list the Microsoft libraries that are currently in use.
    On my system it displays V14.16.27023

    So on my system the 64-bit C run-time library should be found in:
    C:\Program Files (x86)\Micro Focus\Visual COBOL\Microsoft\VC\Tools\MSVC\14.16.27023\lib\x64

    Is this folder available on your system?

  • This does happen on all projects.

    I installed the Eclipse version so my directory structure seems to be different. I originally tried to get the Visual Studio version to work but could never even get past the license registration process with it so I uninstalled and installed this version.

    I did the repair and it did not seem to have any impact.

    I do have that file two versions of it.


    Windows SDK
    location = c:\Program Files (x86)\Windows Kits\10
    version = 10.0.18362.0

    Microsoft Build Tools
    location = c:\Program Files (x86)\Microsoft Visual Studio\2017\Community
    version = 14.16.27023

     

  • I uninstalled Visual Studio Community Edition 2019.

    I uninstalled all the Micro Focus stuff.

    I reinstalled everything again.

    Same error.

    The cblms -Q now shows


    Windows SDK
    location = c:\Program Files (x86)\Windows Kits\10
    version = 10.0.17763.0

    Microsoft Build Tools
    location = c:\Program Files (x86)\Microsoft Visual Studio\2017\Community
    version = 14.16.27023

    In every linker I have worked with there is a way to add a lib path into the compile just not sure how to do that with Micro Focus COBOL for Eclipse.

  • I think that perhaps the switch between the Visual Studio and the Eclipse product might have somehow corrupted this.
    The environment variable that is used to point to the location of the library files is LIB.

    If you open up a Visual COBOL 64-bit command prompt and enter the command:
    echo %LIB% it should show you the exact locations that are being searched. If this does not point to a valid location containing the C run-time files then this is why the error is occurring.

    On a brand new Windows 10 VM on which I installed VC6.0 Eclipse my LIB shows as:
    echo %LIB%
    c:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\lib\x64;c:\Program Files (x86)\Windows Kits\10\Lib\10.0.17763.0\um\x64;c:\Program Files (x86)\Windows Kits\10\Lib\10.0.17763.0\ucrt\x64;C:\Program Files (x86)\Micro Focus\Visual COBOL\lib64\;

    and the PATH shows as:

    PATH=c:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\bin\Hostx64\x64;c:\Program Files (x86)\Windows Kits\10\Bin\10.0.17763.0\x64;C:\Program Files (x86)\Micro Focus\Visual COBOL\bin64\;C:\Program Files (x86)\Micro Focus\Visual COBOL\binn64\;C:\Program Files (x86)\Micro Focus\Visual COBOL\bin\;C:\Program Files (x86)\Micro Focus\Visual COBOL\AdoptOpenJDK\bin;C:\Program Files (x86)\Micro Focus\Visual COBOL\AdoptRedis;C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;C:\windows\System32\OpenSSH\;C:\Users\crg\AppData\Local\Microsoft\WindowsApps;

    What do you have for these settings?

  • Hi Chris, 

    we have the same issue in our development team. We are using the Eclipse Version of Visual COBOL.  We performed an upgrade from VCE 5 PU15 to VCE 6 PU5. On every deverloper PC this works fine. But on one machine we have this issue, too. We uninstalled all MF Software and reinstalled Visual COBOL and the Patch-Update on this PC. 

    Unfortunately without any impact on the compiler issue. 

     

    For comparision:

    The cblms -Q on the machine with the error returns: 

    Windows SDK
     location = c:\Program Files (x86)\Windows Kits\10
     version  = 10.0.18362.0

    Microsoft Build Tools
     location = c:\Program Files (x86)\Microsoft Visual Studio\2019\Community
     version  = 14.28.29333

     

    On my PC (where everything is working fine) it returns: 

    Windows SDK
    location = c:\Program Files (x86)\Windows Kits\10
    version = 10.0.18362.0

    Microsoft Build Tools
    location = c:\Program Files (x86)\Microsoft Visual Studio\2019\Professional
    version = 14.28.29333

    So this is completely equal. We have no idea how we can proceed with this. Do you have any other idea? 

     

     

  • One thing I notice is that on the PC it's working on it appears you have VS Professional and on the one it's failing on it appears you have VS Community - this is based solely on the path names. Is that actually connect?


  • Also please see my post above dated: 2020-10-15 20:23 regarding the LIB environment variable.

    Thanks

  • Yes, we found out that this is the reason. The Colleague used VS 2019 Community where all others are using VS2019 Professional. 

    The Issue is now solved because we replaces the Community Edition with the Professional Edition. 

     

    Thanks for this suggestion.