g++ #include doesn't work (SuSE 11.1, x86_64)

I recently installed SuSE 11.1 64bit version and I just noticed that I can’t compile any program using g++. It fails on #include directives. I create a simple program:

#include <iostream>

using namespace std;

int main() {
return 0;
}

and when I run “g++ main.cpp” I get something like this :

In file included from main.cpp:1:
/usr/include/c++/4.3/iostream:44:28: error: bits/c++config.h: Nie ma takiego pliku ani katalogu
In file included from /usr/include/c++/4.3/cwchar:49,
from /usr/include/c++/4.3/bits/postypes.h:47,
from /usr/include/c++/4.3/iosfwd:47,
from /usr/include/c++/4.3/ios:44,
from /usr/include/c++/4.3/ostream:45,
from /usr/include/c++/4.3/iostream:45,
from main.cpp:1:
/usr/include/c++/4.3/cstddef:49:20: error: stddef.h: Nie ma takiego pliku ani katalogu
In file included from /usr/include/features.h:354,
from /usr/include/stdio.h:28,
from /usr/include/c++/4.3/cstdio:50,
from /usr/include/c++/4.3/bits/char_traits.h:48,
from /usr/include/c++/4.3/ios:46,
from /usr/include/c++/4.3/ostream:45,
from /usr/include/c++/4.3/iostream:45,
from main.cpp:1:
/usr/include/gnu/stubs.h:7:27: error: gnu/stubs-32.h: Nie ma takiego pliku ani katalogu
In file included from /usr/include/stdio.h:75,
from /usr/include/c++/4.3/cstdio:50,
from /usr/include/c++/4.3/bits/char_traits.h:48,
from /usr/include/c++/4.3/ios:46,
from /usr/include/c++/4.3/ostream:45,
from /usr/include/c++/4.3/iostream:45,
from main.cpp:1:
/usr/include/libio.h:53:21: error: stdarg.h: Nie ma takiego pliku ani katalogu
In file included from /usr/include/c++/4.3/ios:47,
from /usr/include/c++/4.3/ostream:45,
from /usr/include/c++/4.3/iostream:45,
from main.cpp:1:
/usr/include/c++/4.3/bits/localefwd.h:47:76: error: bits/c++locale.h: Nie ma takiego pliku ani katalogu
In file included from /usr/include/c++/4.3/bits/ios_base.h:46,
from /usr/include/c++/4.3/ios:48,
from /usr/include/c++/4.3/ostream:45,
from /usr/include/c++/4.3/iostream:45,
from main.cpp:1:
/usr/include/c++/4.3/ext/atomicity.h:39:23: error: bits/gthr.h: Nie ma takiego pliku ani katalogu
/usr/include/c++/4.3/ext/atomicity.h:40:30: error: bits/atomic_word.h: Nie ma takiego pliku ani katalogu
In file included from /usr/include/c++/4.3/string:48,
from /usr/include/c++/4.3/bits/locale_classes.h:47,
from /usr/include/c++/4.3/bits/ios_base.h:48,
from /usr/include/c++/4.3/ios:48,
from /usr/include/c++/4.3/ostream:45,
from /usr/include/c++/4.3/iostream:45,
from main.cpp:1:
/usr/include/c++/4.3/bits/allocator.h:53:31: error: bits/c++allocator.h: Nie ma takiego pliku ani katalogu
In file included from /usr/include/c++/4.3/bits/basic_ios.h:44,
from /usr/include/c++/4.3/ios:50,
from /usr/include/c++/4.3/ostream:45,
from /usr/include/c++/4.3/iostream:45,
from main.cpp:1:
/usr/include/c++/4.3/bits/locale_facets.h:48:30: error: bits/ctype_base.h: Nie ma takiego pliku ani katalogu
/usr/include/c++/4.3/bits/locale_facets.h:1559:31: error: bits/ctype_inline.h: Nie ma takiego pliku ani katalogu
In file included from /usr/include/c++/4.3/iosfwd:46,
from /usr/include/c++/4.3/ios:44,
from /usr/include/c++/4.3/ostream:45,
from /usr/include/c++/4.3/iostream:45,
from main.cpp:1:
/usr/include/c++/4.3/bits/stringfwd.h:46: error: expected constructor, destructor, or type conversion before ‘(’ token
/usr/include/c++/4.3/bits/stringfwd.h:55: error: expected type-specifier before ‘allocator’
/usr/include/c++/4.3/bits/stringfwd.h:55: error: expected ‘>’ before ‘allocator’
/usr/include/c++/4.3/bits/stringfwd.h:60: error: template argument 3 is invalid
/usr/include/c++/4.3/bits/stringfwd.h:60: error: invalid type in declaration before ‘;’ token
/usr/include/c++/4.3/bits/stringfwd.h:68: error: ‘_GLIBCXX_END_NAMESPACE’ does not name a type
In file included from /usr/include/c++/4.3/cwchar:49,
from /usr/include/c++/4.3/bits/postypes.h:47,
from /usr/include/c++/4.3/iosfwd:47,
from /usr/include/c++/4.3/ios:44,
from /usr/include/c++/4.3/ostream:45,
from /usr/include/c++/4.3/iostream:45,
from main.cpp:1:
/usr/include/c++/4.3/cstddef:57: error: ‘::size_t’ has not been declared
In file included from /usr/include/c++/4.3/bits/postypes.h:47,
from /usr/include/c++/4.3/iosfwd:47,
from /usr/include/c++/4.3/ios:44,
from /usr/include/c++/4.3/ostream:45,
from /usr/include/c++/4.3/iostream:45,
from main.cpp:1:
/usr/include/c++/4.3/cwchar:61: error: expected constructor, destructor, or type conversion before ‘extern’
In file included from /usr/include/c++/4.3/ios:45,
from /usr/include/c++/4.3/ostream:45,
from /usr/include/c++/4.3/iostream:45,
from main.cpp:1:
/usr/include/c++/4.3/exception:40: error: expected declaration before end of line

“Nie ma takiego pliku ani katalogu” means “No such file or directory”, so basicly it looks that it can’t find files that should be included. I have g++ 4.3.3 [gcc-4_3-branch revision 144878], installed from standard suse repo. Any idea what the hell is wrong?

Hi
Compiles fine here??


zypper se -i gcc
Loading repository data...
Reading installed packages...

S | Name      | Summary                                  | Type
--+-----------+------------------------------------------+--------
i | gcc       | The system GNU C Compiler                | package
i | gcc-c++   | The system GNU C++ Compiler              | package
i | gcc-gij   | The system GNU Java bytecode interpreter | package
i | gcc43     | The GNU C Compiler and Support Files     | package
i | gcc43-c++ | The GNU C++ Compiler                     | package
i | gcc43-gij | Java Bytecode Interpreter for gcc        | package
i | libgcc43  | C compiler runtime library               | package

I think you may not have installed gcc-c++ which provides the softlinks?


Cheers Malcolm °¿° (Linux Counter #276890)
openSUSE 11.1 (i586) Kernel 2.6.27.21-0.1-pae
up 1 day 3:04, 3 users, load average: 0.76, 0.61, 0.50
ASUS eeePC 1000HE ATOM N280 1.66GHz | GPU Mobile 945GM/GMS/GME

zypper se -i gcc

Pobieranie danych repozytorium...
Odczyt zainstalowanych pakietów...

S | Nazwa          | Podsumowanie                                  | Typ
--+----------------+-----------------------------------------------+-------
i | gcc            | The system GNU C Compiler                     | pakiet
i | gcc-c++        | The system GNU C++ Compiler                   | pakiet
i | gcc-fortran    | The system GNU Fortran Compiler               | pakiet
i | gcc-info       | The system GNU Compiler documentation         | pakiet
i | gcc43          | The GNU C Compiler and Support Files          | pakiet
i | gcc43-c++      | The GNU C++ Compiler                          | pakiet
i | gcc43-fortran  | The GNU Fortran Compiler and Support Files    | pakiet
i | gcc43-info     | Documentation for the GNU compiler collection | pakiet
i | libgcc43       | C compiler runtime library                    | pakiet
i | libgcc43-32bit | C compiler runtime library                    | pakiet

It seems to be in place.

I analysed some of the error messages and for example I managed to eliminate one of the errors saying that /usr/include/gnu/stubs-32.h doesn’t exist by installing glbc-devel-32bit. However it seems strange that 64bit compiler needs 32 bit libraries.

Hi
Strange, just tested on 64 bit and again compiles fine…

On my 64bit version I have;


S | Name           | Summary                                  | Type
--+----------------+------------------------------------------+--------
i | gcc            | The system GNU C Compiler                | package
i | gcc-c++        | The system GNU C++ Compiler              | package
i | gcc-gij        | The system GNU Java bytecode interpreter | package
i | gcc43          | The GNU C Compiler and Support Files     | package
i | gcc43-c++      | The GNU C++ Compiler                     | package
i | gcc43-gij      | Java Bytecode Interpreter for gcc        | package
i | libgcc43       | C compiler runtime library               | package
i | libgcc43-32bit | C compiler runtime library               | package

and

zypper se -i libstd

S | Name              | Summary
| Type
--+-------------------+------------------------------------------------+--------
i | libstdc++-devel   | The system GNU C++ development files | package
i | libstdc++33-32bit | The standard C++ shared library         |package
i | libstdc++43       | The standard C++ shared library | package
i | libstdc++43-32bit | The standard C++ shared library | package
i | libstdc++43-devel | Include Files and Libraries mandatory for De->
| package

Do you have another example to try?


Cheers Malcolm °¿° (Linux Counter #276890)
openSUSE 11.1 (i586) Kernel 2.6.27.21-0.1-pae
up 1 day 4:00, 2 users, load average: 0.40, 0.46, 0.33
ASUS eeePC 1000HE ATOM N280 1.66GHz | GPU Mobile 945GM/GMS/GME

Ok, I solved the problem.

First of all I was wrong about the repo - my gcc was installed from gcc repo. I just migrated from SuSE 10.2 and I copied all the repositories (of course I swtiched to appropriate repo version). On 10.2 there was no problem with gcc from gcc repo, however on 11.1 it seems not to work out of the box.

I reinstalled gcc packages from suse repo. This time when I tried to compile something I got another error :

g++ main.cpp
/tmp/ccgdYNmk.s: Assembler messages:
/tmp/ccgdYNmk.s:10: Error: suffix or operands invalid for `push'
/tmp/ccgdYNmk.s:12: Error: suffix or operands invalid for `push'
/tmp/ccgdYNmk.s:16: Error: suffix or operands invalid for `push'
/tmp/ccgdYNmk.s:19: Error: suffix or operands invalid for `pop'
/tmp/ccgdYNmk.s:20: Error: suffix or operands invalid for `pop'
/tmp/ccgdYNmk.s:28: Error: suffix or operands invalid for `push'
/tmp/ccgdYNmk.s:53: Error: suffix or operands invalid for `push'

Googling for a moment gave an answer - this problem is related to 32-bit assembler not being compatible with 64bit assembler. So I figured out that maybe I should remove glibc-devel-32bit. This led me back to error :


g++ main.cpp
In file included from /usr/include/features.h:354,
                 from /usr/include/c++/4.3/i586-suse-linux/bits/os_defines.h:44,
                 from /usr/include/c++/4.3/i586-suse-linux/bits/c++config.h:40,
                 from /usr/include/c++/4.3/iostream:44,
                 from main.cpp:1:
/usr/include/gnu/stubs.h:7:27: error: gnu/stubs-32.h: Nie ma takiego pliku ani katalogu

Finally I figured out that somehow (and I’ve got no idea why) two packages - gcc and cpp43 - are i586 architecture instead of x86_64 (other, like gcc-c++, were x86_64 architecture). I switched these two packages to 64bit arch and everything seems to work OK.

SOLVED

Hi
That’s a real gotcha! glad you figured it out and all is calm in your
openSuSE world :slight_smile:


Cheers Malcolm °¿° (Linux Counter #276890)
openSUSE 11.1 (i586) Kernel 2.6.27.21-0.1-pae
up 1 day 4:52, 2 users, load average: 0.10, 0.13, 0.16
ASUS eeePC 1000HE ATOM N280 1.66GHz | GPU Mobile 945GM/GMS/GME

Hi

I had the same problem and finally resolved it by installing another java version. I just did it using synaptic, restart the eclipse and compile again. It worked.

My problem was also with helloWorld.cpp and I had the same output than you.

Best,

Angela