0

My overall problem is trying to install HEALPix C++ version and, to isolate the problem, I created foo.cpp:

#include <string>
#include <iostream>

I then run

g++ foo.cpp

to which I get the following error message:

foo.cpp:1:18: fatal error: string: No such file or directory
 #include <string>
                  ^
compilation terminated.

I am running

g++ (GCC) 4.9.2 20141029 (prerelease)
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

downloaded from http://hpc.sourceforge.net/

on OS X Yosemite 10.10

I get the same error message with gcc 5.0 and 4.8 as well. I tried downloading gcc 4.9 from homebrew but this also doesn't work (though with a different error message).

I then try

g++ -I/usr/local/include/c++/4.9.2 foo.cpp

to which I get the error message:

In file included from foo.cpp:1:0:
/usr/local/include/c++/4.9.2/string:38:28: fatal error: bits/c++config.h: No such file
or directory
 #include <bits/c++config.h>
                            ^
compilation terminated.

Now, obviously, I don't want to have to find (recursively) the directory of each required header (for my HEALPix installation, this could take forever!) It seems to me that there is a problem with where #include is looking? How can I change this? Also, if the workaround is to specify the directories of required headers, it is not immediately obvious to me how to specify this within my configuration for the HEALPix installation.

Hope someone can suggest a solution!

Thanks

user2970116
  • 85
  • 1
  • 6
  • 1
    Why is this tagged "c"? – Leeor Nov 11 '14 at 14:35
  • 1
    You could read the installation guide for the software you are using. https://gcc.gnu.org/install/ – Hogan Nov 11 '14 at 14:35
  • 2
    Looks like you are missing libstdc++ somehow. Those are system headers and you should not specify path to them explicitly, you should read gcc installation instructions how to install gcc and libraries properly on your platform. – Slava Nov 11 '14 at 14:36
  • Did you also install Apple's tools, as per the instructions? – molbdnilo Nov 11 '14 at 14:51
  • @molbdnilo Yes, I have the Xcode command line tools (if this is what you are referring to?) `xcode-select: error: command line tools are already installed, use "Software Update" to install updates` and there are no software updates in the App Store. – user2970116 Nov 11 '14 at 15:02
  • @Slava A quick `locate libstdc++` reveals `libstdc++.a`, `libstdc++.la`, `libstdc++.dylib` and other files in multiple places including `/usr/lib` and `/usr/local/lib`. Does this seems vaguely right to you? – user2970116 Nov 11 '14 at 15:33
  • @user2970116 libstdc++ contains not only libraries but headers as well. If those libraries are in /usr/lib, then headers should be in /usr/include. I am not familiar with OS X, but on linux headers for libraries may be installed by separate package, which has suffix dev on some distributions. This answer may help http://stackoverflow.com/questions/9353444/how-to-use-install-gcc-on-mac-os-x-10-8-xcode-4-4 – Slava Nov 11 '14 at 15:41
  • @Slava I have looked in `/usr/include` and it seems me that the libstdc++ headers are there - although I note that `string.h` is there (rather than `string` which is in `/usr/local/include/c++/4.9.2` – user2970116 Nov 12 '14 at 10:31
  • @Slava I am trying to reinstall a new gcc 4.9 (building it myself rather than using pre-compiled binaries), but I have an error at the configure stage. Looking in the log, I have an error: `as: assembler (/usr/libexec/gcc/darwin/x86_64/as or /usr/local/libexec/gcc/darwin/x86_64/as) for architecture x86_64 not installed` (followed by a list of installed assemblers). Where can I get the necessary assembler? Hope you can help! – user2970116 Nov 12 '14 at 10:37

0 Answers0