• Willkommen im Linux Club - dem deutschsprachigen Supportforum für GNU/Linux. Registriere dich kostenlos, um alle Inhalte zu sehen und Fragen zu stellen.

Problem beim compilieren mit g++

Cristobal

Newbie
Hallo!

Bin Anfänger in C++ und wollte folgendes, äußerst einfaches Programm,
mit g++ comilieren.

#include <iostream>

using namespace std;

int main (void)

{
cout << "Hallo";
return 0;

}

Die Eingabe" g++ test.cpp " erzeugt folgende Fehlermeldungen:

/tmp/ccq55X2Z.s: Assembler messages:
/tmp/ccq55X2Z.s:10: Error: suffix or operands invalid for `push'
/tmp/ccq55X2Z.s:38: Error: suffix or operands invalid for `push'
/tmp/ccq55X2Z.s:55: Error: suffix or operands invalid for `push'
/tmp/ccq55X2Z.s:79: Error: suffix or operands invalid for `push'
/tmp/ccq55X2Z.s:81: Error: suffix or operands invalid for `push'
/tmp/ccq55X2Z.s:85: Error: suffix or operands invalid for `push'
/tmp/ccq55X2Z.s:94: Error: suffix or operands invalid for `pop'
/tmp/ccq55X2Z.s:95: Error: suffix or operands invalid for `pop'

Habe schon relativ viel Zeit damit verbracht, komme aber einfach auf
keine Lösung.
Wahrscheinlich ist die Sache ganz einfach.

Wäre echt nett wenn ihr mir helfen könntet!
Danke auf jeden Fall schon mal für die Mühe

Cristobal
 

abgdf

Guru
Schreib doch code bitte in [/code]-tags.
Ansonsten: Dein Code scheint ok zu sein, muß irgendwie mit dem Compiler zusammenhängen.

Code:
#include <iostream>

using namespace std;

int main(void)
{
    cout << "Hallo";
    return 0;
}

Also, bei mir kompiliert's.

Gruß
 
OP
C

Cristobal

Newbie
Hmmm, dachte ich mir eigentlich auch schon, d.h. dachte eigentlich, daß
es irgendwie mit der 64bit Architektur zusammenhängt.
Habe dann dem Rechner mit
Code:
linux32 bash
eine 32bit Architektur vorgegaukelt, hat aber auch nichts gebracht.
Finde die Fehlermeldungen auch irgendwie merkwürdig.
 
Paste doch mal die Datei test.s, die erstellt wird (in ein Pastebin).
Code:
g++ -S test.cpp
Und dann hätten wir noch gerne die Ausgabe von...
Code:
uname -a
gcc -v
 
OP
C

Cristobal

Newbie
Hallo!

Also gut
Code:
g++ -S test.cpp
ergibt
Code:
	.file	"test.cpp"
	.section	.ctors,"aw",@progbits
	.align 4
	.long	_GLOBAL__I_main
	.text
	.align 2
	.type	_Z41__static_initialization_and_destruction_0ii, @function
_Z41__static_initialization_and_destruction_0ii:
.LFB1408:
	pushl	%ebp
.LCFI0:
	movl	%esp, %ebp
.LCFI1:
	subl	$24, %esp
.LCFI2:
	movl	%eax, -4(%ebp)
	movl	%edx, -8(%ebp)
	cmpl	$1, -4(%ebp)
	jne	.L5
	cmpl	$65535, -8(%ebp)
	jne	.L5
	movl	$_ZSt8__ioinit, (%esp)
	call	_ZNSt8ios_base4InitC1Ev
	movl	$__dso_handle, 8(%esp)
	movl	$0, 4(%esp)
	movl	$__tcf_0, (%esp)
	call	__cxa_atexit
.L5:
	leave
	ret
.LFE1408:
	.size	_Z41__static_initialization_and_destruction_0ii, .-_Z41__static_initialization_and_destruction_0ii
.globl __gxx_personality_v0
	.align 2
	.type	_GLOBAL__I_main, @function
_GLOBAL__I_main:
.LFB1410:
	pushl	%ebp
.LCFI3:
	movl	%esp, %ebp
.LCFI4:
	subl	$8, %esp
.LCFI5:
	movl	$65535, %edx
	movl	$1, %eax
	call	_Z41__static_initialization_and_destruction_0ii
	leave
	ret
.LFE1410:
	.size	_GLOBAL__I_main, .-_GLOBAL__I_main
	.align 2
	.type	__tcf_0, @function
__tcf_0:
.LFB1409:
	pushl	%ebp
.LCFI6:
	movl	%esp, %ebp
.LCFI7:
	subl	$8, %esp
.LCFI8:
	movl	$_ZSt8__ioinit, (%esp)
	call	_ZNSt8ios_base4InitD1Ev
	leave
	ret
.LFE1409:
	.size	__tcf_0, .-__tcf_0
	.section	.rodata
.LC0:
	.string	"Hallo"
	.text
	.align 2
.globl main
	.type	main, @function
main:
.LFB1401:
	leal	4(%esp), %ecx
.LCFI9:
	andl	$-16, %esp
	pushl	-4(%ecx)
.LCFI10:
	pushl	%ebp
.LCFI11:
	movl	%esp, %ebp
.LCFI12:
	pushl	%ecx
.LCFI13:
	subl	$20, %esp
.LCFI14:
	movl	$.LC0, 4(%esp)
	movl	$_ZSt4cout, (%esp)
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movl	$0, %eax
	addl	$20, %esp
	popl	%ecx
	popl	%ebp
	leal	-4(%ecx), %esp
	ret
.LFE1401:
	.size	main, .-main
	.local	_ZSt8__ioinit
	.comm	_ZSt8__ioinit,1,1
	.weakref	_Z20__gthrw_pthread_oncePiPFvvE,pthread_once
	.weakref	_Z27__gthrw_pthread_getspecificj,pthread_getspecific
	.weakref	_Z27__gthrw_pthread_setspecificjPKv,pthread_setspecific
	.weakref	_Z22__gthrw_pthread_createPmPK14pthread_attr_tPFPvS3_ES3_,pthread_create
	.weakref	_Z22__gthrw_pthread_cancelm,pthread_cancel
	.weakref	_Z26__gthrw_pthread_mutex_lockP15pthread_mutex_t,pthread_mutex_lock
	.weakref	_Z29__gthrw_pthread_mutex_trylockP15pthread_mutex_t,pthread_mutex_trylock
	.weakref	_Z28__gthrw_pthread_mutex_unlockP15pthread_mutex_t,pthread_mutex_unlock
	.weakref	_Z26__gthrw_pthread_mutex_initP15pthread_mutex_tPK19pthread_mutexattr_t,pthread_mutex_init
	.weakref	_Z26__gthrw_pthread_key_createPjPFvPvE,pthread_key_create
	.weakref	_Z26__gthrw_pthread_key_deletej,pthread_key_delete
	.weakref	_Z30__gthrw_pthread_mutexattr_initP19pthread_mutexattr_t,pthread_mutexattr_init
	.weakref	_Z33__gthrw_pthread_mutexattr_settypeP19pthread_mutexattr_ti,pthread_mutexattr_settype
	.weakref	_Z33__gthrw_pthread_mutexattr_destroyP19pthread_mutexattr_t,pthread_mutexattr_destroy
	.section	.eh_frame,"a",@progbits
.Lframe1:
	.long	.LECIE1-.LSCIE1
.LSCIE1:
	.long	0x0
	.byte	0x1
	.string	"zP"
	.uleb128 0x1
	.sleb128 -4
	.byte	0x8
	.uleb128 0x5
	.byte	0x0
	.long	__gxx_personality_v0
	.byte	0xc
	.uleb128 0x4
	.uleb128 0x4
	.byte	0x88
	.uleb128 0x1
	.align 4
.LECIE1:
.LSFDE1:
	.long	.LEFDE1-.LASFDE1
.LASFDE1:
	.long	.LASFDE1-.Lframe1
	.long	.LFB1408
	.long	.LFE1408-.LFB1408
	.uleb128 0x0
	.byte	0x4
	.long	.LCFI0-.LFB1408
	.byte	0xe
	.uleb128 0x8
	.byte	0x85
	.uleb128 0x2
	.byte	0x4
	.long	.LCFI1-.LCFI0
	.byte	0xd
	.uleb128 0x5
	.align 4
.LEFDE1:
.LSFDE3:
	.long	.LEFDE3-.LASFDE3
.LASFDE3:
	.long	.LASFDE3-.Lframe1
	.long	.LFB1410
	.long	.LFE1410-.LFB1410
	.uleb128 0x0
	.byte	0x4
	.long	.LCFI3-.LFB1410
	.byte	0xe
	.uleb128 0x8
	.byte	0x85
	.uleb128 0x2
	.byte	0x4
	.long	.LCFI4-.LCFI3
	.byte	0xd
	.uleb128 0x5
	.align 4
.LEFDE3:
.LSFDE5:
	.long	.LEFDE5-.LASFDE5
.LASFDE5:
	.long	.LASFDE5-.Lframe1
	.long	.LFB1409
	.long	.LFE1409-.LFB1409
	.uleb128 0x0
	.byte	0x4
	.long	.LCFI6-.LFB1409
	.byte	0xe
	.uleb128 0x8
	.byte	0x85
	.uleb128 0x2
	.byte	0x4
	.long	.LCFI7-.LCFI6
	.byte	0xd
	.uleb128 0x5
	.align 4
.LEFDE5:
.LSFDE7:
	.long	.LEFDE7-.LASFDE7
.LASFDE7:
	.long	.LASFDE7-.Lframe1
	.long	.LFB1401
	.long	.LFE1401-.LFB1401
	.uleb128 0x0
	.byte	0x4
	.long	.LCFI9-.LFB1401
	.byte	0xc
	.uleb128 0x1
	.uleb128 0x0
	.byte	0x9
	.uleb128 0x4
	.uleb128 0x1
	.byte	0x4
	.long	.LCFI10-.LCFI9
	.byte	0xc
	.uleb128 0x4
	.uleb128 0x4
	.byte	0x4
	.long	.LCFI11-.LCFI10
	.byte	0xe
	.uleb128 0x8
	.byte	0x85
	.uleb128 0x2
	.byte	0x4
	.long	.LCFI12-.LCFI11
	.byte	0xd
	.uleb128 0x5
	.byte	0x4
	.long	.LCFI13-.LCFI12
	.byte	0x84
	.uleb128 0x3
	.align 4
.LEFDE7:
	.ident	"GCC: (GNU) 4.1.2 20061115 (prerelease) (SUSE Linux)"
	.section	.note.GNU-stack,"",@progbits
und
Code:
uname -a
bringt:
Code:
Linux linux-tnoe 2.6.18.2-34-default #1 SMP Mon Nov 27 11:46:27 UTC 2006 x86_64 x86_64 x86_64 GNU/Linux
Code:
gcc -v
bringt als Ausgabe:
Code:
Using built-in specs.
Target: i586-suse-linux
Configured with: ../configure --enable-threads=posix --prefix=/usr --with-local-prefix=/usr/local --infodir=/usr/share/info --mandir=/usr/share/man --libdir=/usr/lib --libexecdir=/usr/lib --enable-languages=c,c++,objc,fortran,obj-c++,java,ada --enable-checking=release --with-gxx-include-dir=/usr/include/c++/4.1.2 --enable-ssp --disable-libssp --disable-libgcj --with-slibdir=/lib --with-system-zlib --enable-shared --enable-__cxa_atexit --enable-libstdcxx-allocator=new --program-suffix=-4.1 --enable-version-specific-runtime-libs --without-system-libunwind --with-cpu=generic --host=i586-suse-linux
Thread model: posix
gcc version 4.1.2 20061115 (prerelease) (SUSE Linux)
l
Danke auf jeden Fall, daß Du dir die Sache ansiehst!
Gruß
Cristobal
 

Spasswolf

Member
Was dein g++ ausspuckt ist x86(32bit) Assembler Code. Du scheinst einen 32bit Compiler, aber einen 64bit Assembler installiert zu haben.
Kompilier das Programm mal so:
Code:
g++ -m64 test.cpp
 
OP
C

Cristobal

Newbie
Danke erst mal für die Info.
Code:
g++ -m64 test.cpp
bringt mirfolgende Ausgabe:
Code:
test.cpp:1: sorry, unimplemented: 64-bit mode not compiled in
Wahrscheinlich eine dumme Frage aber, was kann ich jetzt tun?

Gruß
Cristobal
 
Probier einfach mal...
Code:
g++ -S test.cpp
as --32 test.s
file test.o
da könnte tatsächlich eine 32-bit test.o rauskommen.
Ergo:
- 32-bit Compiler installiert
- Assembler der x86_64 als Default hat
 
Oben