Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Rainer Weikusat Newsgroups: comp.os.linux.development.apps Subject: Re: Compilation order Date: Fri, 27 May 2011 14:31:14 +0100 Lines: 19 Message-ID: <87zkm81d99.fsf@sapphire.mobileactivedefense.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: individual.net uJFChDdVBLRifd6eTtL1OAoJ7De+LjDOB3kesU3Q5haRB+KvQ= Cancel-Lock: sha1:U0Pe5NZjN41Pi5jwLmhIzsBRxuc= sha1:aAOC8xoKsuU6HKjInJaTRFhSo6I= User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux) Xref: x330-a1.tempe.blueboxinc.net comp.os.linux.development.apps:118 David Brown writes: > On 27/05/2011 08:06, wij@seed.net.tw wrote: >> Hi: >> I have a program to update on Fedora 15(g++ version 4.6.0), but >> the compiled executable is wrong. Let me make an example. I had >> 2 files t1.cpp t2.cpp, t1 contains the main function. If I issue >> command "g++ t1.cpp t2.o". A static array in t2.o is not initialized. >> The command "g++ t2.o t1.cpp" solves the problem. But on earlier >> versions of g++, the same problem happened. In all, with g++ 4.6.0 >> I should use g++ t2.o t1.cpp, with earlier versions I should use >> g++ t1.cpp t2.o. What is the problem and how should I fix it? >> Thanks in advance. > > Don't call g++ directly - always use "gcc", and let it call the > required linker or compiler programs as needed. That's wrong. g++ is the name of the gcc frontend for C++ and it is supposed to provide default values that 'work' for this language. It is not one of the backends (that would be cc1plus in this case).