Could not open source file "limits.h"

Could not open source file "limits.h"

Hi,

I work at an engineering company. Here, we use a Linux host where are installed licenses of an engineering commercial software, called Abaqus. 

Abaqus has a "make" procedure, that makes executable programs using a user soubroutine source code, or the correspondent object file. Here, Abaqus makes use of icpc/ifort compiler to compile C/Fortran codes. My program is written in Fortran, but it uses modules, so instead of using the "make" procedure with the source code of the main program,  I precompiled the modules, then compiled the main program (both using ifort), and finally tried the "make" procedure with the object file (according to Abaqus Documentation, that is completely possible).

The problem is that, apparently, during the make procedure, Abaqus needs to compile an internal source code, in C language, and icpc gives this error: Could not open source file "limits.h" . Here goes a copy of the terminal:

tm@master1:/data/users/tm> abaqus make job=abqmain.o
Abaqus JOB abqmain
Begin Compiling User Post-Processing Program
Fri 03 May 2013 02:47:38 PM CEST
Compiling: /data/users/tm/main_6425.C
icpc: Command line warning: ignoring option '-c'; no argument required
/usr/include/limits.h(125): catastrophic error: could not open source file "limits.h"
  # include_next <limits.h>
                           ^
compilation aborted for /data/users/tm/main_6425.C (code 4)
Abaqus Error: Problem during compilation - /data/users/tm/TM/1_Rchar_Calibration/Fortran/main_6425.C
The Abaqus Make execution procedure exited with errors

Apparently, it's an icpc issue, but I'd rather do not change the Abaqus compilator to gcc.

I searched on the internet, and I found a possible solution, that would be the command:
-idirafter /usr/include/linux

But I doesn't really know what this command does, and also I don't know if it will actually work. I found it in the end of this page, under "Common Problems": http://www.gentoo-wiki.info/HOWTO_ICC_and_Portage

I am afraid to damage the company's host if I use this command. Also, I currently don't have permission to do it, so I have to be pretty sure this is the solution before asking for permission.

Can anyone help me? That solution really works? Is there someway to "undo" the command, so I can run it and latter undo it? Also, does someone know if there is an alternative, or will I have to use gcc?

Thank you

9 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

what version of icc are you using?

See this thread: http://software.intel.com/en-us/forums/topic/301335 

Jennifer

http://www.delorie.com/gnu/docs/gcc/cpp_11.html

describes #include_next and apparently recommends against its use other than for the specific purpose of excluding the preceding search paths.  If there is only one <limits.h> on your search path (the normal case), the usual #include <limits.h> should be fine.

You could simply keep a backup copy of the source code and try replacing include_next by include, as needed, but if you are concerned about it, you should consult Abaqus support.

The icpc version is: icpc (ICC) 9.1 20070510

Quote:

You could simply keep a backup copy of the source code and try replacing include_next by include

I believe that could be a solution, however I don't have the source code of this file, main_6425.C . It is automatically created by Abaqus.

I will contact Abaqus support too, but I am still open to other possible solutions.

But I didn't quite understand this thing: why does the limits.h file has an include statement to "include itself"?

 
/* Get the compiler's limits.h, which defines almost all the ISO constants.
    We put this #include_next outside the double inclusion check because
    it should be possible to include this file more than once and still get
    the definitions from gcc's header.  */
#if defined __GNUC__ && !defined _GCC_LIMITS_H_
/* `_GCC_LIMITS_H_' is what GCC's file defines.  */
# include_next <limits.h>
#endif

Do you know which directories come after /usr/include in the search path? Can I simply make a copy of limits.h in one of these directories? Is the current directory one of them?

Also, this limits.h file is seeming a little strange for me, I think it may have been edited, look:

/* If we are not using GNU CC we have to define all the symbols ourself.
   Otherwise use gcc's definitions (see below).  */
#if !defined __GNUC__ || __GNUC__ < 2
/* ...
Following here there are a lof of definitions
... */

Here, the condition is !defined __GNUC__ || __GNUC__ < 2

So, we should expect that before #include_next, the condition should be the opposite (adding the !defined _GCC_LIMITS_H_) : defined __GNUC__ && __GNUC__ >= 2 && !defined _GCC_LIMITS_H_

Am I wrong?

>>/usr/include/limits.h(125): catastrophic error: could not open source file "limits.h"
>>#include_next "limits.h"

The error text is clear: error: could not open source file and it means that C++ compiler can not find that file on the file system due to some problem with a path.

About construction: #include_next " someheaderfile ". It is used in many another headers, like float.h, stdarg.h, stddef.h, etc.

This is what documentstion says about that construction:

Wrapper Headers
==============================

Sometimes it is necessary to adjust the contents of a system-provided header file without editing it directly.
GCC's `fixincludes' operation does this, for example. One way to do that would be to create a new header
file with the same name and insert it in the search path before the original header. That works fine as long as
you're willing to replace the old header entirely. But what if you want to refer to the old header from
the new one?

You cannot simply include the old header with `#include'. That will start from the beginning, and find your
new header again. If your header is not protected from multiple inclusion (*note Once-Only Headers::), it will
recurse infinitely and cause a fatal error.

You could include the old header with an absolute pathname:
#include "/usr/include/old-header.h"

This works, but is not clean; should the system headers ever move, you would have to edit the new
headers to match.

There is no way to solve this problem within the C standard, but you can use the GNU extension `#include_next'.
It means, "Include the _next_ file with this name." This directive works like `#include' except in searching for
the specified file: it starts searching the list of header file directories _after_ the directory in which the current
file was found.

Suppose you specify `-I /usr/local/include', and the list of directories to search also includes `/usr/include'; and
suppose both directories contain `signal.h'. Ordinary `#include ' finds the file under `/usr/local/include'.
If that file contains `#include_next ', it starts searching after that directory, and finds the file in `/usr/include'.

`#include_next' does not distinguish between `' and `"FILE"' inclusion, nor does it check that the file you
specify has the same name as the current file. It simply looks for the file named, starting with the directory in
the search path after the one where the current file was found.

The use of `#include_next' can lead to great confusion. We recommend it be used only when there is no other
alternative. In particular, it should not be used in the headers belonging to a specific program; it should be used
only to make global corrections along the lines of `fixincludes'.

Quote:

Sergey Kostrov wrote:
About construction: #include_next " someheaderfile ". It is used in many another headers, like float.h, stdarg.h, stddef.h, etc.

So, there should be another limits.h file in the search path? And (I am sorry to ask again) in the case of the limits.h file, do you know for which reason it has to be re-included? I am insisting in this question because, apparently, it should be re-included if I was using a GCC compiler, which is not the case.

Thank you a lot

>>So, there should be another limits.h file in the search path?

Possibly Yes.

>>And (I am sorry to ask again) in the case of the limits.h file, do you know for which reason it has to be re-included?

I don't know exact reason and I could assume this is due to some compatibility / portability issues. I think we're trying to discuss some 3rd party issue and a question on a GCC-forum could help to understand why it happens.

grep -l -e ' limits.h' /usr/include/*.h ,maybe due to some mutiple-including problems.

QIAOMINQ.

Leave a Comment

Please sign in to add a comment. Not a member? Join today