Cadet 3rd Class
Cadet 3rd Class
376 views

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.

0 Likes
4 Replies
Micro Focus Expert
Micro Focus Expert

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?

0 Likes
Cadet 3rd Class
Cadet 3rd Class

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

 

0 Likes
Cadet 3rd Class
Cadet 3rd Class

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.

0 Likes
Micro Focus Expert
Micro Focus Expert

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?

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.