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

Fatal error cannot open "LIBC"

vivitsa
Beginner
1,321 Views

Hello,

I am quite new to fortran. I have a intel fortran 9.1 version on win32 XP OS. I had also installed MS Visual studio 2005 before installing fortran IA-32.

Its working fine in the case of simple fortran codes like finding out volume of sphere etc. I can execute them from Visual studio as well as command line in the build environment.

But when I try to execute a code (say file.f90) which has to run along with a set of object files in the same directory I get the error message......(Unlike the previous case I use nmake here).

Fatal error cannot open "LIBC"
ifort: error: problem during multi-file optimization compilation (code 1)
NMAKE : fatal error U1077: 'ifort' : return code '0x1'
Stop.

I am able to get file.obj. But I guess the problem arises when it tries to link file.obj and other object files. I have even tried to set ignore libc library in the linker(from previous posts). It doesnt work.

I have pasted makefile below..........

#
# Makefile for building ls971
# on 'Windows '
# for diuble precision SMPD
ls971: dyn21.obj
ifort -q -o ls971 dyn21.obj
libdyna.lib libansysdp.lib shell32.lib /F:10000000 -link -force -nodefaultlib:msvcrt.lib
dyn21.obj: dyn21.f
ifort -c -W0 -WB -unroll -Qfp_port -G7 -4Yportlib -Qfpp2 /assume:byterecl /fltconsistency
-DPCWIN -DINTEL -DOPENMP -Qopenmp -DAUTODOUBLE -4R8 -4I8 -QxK dyn21.f

I would really appreciate any help here. Thanks.

Madhav.

0 Kudos
10 Replies
Steven_L_Intel1
Employee
1,321 Views

VS2005 does not provide libc.lib - this is explained in the Intel Fortran Compiler Release Notes. I would guess that the libraries you are linking to were built with an earlier version of Visual C++ so they reference libc.lib. For static libraries, only the multithread version (libcmt.lib) is available. The Fortran compiler will default to /MT when it has been installed specifying command-line compatibility with VS2005.

Unfortunately, it is generally not just a case of telling the linker to ignore libc, as with C/C++, the compiler generates different code for single and multithread code, or static and DLL.

You can try using /nodefaultlib:libc.lib, but you say it doesn't work. I'm not sure why that would be, perhaps you did not specify it in the right place.

I am always uncomfortable when I see /nodefaultliib and /force in a build script - they're usually covering up for mistakes made elsewhere.

0 Kudos
vivitsa
Beginner
1,321 Views
I added /nodefaultlib to my makefile. Its working now. Previously I changed the property settings in MS VS 2005 Configuration Properties | Linker | Input. Set Ignore specific library to libc. And I was running from command line. Thats why I guess it didnt work. Thanks a lot for your inputs steve.

But I get a warning message

LINK : warning LNK4044: unrecognized option '/F:10000000'; ignored
libansysdp.lib(lm_new.obj) : warning LNK4217: locally defined symbol _time imported in function _l_buf_2


Can I ignore them? Or is there anything that should be done to supress them.

Madhav.
0 Kudos
Steven_L_Intel1
Employee
1,321 Views

/F is an ifort switch. The equivalent linker switch is /stack. But /stack is meaningless when building a DLL - I'm not sure if that's what you're doing.

The linker warning 4217 can be ignored. It is saying that you have a DLLIMPORT for a symbol that is defined in the DLL. This is common when building Fortran DLLs and is harmless.

0 Kudos
vivitsa
Beginner
1,321 Views
Thanks once again steve. /stack supressed the error.

Madhav.
0 Kudos
aref_tehranian
Beginner
1,321 Views

VS2005 does not provide libc.lib - this is explained in the Intel Fortran Compiler Release Notes. I would guess that the libraries you are linking to were built with an earlier version of Visual C++ so they reference libc.lib. For static libraries, only the multithread version (libcmt.lib) is available. The Fortran compiler will default to /MT when it has been installed specifying command-line compatibility with VS2005.

Unfortunately, it is generally not just a case of telling the linker to ignore libc, as with C/C++, the compiler generates different code for single and multithread code, or static and DLL.

You can try using /nodefaultlib:libc.lib, but you say it doesn't work. I'm not sure why that would be, perhaps you did not specify it in the right place.

I am always uncomfortable when I see /nodefaultliib and /force in a build script - they're usually covering up for mistakes made elsewhere.

Could you please tell me where exactly should I put /nondefaultlib:libc.lib
I inserted it in the following statement; it is not working though. Is this the right usage of this switch?

ifort -q -o ls971 dyn21.obj libdyna.lib libansysdp.lib shell32.lib /F:10000000 -link -force -nondefaultlib:libc.lib -nodefaultlib:msvcrt.lib

Thank you in advance,
Aref
0 Kudos
TimP
Honored Contributor III
1,321 Views
Quoting - aref_tehranian
ifort -q -o ls971 dyn21.obj libdyna.lib libansysdp.lib shell32.lib /F:10000000 -link -force -nondefaultlib:libc.lib -nodefaultlib:msvcrt.lib

Why do you spell it more than one way? nodefaultlib seems to work for you.
As you are linking libansys, you should be paying for a license and support, so this is not the place for advice.
0 Kudos
Steven_L_Intel1
Employee
1,321 Views
Please note that the spelling of the switch is "nodefaultlib", not "noNdefaultlib".
0 Kudos
aref_tehranian
Beginner
1,321 Views
Thank you steve. I used the following code and it still gives me "cannot find LIBC" error:

ifort -w -q -o ls971.exe dyn21.obj dyn21b.obj libdyna.lib libansys.lib shell32.lib -link -force -nodefaultlib:libc.lib -nodefaultlib:msvcrt.lib

Am I using this switch in the right place?
0 Kudos
Steven_L_Intel1
Employee
1,321 Views
You are using it in the right place. Adding -verbose at the end would give you some diagnostic output saying where the various requests for libraries are coming from. I'm unsure why -nodefaultlib is not working for you.

However, I recommend getting a version of the libraries you're using that are compatible with VS2005 or VS2008.
0 Kudos
TimP
Honored Contributor III
1,321 Views
However, I recommend getting a version of the libraries you're using that are compatible with VS2005 or VS2008.
Or, obtain and follow the recommendations of the software vendor.
0 Kudos
Reply