www.delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2025/05/23/09:31:13

DMARC-Filter: OpenDMARC Filter v1.4.2 delorie.com 54NDVDpV1045936
Authentication-Results: delorie.com; dmarc=pass (p=none dis=none) header.from=cygwin.com
Authentication-Results: delorie.com; spf=pass smtp.mailfrom=cygwin.com
DKIM-Filter: OpenDKIM Filter v2.11.0 delorie.com 54NDVDpV1045936
X-Recipient: archive-cygwin AT delorie DOT com
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 70D70385B50C
ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 70D70385B50C
ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1748007057; cv=none;
b=dPxL8uv8a56mPDnjbZLsx37t3UvfcFXHU9tg7vMi+mJxkVT2Jm1UIlrZXb3CvPTyO4XVZPIr32Zt1Ex4BL710XQETpZ/upfQyfzJILdQS/4MwRN4tLEg+5AIyqsdVsGk9EECavfz87o2nPq2pWd7tD9l4vH2IF/Vc3uBfaYEqn4=
ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key;
t=1748007057; c=relaxed/simple;
bh=z6UtvK/wiMnyU1nRaJhRvFxsY00toqtI6LHEL653YkI=;
h=DKIM-Signature:Message-ID:Date:MIME-Version:To:From:Subject;
b=YDuyrLsQ1d3c3KeyUVYmATXEI+T/HqQiKagxtGwqqPvfrncK+JA0aACr/HJ7H3HyQg3e/riDBFaWjEq8/ST8baZYvkxliAHgHwDYI3Zp6wba1PvaTeTGhhMfCyFmF0Jtzud2eatLfOvXoQhJgn91McZ1EgQjmLnjxlHakU4PrB4=
ARC-Authentication-Results: i=1; server2.sourceware.org
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 70D70385B50C
X-Authority-Analysis: v=2.4 cv=G5caEck5 c=1 sm=1 tr=0 ts=6830788f
a=qUfFRToiTI0hwv9vP0yqsA==:117 a=qUfFRToiTI0hwv9vP0yqsA==:17
a=IkcTkHD0fZMA:10 a=dt9VzEwgFbYA:10 a=UXp7rZ135JgA:10
a=9xwAxv0TNgKg_r5PMHIA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10
a=x3vGyVeL1kjphkeRFRfl:22
Message-ID: <e07d3263-f629-4276-b7a8-d977b092d24f@slipbits.com>
Date: Fri, 23 May 2025 06:30:54 -0700
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
To: cygwin AT cygwin DOT com
Subject: gcc links to libcmain when generating a dll
X-Antivirus: Norton (VPS 250523-2, 5/23/2025), Outbound message
X-Antivirus-Status: Clean
X-AntiAbuse: This header was added to track abuse,
please include it with any abuse report
X-AntiAbuse: Primary Hostname - box5707.bluehost.com
X-AntiAbuse: Original Domain - cygwin.com
X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12]
X-AntiAbuse: Sender Address Domain - slipbits.com
X-BWhitelist: no
X-Source-IP: 70.187.149.156
X-Source-L: No
X-Exim-ID: 1uISUB-00000001xOj-03WT
X-Source:
X-Source-Args:
X-Source-Dir:
X-Source-Sender: ip70-187-149-156.oc.oc.cox.net ([192.168.1.7])
[70.187.149.156]:62742
X-Source-Auth: home AT slipbits DOT com
X-Email-Count: 2
X-Org: HG=bhshared;ORG=bluehost;
X-Source-Cap: c2xpcGJpdHM7c2xpcGJpdHM7Ym94NTcwNy5ibHVlaG9zdC5jb20=
X-Local-Domain: yes
X-CMAE-Envelope: MS4xfBhPx8QStIOQyQmuYRTwvOM9GCfLvVBIScDAbGxx+hT2lGgOn4IIpsDscAHlx/sqG+gsHWFFf/hbVQudZiZvDyM+FE01Fp2Jx7lvA9scQz/XFdRlrW91
Z1w3KS3dQjc7QqguGa1iVeOqpd3G4uEcPiFvWzzR58KGsK9H6Empagzl2u32WE1vwGUEL7eOQcxucsTExgO44miY/5nJKpFc+QU=
X-BeenThere: cygwin AT cygwin DOT com
X-Mailman-Version: 2.1.30
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-request AT cygwin DOT com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=subscribe>
From: skidmarks via Cygwin <cygwin AT cygwin DOT com>
Reply-To: skidmarks <home AT slipbits DOT com>
Sender: "Cygwin" <cygwin-bounces~archive-cygwin=delorie DOT com AT cygwin DOT com>
X-MIME-Autoconverted: from base64 to 8bit by delorie.com id 54NDVDpV1045936

 > On 2025-05-22 12:37, Arthur Schwarz via Cygwin wrote:
 > > I can't figure this one out.
 > >
 > >  > clear;g++ -flinker-output=dyn -o slip.dll *.o
 > >
 > > generates:
 > >
 > > 
/usr/lib/gcc/x86_64-pc-cygwin/12/../../../../x86_64-pc-cygwin/bin/ld: 
/usr/lib/
 > > gcc/x86_64-pc-cygwin/12/../../../../lib/libcygwin.a(libcmain.o): in 
function
 > > `main':
 > > /usr/src/debug/cygwin-3.6.1-1/winsup/cygwin/lib/libcmain.c:37:
 > > (.text.startup+0x79): undefined reference to `WinMain'
 > > collect2: error: ld returned 1 exit status
 > >
 > > But I am developing a dll, not a windows application. The gcc.pdf 
manual says:
 > >
 > >     -flinker-output=type
 > >     This option controls code generation of the link-time optimizer. By
 > >     default the
 > >     linker output is automatically determined by the linker plugin. For
 > >     debugging
 > >     the compiler and if incremental linking with a non-LTO object file
 > >     is desired,
 > >     it may be useful to control the type manually.
 > >
 > >     If type is ‘dyn’, code generation produces a shared library. In 
this
 > >     case ‘-fpic’
 > >     or ‘-fPIC’ is preserved, but not enabled automatically. This allows
 > >     to build
 > >     shared libraries without position-independent code on architectures
 > >     where this
 > >     is possible, i.e. on x86.
 > >
 > > My code is not executable and nowhere links to or uses any Windows 
code. It does
 > > not have a WinMain method and there is no link to libcmain.o in the 
object
 > > folder (*.o does not have libcmain.o).
 > >
 > > How do I get rid of this link error?

 > On 2025-05-22 19:19:46 Brian Inglis via Cygwin wrote:
 >
 > Tell the linker (ld/gcc/g++) not the LTO code generator!
 > If your "code" is not executable (data?) then LTO is irrelevant.
 >
 > Please note:
 >
 > $ info gcc flinker-output | tail -8
 > ---------- Footnotes ----------
 >
 > (1) On some systems, ‘gcc -shared’ needs to build supplementary stub
 > code for constructors to work.
 > On multi-libbed systems, ‘gcc -shared’ must select the correct 
support libraries
 > to link against.
 > *Failing to supply the correct flags may lead to subtle defects.*
 > Supplying them in cases where they are not necessary is innocuous.
 >
 > A couple of examples from cygport scripts:
 >
 > $ grep -iA3 'CC.*-shared' **/*.cygport
 > expect.cygport:    cygmake SHLIB_LD='$(CC) -shared -Wl,--out-implib,$@.a'
 > --
 > libvpx.cygport:    $CC -shared -fpic -o cygvpx-$ABI.dll            \
 > libvpx.cygport-        -Wl,--out-implib,libvpx.dll.a \
 > libvpx.cygport- -Wl,--whole-archive,libvpx.a,--no-whole-archive    \
 > libvpx.cygport-        -Wl,--version-script,$EXPORT_FILE
 >
 > Your program will need to link with the implib.
 >
 > --
 > Take care. Thanks, Brian Inglis              Calgary, Alberta, Canada
 >
 > La perfection est atteinte                   Perfection is achieved
 > non pas lorsqu'il n'y a plus rien à ajouter  not when there is no 
more to add
 > mais lorsqu'il n'y a plus rien à retrancher  but when there is no 
more to cut
 >                                  -- Antoine de Saint-Exupéry

Thanks!

 > g++ -shared -flinker-output=dyn -o slip.dll *.o

ran with not errors.

Is there any documentation available on cygwin specific issues? This 
seems like
a question that I should be able to answer on my own. One residual 
question that
a cygwin specific manual may answer is why libcmain.a was included at all.

art

-- 
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019