X-Recipient: archive-cygwin AT delorie DOT com X-SWARE-Spam-Status: No, hits=-2.2 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,RCVD_IN_DNSWL_LOW X-Spam-Check-By: sourceware.org Message-ID: <4D4B0702.9090600@cwilson.fastmail.fm> Date: Thu, 03 Feb 2011 14:50:26 -0500 From: Charles Wilson Reply-To: Charles Wilson User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.9.2.13) Gecko/20101207 Thunderbird/3.1.7 MIME-Version: 1.0 To: cygwin AT cygwin DOT com Subject: Re: -static not working with gcc 4.3.4 References: <20101017005857 DOT GA28900 AT const DOT famille DOT thibault DOT fr> <2BF01EB27B56CC478AD6E5A0A28931F201762C09 AT A1DAL1SWPES19MB DOT ams DOT acs-inc DOT net> <20101018125833 DOT GB25504 AT const> <252576 DOT 94771 DOT qm AT web25508 DOT mail DOT ukl DOT yahoo DOT com> <20101018213923 DOT GO6369 AT const DOT famille DOT thibault DOT fr> <30838541 DOT post AT talk DOT nabble DOT com> In-Reply-To: <30838541.post@talk.nabble.com> Content-Type: text/plain; charset=UTF-8 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 On 2/3/2011 2:34 PM, gvidaver wrote: > It still requires the cygwin1.dll: > > $ g++ -v > ... > gcc version 4.5.0 (GCC) > > $ g++ test.c -o test -static > > $ ldd test.exe > ... > cygwin1.dll => /usr/bin/cygwin1.dll (0x61000000) > ... Uhm, yes. The cygwin-provided gcc is a cygwin compiler, intended for generating cygwin DLLs and executables. Thus, all dlls and exes it generates will require the cygwin1.dll (since there is not now, and will not be, any "static version" of cygwin1.dll). Older cygwin gcc's had a controversial mode "-mno-cygwin" that, basically, turned the cygwin gcc into a buggy version of the mingw gcc. It often had "cygwin pollution" problems, and many people misunderstood the purpose of the flag. So, it has been deprecated for about five years now, and was finally removed with the release of cygwin's gcc-4.3.4. > And apparently the only alternative is mingw, see: > > http://cygwin.com/faq/faq-nochunks.html#faq.programming.static-linking > "it is not possible to statically link with a Cygwin library to obtain an > independent, self-contained executable. " > > $ i686-w64-mingw32-g++ -v > ... > gcc version 4.5.1 (GCC) > > $ i686-w64-mingw32-g++ test.c -o test -static > > $ ldd test.exe > ntdll.dll => ... path to Windows dlls > kernel32.dll => ... > KERNELBASE.dll => ... > msvcrt.dll => ... > > (I.e. no dependencies on anything besides system dlls.) Right, but on the "cygwin system", the cygwin1.dll IS a system dll (as are cyggcc_s-1.dll, cygstdc++-6.dll, and the other "language" runtime libraries). All -static does is force the compiler to attempt to link statically to OTHER user libs that you'd pass on the link command, like -lintl -lz -ljpeg etc. You can, in SOME cases, avoid a shared dependency on the *language* runtimes (for C and C++ alone) by using the -static-libgcc and/or -static-libstdc++, but...there are complexities with that. However, using the cygwin compiler, you cannot (*) avoid a dependency on the cygwin runtime cygwin1.dll. This is not a bug; it is part of the design. Now, the OP in this thread posted a problem with -static related to the language runtime library for C (gcc_s aka cyggcc_s-1.dll) but that's a whole different issue that your attempt to avoid cygwin1.dll. (*) OK, sure, you can use -nostdlib but...I guarantee you won't like the results. It just won't work, and you'd be better off simply using the mingw compiler instead (or one of cygwin's mingw-target cross compilers). -- Chuck -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple