X-Spam-Check-By: sourceware.org From: "Dave Korn" To: Subject: RE: G77, libg2c and a linking problem Date: Fri, 15 Sep 2006 16:44:02 +0100 Message-ID: <005601c6d8dd$c4a41ee0$a501a8c0@CAM.ARTIMI.COM> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook 11 In-Reply-To: Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm Precedence: bulk List-Unsubscribe: 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 On 15 September 2006 14:05, Angelo Graziosi wrote: >> program hello >> implicit none >> write(*,*) 'Hello!' >> end >> $ g77 hello.F -o hello -L/usr/lib/gcc/i686-pc-cygwin/3.4.4 -lg2c >> /usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../libcygwin.a(libcmain.o):(.text+0xab ): >> undefined reference to `_WinMain AT 16' >> collect2: ld returned 1 exit status > 1) adding -s at the end works > $ g77 hello.F -o hello -L/usr/lib/gcc/i686-pc-cygwin/3.4.4 -lg2c -s > 2) but after hello.F, doesn't > > $ g77 hello.F -s -o hello -L/usr/lib/gcc/i686-pc-cygwin/3.4.4 -lg2c > /usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../libcygwin.a(libcmain.o):(.text+0xab ): > undefined reference to `_WinMain AT 16' > collect2: ld returned 1 exit status > 3) moving '-o hello' at the end works > > $ g77 hello.F -s -L/usr/lib/gcc/i686-pc-cygwin/3.4.4 -lg2c -o hello > 4) also moving -s works > > $ g77 hello.F -L/usr/lib/gcc/i686-pc-cygwin/3.4.4 -lg2c -s -o hello > 5) or removing it > > $ g77 hello.F -L/usr/lib/gcc/i686-pc-cygwin/3.4.4 -lg2c -o hello This is probably a consequence of that packaging error that you noticed: http://www.cygwin.com/ml/cygwin/2006-07/msg00619.html The problem (I suspect but have not yet proven) is that the g77 driver gets all the libs and objects in the correct order on the commandline, and tagging one on the end with -L/-l doesn't work because it's in the wrong place. Using your hello world testcase, I found that g77 hello.F -o hello "just works". You don't mention that you've tried this but I assume you did and it didn't work. So please try the fix I suggested in http://www.cygwin.com/ml/cygwin/2006-07/msg00620.html which moves the libs to the place where the compiler expects to find them, and means you don't need to worry about manually trying to add the library into the correct place on the command line. I expect that this should resolve the problem for you. cheers, DaveK -- Can't think of a witty .sigline today.... -- 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/