Description of Problem: even most basic C++ program does not compile Version-Release number of selected component (if applicable): # rpm -q gcc gcc-3.2-7 How Reproducible: always Steps to Reproduce: 1. Create program #include <iostream.h> int main() { return (0); } 2. run g++ foo.C or gcc foo.C 3. Actual Results: # g++ foo.C foo.C:1:22: iostream.h: No such file or directory Expected Results: Additional Information:
do you have libstdc++-devel-3.2-7 installed (well, gcc-c++-3.2-7 requires it)? Works just fine for me: In file included from /usr/include/c++/3.2/backward/iostream.h:31, from /tmp/x.C:1: /usr/include/c++/3.2/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <sstream> instead of the deprecated header <strstream.h>. To disable this warning use -Wno-deprecated.
$ rpm -ql libstdc++-devel|grep /iostr /usr/include/c++/3.2/backward/iostream.h /usr/include/c++/3.2/iostream $ c++ foo.C foo.C:1:22: iostream.h: No such file or directory $ sed 's/\.h//' foo.C > foo.C.tmp && mv foo.C.tmp foo.C && c++ foo.C foo.C:1:20: iostream: No such file or directory
Forgot: $ rpm -q libstdc++-devel libstdc++-devel-3.2-7
Can you add -v to g++ -v foo.C? g++ foo.C -v Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.2/specs Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --host=i386-redhat-linux --with-system-zlib --enable-__cxa_atexit Thread model: posix gcc version 3.2 20020903 (Red Hat Linux 8.0 3.2-7) /usr/lib/gcc-lib/i386-redhat-linux/3.2/cc1plus -v -D__GNUC__=3 -D__GNUC_MINOR__=2 -D__GNUC_PATCHLEVEL__=0 -D__GXX_ABI_VERSION=102 -D__ELF__ -Dunix -D__gnu_linux__ -Dlinux -D__ELF__ -D__unix__ -D__gnu_linux__ -D__linux__ -D__unix -D__linux -Asystem=posix -D__NO_INLINE__ -D__STDC_HOSTED__=1 -D_GNU_SOURCE -Acpu=i386 -Amachine=i386 -Di386 -D__i386 -D__i386__ -D__tune_i386__ foo.C -D__GNUG__=3 -D__DEPRECATED -D__EXCEPTIONS -quiet -dumpbase foo.C -version -o /tmp/cc42SqCe.s GNU CPP version 3.2 20020903 (Red Hat Linux 8.0 3.2-7) (cpplib) (i386 Linux/ELF) GNU C++ version 3.2 20020903 (Red Hat Linux 8.0 3.2-7) (i386-redhat-linux) compiled by GNU C version 3.2 20020903 (Red Hat Linux 8.0 3.2-7). ignoring nonexistent directory "/usr/i386-redhat-linux/include" #include "..." search starts here: #include <...> search starts here: /usr/include/c++/3.2 /usr/include/c++/3.2/i386-redhat-linux /usr/include/c++/3.2/backward /usr/local/include /usr/lib/gcc-lib/i386-redhat-linux/3.2/include /usr/include End of search list. In file included from /usr/include/c++/3.2/backward/iostream.h:31, from foo.C:1: /usr/include/c++/3.2/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <sstream> instead of the deprecated header <strstream.h>. To disable this warning use -Wno-deprecated. ...
$ g++ foo.C -v Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.2/specs Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --host=i386-redhat-linux --with-system-zlib --enable-__cxa_atexit Thread model: posix gcc version 3.2 20020903 (Red Hat Linux 8.0 3.2-7) /usr/lib/gcc-lib/i386-redhat-linux/3.2/cc1plus -v -D__GNUC__=3 -D__GNUC_MINOR__=2 -D__GNUC_PATCHLEVEL__=0 -D__GXX_ABI_VERSION=102 -D__ELF__ -Dunix -D__gnu_linux__ -Dlinux -D__ELF__ -D__unix__ -D__gnu_linux__ -D__linux__ -D__unix -D__linux -Asystem=posix -D__NO_INLINE__ -D__STDC_HOSTED__=1 -D_GNU_SOURCE -Acpu=i386 -Amachine=i386 -Di386 -D__i386 -D__i386__ -D__tune_i386__ foo.C -D__GNUG__=3 -D__DEPRECATED -D__EXCEPTIONS -quiet -dumpbase foo.C -version -o /tmp/ccALs40F.s GNU CPP version 3.2 20020903 (Red Hat Linux 8.0 3.2-7) (cpplib) (i386 Linux/ELF) GNU C++ version 3.2 20020903 (Red Hat Linux 8.0 3.2-7) (i386-redhat-linux) compiled by GNU C version 3.2 20020903 (Red Hat Linux 8.0 3.2-7). ignoring nonexistent directory "/usr/lib/../include/c++/3.2" ignoring nonexistent directory "/usr/lib/../include/c++/3.2/i386-redhat-linux" ignoring nonexistent directory "/usr/lib/../include/c++/3.2/backward" ignoring nonexistent directory "/usr/lib/../i386-redhat-linux/include" #include "..." search starts here: #include <...> search starts here: /usr/local/include /usr/lib/gcc-lib/i386-redhat-linux/3.2/include /usr/include End of search list. foo.C:1:20: iostream: No such file or directory So obviously, /usr/include/c++/3.2 /usr/include/c++/3.2/i386-redhat-linux /usr/include/c++/3.2/backward are missing from the search directory list. Wonder why... I am running the c++ command as a brand new user so my personal init files cannot be the problem.
If you are sure /usr/include/c++/3.2 directory exists, then the problem is that /usr/lib/../include/c++/3.2 is not /usr/include/c++/3.2, ie. /usr/lib is a symlink somewhere else. Can you please check that?
$ ls -dl /usr/include/c++/3.2 drwxr-xr-x 6 root root 4096 Oct 4 17:02 /usr/include/c++/3.2/ and $ ls -l /usr/lib lrwxrwxrwx 1 root root 24 Jul 5 22:04 /usr/lib -> ../home/symlinks/usr_lib/
Well, ../home/symlinks/ is certainly not what the distribution created. You need to add a symlink wherever ../home/symlinks/usr_lib really points to.
I do not understand this at all: what is wrong with /usr/lib being a symlink? If your partition containing /usr/lib gets full, what do you do? Is it documented somewhere that if /usr/lib is a symlink then c++ will not work anymore? Why is c++ looking for include files in /usr/lib/../include/c++/3.2 and why not directly in /usr/include/c++/3.2 ( that is in $(includeddir)/c++/3.2 or ${libsubdir}/include/c++/3.2) reading gcc-3.2-20020903/gcc/configure, it seems setting enable_version_specific_runtime_libs=yes would solve the problem. Otherwise gcc_gxx_include_dir="\$(libsubdir)/\$(unlibsubdir)/..\`echo \$(exec_prefix) | sed -e 's|^\$(prefix)||' -e 's|/[^/]*|/..|g'\`/include/"${libstdcxx_incdir} sets the includdir searchpath. I do not understand when you say You need to add a symlink wherever ../home/symlinks/usr_lib really points to. Where do I add this? To every g++ command I run? How? Mate
OK, so you mean for me to create something like ln -s ../home/symlinks/usr_include /usr/include to match ln -s ../home/symlinks/usr_lib /usr/lib In other words, if I make /usr/lib a symlink then /usr/include has to made one too and point to a dir with the same parentdir? What else do I have to make a symlink once /usr/lib is?
Before I can tell you you need to ls -l /home/symlinks/usr_lib Note that the above behaviour is how gcc always worked by design, so that it can be relocated somewhere else without too much pain.
Well, ls -l /home/symlinks/usr_lib/|wc -l and /home/symlinks/usr_lib is not a symlink anymore. The output is at http://www.csi.hu/mw/lsl_usrlib.txt As for the behavior of gcc this way: why not solve the relocatability problem by looking up the search directories in a config file and in the environment? The price I pay for the flexibilty in relocating gcc is that I cannot move my /usr/lib directory anywhere. When # du -s /home/symlinks/usr_lib/ 1088016 /home/symlinks/usr_lib it certainly can happen that 1G has to be moved some place else. (Thx for your patience, though)