X-Spam-Check-By: sourceware.org Message-ID: <45DB5F00.5050501@itn.liu.se> Date: Tue, 20 Feb 2007 21:50:08 +0100 From: Patric Ljung User-Agent: Thunderbird 1.5.0.9 (Windows/20061207) MIME-Version: 1.0 To: cygwin AT cygwin DOT com Subject: g++ 3.4.4: all global constructors in archive not called Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Dear cygwin readers, I have just ported an application from Linux to Cygwin. In one archive (.a) I have several global constructors, 2-3 in two .o files. When I run my program only one initializer function is called in that archive. Leaving the other uninitialized/uncalled. I have found this issue reported in 2002, but there is no solutions posted in response to this question. http://sourceware.org/ml/cygwin/2002-07/msg00447.html To verify this problem I created a simple class and made a local global instance. The class name and output string was slightly different in the other file. class a_very_local_t { public: a_very_local_t() { printf("arbfragprog.cc: very_local_t::constructor\n"); _info = 0; } private: int _info; }; static a_very_local_t a_local_instance_a; When the program is started I only get the output from one of the .o files (the first alphabetically). It appears to me a rather fundamental issue that should have been solved years ago. Have I missed to provide the compiler/linker/archiver with an appropriate flag? Thanks in advance for your help. best regards / Patric -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/