Cannot open source file "stddef.h"

I just installed the PGI compilers so that I could use OpenMP on my Macbook running Mavericks. Unfortunately, when I try to compile any C++ program it gives the following error in the Terminal:

$ pgcpp hello.cc hello hello.cc:
“/opt/pgi/osx86-64/14.6/include/stddef.h”, line 16: catastrophic error: cannot
open source file “stddef.h”
#include_next <stddef.h>
^

1 catastrophic error detected in the compilation of “hello.cc”.
Compilation terminated.
File with unknown suffix passed to linker: hello

Any help would be much appreciated.

Thanks,

Chester

Hi Chester,

Do you have Xcode 3.2 or later installed on your system? PGI compilers require this, and Xcode contains the stddef.h header file being referenced here.

Hope this helps,

+chris

Yes, I have Xcode version 5.1.1.

Hi Chester,

Could you run your compilation again, this time passing the “-v” flag, and paste the result in a response here? On our Mavericks system here, the stddef.h header file lives in /usr/include:

cparrott@mavericks2 ~ $ pgcpp -v -o hello hello.cc
Export PGI=/opt/pgi
Export PGIBIN=/opt/pgi/osx86-64/90473/bin

/proj/pgi/osx86-64/90473/bin/pgcpp1 --nollalign -Dunix -D__unix -D__unix__ -D__LITTLE_ENDIAN__ -D__inline__= -Dosx86 -D__osx86 -D__osx86__ -D__APPLE__ -D__LP64__ -D__x86_64__ -D_M_IX86 -D__NO_MATH_INLINES -D__amd64__ -D__PGI_STRPTIME -D__extension__= -D__SSE__ -D__MMX__ -D__SSE2__ -D__SSE3__ -D__SSSE3__ -D__PGI_5XC__ -D__PGI -D__signed__=signed -I- -I/opt/pgi/osx86-64/90473/include/CC -I/opt/pgi/osx86-64/90473/include -I/usr/local/include -I/Applications/Xcode.app/Contents/Developer/usr/lib/llvm-gcc/4.2.1/include -I/Applications/Xcode.app/Contents/Developer/usr/lib/llvm-gcc/4.2.1/include -I/usr/include -q -o /var/folders/zz/zyxvpxvq6csfxvn_n000045m00011d/T/pgcppCSTruqz39hcR.il hello.cc

I’m curious to know why the compiler can’t find stddef.h on your system. It should be located in one of the directories following the -I flags, as seen above. (-I/usr/include in this case.)

Best regards,

+chris

Thanks for the help, Chris. Here is the result you requested:

$ pgcpp -v -o hello hello.cc
Export PGI=/opt/pgi
Export PGIBIN=/opt/pgi/osx86-64/14.6/bin

/opt/pgi/osx86-64/14.6/bin/pgcpp1 --nollalign -Dunix -D__unix -D__unix__ -D__LITTLE_ENDIAN__ -D__inline__= -Dosx86 -D__osx86 -D__osx86__ -D__APPLE__ -D__LP64__ -D__x86_64__ -D_M_IX86 -D__NO_MATH_INLINES -D__amd64__ -D__PGI_STRPTIME -D__extension__= -D__SSE__ -D__MMX__ -D__SSE2__ -D__SSE3__ -D__SSSE3__ -D__PGI_5XC__ -D__PGI -D__signed__=signed -I- -I/opt/pgi/osx86-64/14.6/include/CC -I/opt/pgi/osx86-64/14.6/include -I/usr/local/include -I/Applications/Xcode.app/Contents/Developer/usr/lib/llvm-gcc/4.2.1/include -I/Applications/Xcode.app/Contents/Developer/usr/lib/llvm-gcc/4.2.1/include -I/usr/include -q -o /var/folders/hn/gsgsdzm917v68d75vhhmj1g00000gn/T/pgcppDmbrxpRjpRqs.il hello.cc
“/opt/pgi/osx86-64/14.6/include/stddef.h”, line 16: catastrophic error: cannot
open source file “stddef.h”
#include_next <stddef.h>
^

1 catastrophic error detected in the compilation of “hello.cc”.
Compilation terminated.
pgcpp-Fatal-cpp1 completed with exit code 4

Chester:

I verified that our Mavericks system has Xcode 5.1.1 installed:

cparrott@mavericks /Applications/Xcode.app/Contents $ cat version.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>BuildVersion</key>
        <string>10</string>
        <key>CFBundleShortVersionString</key>
        <string>5.1.1</string>
        <key>CFBundleVersion</key>
        <string>5085</string>
        <key>ProductBuildVersion</key>
        <string>5B1008</string>
        <key>ProjectName</key>
        <string>IDEFrameworks</string>
        <key>SourceVersion</key>
        <string>5085000000000000</string>
</dict>
</plist>

And I see that our system has a stddef.h file in /usr/include:

cparrott@mavericks /Applications/Xcode.app/Contents $ ls -l /usr/include/stddef.h
-r--r--r--  1 root  wheel  5079 Apr 10 15:07 /usr/include/stddef.h

This is the contents of this file:

cparrott@mavericks /Applications/Xcode.app/Contents $ cat /usr/include/stddef.h 
/*
 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
 *
 * @APPLE_LICENSE_HEADER_START@
 *
 * This file contains Original Code and/or Modifications of Original Code
 * as defined in and that are subject to the Apple Public Source License
 * Version 2.0 (the 'License'). You may not use this file except in
 * compliance with the License. Please obtain a copy of the License at
 * http://www.opensource.apple.com/apsl/ and read it before using this
 * file.
 *
 * The Original Code and all software distributed under the License are
 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
 * Please see the License for the specific language governing rights and
 * limitations under the License.
 *
 * @APPLE_LICENSE_HEADER_END@
 */
/*      $OpenBSD: stddef.h,v 1.2 1997/09/21 10:45:52 niklas Exp $       */
/*      $NetBSD: stddef.h,v 1.4 1994/10/26 00:56:26 cgd Exp $   */

/*-
 * Copyright (c) 1990 The Regents of the University of California.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *      This product includes software developed by the University of
 *      California, Berkeley and its contributors.
 * 4. Neither the name of the University nor the names of its contributors
 *    may be used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 *      @(#)stddef.h    5.5 (Berkeley) 4/3/91
 */

#if !defined(__STDDEF_H__)

#if !defined(__need_wchar_t) && !defined(__need_size_t) \
    && !defined(__need_ptrdiff_t) && !defined(__need_NULL) \
    && !defined(__need_wint_t) && !defined(__need_rsize_t)
#define __STDDEF_H__
#endif /* none of __need_* defined */

#include <_types.h>

#if defined(__STDDEF_H__) || defined(__need_ptrdiff_t)
#include <sys/_types/_ptrdiff_t.h>
#endif /* __STDDEF_H__ || __need_ptrdiff_t */

#if defined(__STDDEF_H__) || defined(__need_size_t)
/* DO NOT REMOVE THIS COMMENT: fixincludes needs to see:
 * _GCC_SIZE_T */
#include <sys/_types/_size_t.h>
#endif /* __STDDEF_H__ || __need_size_t */

#if (defined(__STDDEF_H__) && defined(__STDC_WANT_LIB_EXT1__) && __STDC_WANT_LIB_EXT1__ >= 1) || defined(__need_rsize_t)
#include <sys/_types/_rsize_t.h>
#endif /* (__STDDEF_H__ && __STDC_WANT_LIB_EXT1__ >= 1) || __need_rsize_t */

#if defined(__STDDEF_H__) || defined(__need_wchar_t)
#include <sys/_types/_wchar_t.h>
#endif /* __STDDEF_H__ || __need_wchar_t */

#if (defined(__STDDEF_H__) && !defined(_ANSI_SOURCE) && (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE))) \
    || defined(__need_wint_t)
#include <sys/_types/_wint_t.h>
#endif /* __STDDEF_H__ && !_ANSI_SOURCE && (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) || __need_wchar_t */

#if defined(__STDDEF_H__) || defined(__need_NULL)
#include <sys/_types/_null.h>
#endif /* __STDDEF_H__ || __need_NULL */

#ifdef __STDDEF_H__
#if defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 5 || __GNUC__ > 3)
#ifndef __offsetof      /* Deprecated: for source compatibility only */
#define __offsetof(type, field) __builtin_offsetof(type, field)
#endif
#define offsetof(type, field) __builtin_offsetof(type, field)
#else /* ! (gcc >= 3.5) */
#ifndef __offsetof      /* Deprecated: for source compatibility only */
#define __offsetof(type, field) ((size_t)(&((type *)0)->field))
#endif
#define offsetof(type, field) ((size_t)(&((type *)0)->field))
#endif /* (gcc >= 3.5) */
#endif /* __STDDEF_H__ */

#endif /* __STDDEF_H__ */

#undef __need_ptrdiff_t
#undef __need_size_t
#undef __need_wchar_t
#undef __need_wint_t
#undef __need_NULL
cparrott@mavericks /Applications/Xcode.app/Contents

Can you confirm whether /usr/include/stddef.h is present on your system? And if so, does it match the contents as above?

Best regards,

+chris

It appears that I don’t have an install folder in usr and thus don’t have an stddef.h file there. Here are the contents of /usr:

$ ls
X11 bin libexec sbin standalone
X11R6 lib local share texbin

Hi Chester,

You may want to try reinstalling Xcode, to see if it would restore the missing stddef.h file. I’m honestly not sure which bundle from Apple that stddef.h comes in, but that seems like a good place to start.

Hope this helps,

+chris

Hi Chris,

I reinstalled Xcode a couple times and stddef.h is still nowhere to be found. There is no /usr/include path.

Chester

Hi Chester,

Sometime when you aren’t doing much on your computer, could you run the following command for me?

$ find / -name stddef.h -print

Let me know if it turns up anything. I’m curious to see if stddef.h is getting put somewhere else than the default location on your system. Perhaps we might need to amend our search paths.

Note this will generate a lot of I/O, so it’s not a good idea to do it when you are trying to run other things on your system.

Thanks,

+chris

Hi Chris,

Thanks again for your continued help with this!

Below are what I think are the relevant lines from $ find / -name stddef.h -print. The rest are “Permission denied” lines.

/Applications/Free PGI.app/Contents/Resources/pgi/osx86/14.3/include/CC/stddef.h
/Applications/Free PGI.app/Contents/Resources/pgi/osx86/14.3/include/stddef.h
/Applications/Free PGI.app/Contents/Resources/pgi/osx86-64/14.3/include/CC/stddef.h
/Applications/Free PGI.app/Contents/Resources/pgi/osx86-64/14.3/include/stddef.h
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk/usr/include/stddef.h
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.1.sdk/usr/include/stddef.h
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/usr/include/stddef.h
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/stddef.h
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/5.1/include/stddef.h
/opt/pgi/osx86/14.6/include/CC/stddef.h
/opt/pgi/osx86/14.6/include/stddef.h
/opt/pgi/osx86-64/14.6/include/CC/stddef.h
/opt/pgi/osx86-64/14.6/include/stddef.h

Hi Chester,

I will make a note of this issue here - we have not seen it on our Mavericks systems, so I am not sure of the reason for the discrepancy. For some reason, our Mavericks systems here have /usr/include/stddef.h defined.

As a workaround, you might try the following:

sudo mkdir -p /usr/include

sudo ln -s /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/5.1/include/stddef.h /usr/include/stddef.h

(Note the second sudo command above should be a single line, but it wraps in my browser. The line breaks in the second command should be spaces, e.g. there should be a space before /usr/include/stddef.h, and not a line break.)

Hope this helps,

+chris

The headaches continue. Here is what happens when I try to compile now after running the two commands you suggested:

$ pgcpp -v hello.cc hello
Export PGI=/opt/pgi
Export PGIBIN=/opt/pgi/osx86-64/14.6/bin
hello.cc:

/opt/pgi/osx86-64/14.6/bin/pgcpp1 --nollalign -Dunix -D__unix -D__unix__ -D__LITTLE_ENDIAN__ -D__inline__= -Dosx86 -D__osx86 -D__osx86__ -D__APPLE__ -D__LP64__ -D__x86_64__ -D_M_IX86 -D__NO_MATH_INLINES -D__amd64__ -D__PGI_STRPTIME -D__extension__= -D__SSE__ -D__MMX__ -D__SSE2__ -D__SSE3__ -D__SSSE3__ -D__PGI_5XC__ -D__PGI -D__signed__=signed -I- -I/opt/pgi/osx86-64/14.6/include/CC -I/opt/pgi/osx86-64/14.6/include -I/usr/local/include -I/Applications/Xcode.app/Contents/Developer/usr/lib/llvm-gcc/4.2.1/include -I/Applications/Xcode.app/Contents/Developer/usr/lib/llvm-gcc/4.2.1/include -I/usr/include -q -o /var/folders/hn/gsgsdzm917v68d75vhhmj1g00000gn/T/pgcppgRscsayyRnHn.il hello.cc
“/usr/include/stddef.h”, line 29: error: expression preceding parentheses of
apparent call must have (pointer-to-) function type
#if !defined(_PTRDIFF_T) || __has_feature(modules)
^

“/usr/include/stddef.h”, line 31: error: function call is not allowed in a
constant expression
#if !__has_feature(modules)
^

“/usr/include/stddef.h”, line 34: error: identifier “PTRDIFF_TYPE” is
undefined
typedef PTRDIFF_TYPE ptrdiff_t;
^

“/usr/include/stddef.h”, line 37: error: expression preceding parentheses of
apparent call must have (pointer-to-) function type
#if !defined(_SIZE_T) || __has_feature(modules)
^

“/usr/include/stddef.h”, line 39: error: function call is not allowed in a
constant expression
#if !__has_feature(modules)
^

“/usr/include/stddef.h”, line 48: error: function call is not allowed in a
constant expression
!defined(_RSIZE_T)) || __has_feature(modules)
^

“/opt/pgi/osx86-64/14.6/include/CC/cstring”, line 38: catastrophic error:
cannot open source file “string.h”
#include_next <string.h>
^

6 errors and 1 catastrophic error detected in the compilation of “hello.cc”.
Compilation terminated.
pgcpp-Fatal-cpp1 completed with exit code 4

File with unknown suffix passed to linker: hello

Hi Chester,

First, remove the link I previously suggested.

Have you tried installing the Xcode Command Line Tools? They are no longer installed onto your system by default, as of Xcode 4.3 and later.

If not, you will need to start up Xcode, go to the Downloads preferences panel, and select the Components tab. From here, you should be able to initiate the download of the Xcode Command Line Tools. I believe this will give you all the header files in /usr/include that you are currently missing.

Sorry I didn’t pick up on this before - I had forgotten that Apple makes you do this now. Perhaps we should revise our documentation for OS X users.

Hope this helps.

Best regards,

+chris

Hi Chris,

I removed the link. I thought for sure that I had installed the Xcode Command Line Tools since they weren’t available in the Components tab. I installed them via the command line which means the header files are now in /usr/include as desired.

I’m now having trouble with something completely different when I try to compile though:

$ pgcpp -v -o hello hello.cc
Export PGI=/opt/pgi
Export PGIBIN=/opt/pgi/osx86-64/14.6/bin

/opt/pgi/osx86-64/14.6/bin/pgcpp1 --nollalign -Dunix -D__unix -D__unix__ -D__LITTLE_ENDIAN__ -D__inline__= -Dosx86 -D__osx86 -D__osx86__ -D__APPLE__ -D__LP64__ -D__x86_64__ -D_M_IX86 -D__NO_MATH_INLINES -D__amd64__ -D__PGI_STRPTIME -D__extension__= -D__SSE__ -D__MMX__ -D__SSE2__ -D__SSE3__ -D__SSSE3__ -D__PGI_5XC__ -D__PGI -D__signed__=signed -I- -I/opt/pgi/osx86-64/14.6/include/CC -I/opt/pgi/osx86-64/14.6/include -I/usr/local/include -I/Applications/Xcode.app/Contents/Developer/usr/lib/llvm-gcc/4.2.1/include -I/Applications/Xcode.app/Contents/Developer/usr/lib/llvm-gcc/4.2.1/include -I/usr/include -q -o /var/folders/hn/gsgsdzm917v68d75vhhmj1g00000gn/T/pgcppbfAedyTwu6Xe.il hello.cc

/opt/pgi/osx86-64/14.6/bin/pgcpp2 hello.cc -opt 1 -x 119 0x10000010 -x 129 0x80 -x 19 0x400000 -dollar ‘$’ -x 119 0x40610400 -x 119 0x1000 -x 59 4 -x 129 0x10 -x 70 0x8000 -x 122 1 -x 125 0x20000 -x 117 0x1000 -x 120 0x80 -x 122 0x40 -x 123 0x1000 -x 127 21 -tp sandybridge -y 80 0x40000000 -x 120 0x400 -x 120 0x1000 -astype 1 -fn hello.cc -il /var/folders/hn/gsgsdzm917v68d75vhhmj1g00000gn/T/pgcppbfAedyTwu6Xe.il -x 123 0x80000000 -x 123 4 -x 2 0x400 -x 119 0x20 -alwaysinline /opt/pgi/osx86-64/14.6/lib/libintrinsics.il 4 -x 120 0x200000 -x 70 0x40000000 -x 117 0x2000 -y 189 0x4000000 -x 69 0x200 -cmdline ‘+pgcpp /var/folders/hn/gsgsdzm917v68d75vhhmj1g00000gn/T/pgcppbfAedyTwu6Xe.il -v -o hello’ -asm /var/folders/hn/gsgsdzm917v68d75vhhmj1g00000gn/T/pgcppjfAeBy4qHAi5.s
pgi-cpp-osx64: LICENSE MANAGER PROBLEM: Cannot find license file.
The license files (or license server system network addresses) attempted are
listed below. Use LM_LICENSE_FILE to use a different license file,
or contact your software provider for a license file.
Feature: pgi-cpp-osx64
Filename: /opt/pgi/license.dat
License path: /opt/pgi/license.dat:
FLEXnet Licensing error:-1,359. System Error: 2 “No such file or directory”
For further information, refer to the FLEXnet Licensing documentation,
available at “www.flexerasoftware.com”.
pgcpp-Fatal-cpp2 completed with exit code 1

Unlinking /var/folders/hn/gsgsdzm917v68d75vhhmj1g00000gn/T/pgcppbfAedyTwu6Xe.il
Unlinking /var/folders/hn/gsgsdzm917v68d75vhhmj1g00000gn/T/pgcppjfAeBy4qHAi5.s

Hi Chester,

You will need a valid PGI license file for your system if you do not already have one. Alternately, if your organization has a site license, you can point to it by setting the LM_LICENSE_FILE environment variable. The format is ‘port@host’. Here is an example for bash:

export LM_LICENSE_FILE=12345@license.myorg.com

Consult with your site’s administrator if this applies to you.

If you do not have a site license, then you should have received a license.dat file when you purchased PGI. You will need to copy this file to /opt/pgi/license.dat.

If you do not have a license file, you can generate a short-term trial license from our site here:

https://www.pgroup.com/support/trial.htm

If your license file is installed in /opt/pgi, then I’ll have to get Dave to follow up with you further on this.

Hope this helps.

Best regards,

+chris