Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29246 Discussions

LINK : fatal error LNK1104: cannot open file 'LIBC.lib'

mohanmuthu
New Contributor I
4,879 Views
I am trying to compile a simple code in Intel Fortran 9.1 in XP-32 machine and getting following error.


> ifort test.f90 /o test.exe

Intel Fortran Compiler for 32-bit applications, Version 9.1 Build 20071017 Z Package ID: W_FC_C_9.1.039
Copyright (C) 1985-2007 Intel Corporation. All rights reserved.
ifort: warning: Microsoft Visual C++ not found in path
Microsoft Incremental Linker Version 10.00.30319.01
Copyright (C) Microsoft Corporation. All rights reserved.

-out:test.exe
-subsystem:console
test.obj
LINK : fatal error LNK1104: cannot open file 'LIBC.lib'

~~~~~~~~~ test.f90
program test
implicit none
print(*,*) 'Hello World'
end program test


Since I have VS2010, I use command prompt to get exe. Can someone help me to overcome this error?

0 Kudos
1 Solution
mecej4
Honored Contributor III
4,879 Views
You must have at least one of these three libraries: LIBC.LIB, LIBCMT.LIB, or MSVCRT.LIB, and other Windows system libraries such as KERNEL32.LIB, ..., and your LIB environment variable must contain the location(s) of these libraries.

If you do not have a compatible version of Microsoft C or a Microsoft SDK (Platform SDK, Device Driver Kit), you cannot build Fortran programs.

View solution in original post

0 Kudos
6 Replies
mecej4
Honored Contributor III
4,880 Views
You must have at least one of these three libraries: LIBC.LIB, LIBCMT.LIB, or MSVCRT.LIB, and other Windows system libraries such as KERNEL32.LIB, ..., and your LIB environment variable must contain the location(s) of these libraries.

If you do not have a compatible version of Microsoft C or a Microsoft SDK (Platform SDK, Device Driver Kit), you cannot build Fortran programs.
0 Kudos
mohanmuthu
New Contributor I
4,879 Views

Out of 3 libraries mentioned, I have LIBCMT.LIB andMSVCRT.LIB in Microsoft Visual C++ 2010's library path. Even after adding that path in LIB environment variable, I get the same error.
0 Kudos
mecej4
Honored Contributor III
4,879 Views
You should use the /MD or /MT compiler options. The former goes with MSVCRT.LIB, and the latter with LIBCMT.LIB.

If you compile (or have compiled) with neither option, the default in older versions of Intel Fortran was to compile for LIBC.LIB. It is best to recompile your sources as well as to rebuild any user libraries with the /MD or /MT options rather than rely upon the /nodefaultlib:... link
er option.
0 Kudos
mohanmuthu
New Contributor I
4,879 Views

mecej4 - Thanks very much. I'm getting the exe with /MT.

/MT option is for multi-threads. Will it affect my output in anyway or it doesn't matter? If yes, how can I prevent/mitigate it?

0 Kudos
mecej4
Honored Contributor III
4,879 Views
You do not need to worry about compatibility. The OS manages things so that your code will not try to use more threads than the hardware is capable of supporting (unless you explicitly override it -- in this case, you may or may not get what you ask for).

Both the /MT and /MD options produce code that is capable of running with multiple threads.

Using /MT makes your EXE self-contained, and probably a little faster.

Using /MD makes your EXE depend on MSVCR??.DLL. The EXE will be smaller in size, but may run a little slower because of the need to load and map routines in the DLL, and to execute the little bit of glue code involved.

Unless your code contains threading errors, the results will be the same whether you use static or dynamic libraries.
0 Kudos
Steven_L_Intel1
Employee
4,879 Views
LIBC.LIB was the single-threaded Microsoft Visual C++ library. MS did away with that in VS2005 - now only thread-safe (multithread) libraries are provided. If you have objects compiled against old libraries that reference LIBC you must recompile them.
0 Kudos
Reply