Rocksolid Light

Welcome to Rocksolid Light

mail  files  register  newsreader  groups  login

Message-ID:  

TRANSACTION CANCELLED - FARECARD RETURNED


devel / comp.os.ms-windows.programmer.win32 / MinGW - some APIs are undefined for console programs

SubjectAuthor
* MinGW - some APIs are undefined for console programsCharlie Gibbs
+* MinGW - some APIs are undefined for console programsJJ
|`- MinGW - some APIs are undefined for console programsCharlie Gibbs
`* MinGW - some APIs are undefined for console programsElChino
 `- MinGW - some APIs are undefined for console programsCharlie Gibbs

1
MinGW - some APIs are undefined for console programs

<dqBgK.60141$qMI1.48013@fx96.iad>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=1042&group=comp.os.ms-windows.programmer.win32#1042

  copy link   Newsgroups: comp.os.ms-windows.programmer.win32
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!news.uzoreto.com!news-out.netnews.com!news.alt.net!fdc2.netnews.com!feeder1.feed.usenet.farm!feed.usenet.farm!peer03.ams4!peer.am4.highwinds-media.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx96.iad.POSTED!not-for-mail
Newsgroups: comp.os.ms-windows.programmer.win32
From: cgibbs@kltpzyxm.invalid (Charlie Gibbs)
Subject: MinGW - some APIs are undefined for console programs
User-Agent: slrn/1.0.3 (Linux)
Lines: 59
Message-ID: <dqBgK.60141$qMI1.48013@fx96.iad>
X-Complaints-To: https://www.astraweb.com/aup
NNTP-Posting-Date: Mon, 16 May 2022 23:49:29 UTC
Date: Mon, 16 May 2022 23:49:29 GMT
X-Received-Bytes: 4317
 by: Charlie Gibbs - Mon, 16 May 2022 23:49 UTC

Are there any MinGW gurus out there? Or is there a better place
to ask these questions?

I wrote a suite of programs years ago; I've been compiling
the Win32 versions (a mix of console and GUI programs) with
Borland C++ Builder. I'd like to switch to MinGW so I can
use a more modern, advanced compiler. (I've been compiling
Linux versions of these programs under gcc 8.)

My ultimate goal is to build the latest version of OpenSSL, 3.0.2
(which probably can't be done with the Borland compiler), and link it
with the programs in my suite which support SSL. Ditto for LibSSH2.
OpenSSL comes with build instructions for MinGW.

I've installed MinGW and have successfully compiled and run small
test programs, both console and GUI. So far, though, I've not
succeeded in getting my suite to compile (although a few of the
simplest programs, both console and GUI, do compile and run).
The program I'm currently trying to compile is a console program
which comes up with the following messages:

gcc -c revdate.c
gcc -DWIN32 -DMINGW -Wall -Wno-format-overflow -c adjcost.c
gcc -Wall -Wl,--allow-multiple-definition -o MinGW/adjcost.exe adjcost.o revdate.o MinGW/genesis.a
c:/Strawberry/c/bin/../lib/gcc/i686-w64-mingw32/8.3.0/../../../../i686-w64-mingw32/bin/ld.exe: MinGW/genesis.a(gensubs.o):gensubs.c:(.text+0x4aea): undefined reference to `_imp__GetTextExtentPoint32A@16'
c:/Strawberry/c/bin/../lib/gcc/i686-w64-mingw32/8.3.0/../../../../i686-w64-mingw32/bin/ld.exe: MinGW/genesis.a(gensubs.o):gensubs.c:(.text+0x580a): undefined reference to `_imp__TextOutA@20'
c:/Strawberry/c/bin/../lib/gcc/i686-w64-mingw32/8.3.0/../../../../i686-w64-mingw32/bin/ld.exe: MinGW/genesis.a(gensubs.o):gensubs.c:(.text+0x5836): undefined reference to `_imp__GetTextMetricsA@8'
c:/Strawberry/c/bin/../lib/gcc/i686-w64-mingw32/8.3.0/../../../../i686-w64-mingw32/bin/ld.exe: MinGW/genesis.a(gensubs.o):gensubs.c:(.text+0x592c): undefined reference to `_imp__GetDeviceCaps@8'
c:/Strawberry/c/bin/../lib/gcc/i686-w64-mingw32/8.3.0/../../../../i686-w64-mingw32/bin/ld.exe: MinGW/genesis.a(gensubs.o):gensubs.c:(.text+0x5a57): undefined reference to `_imp__TextOutA@20'
c:/Strawberry/c/bin/../lib/gcc/i686-w64-mingw32/8.3.0/../../../../i686-w64-mingw32/bin/ld.exe: MinGW/genesis.a(gensubs.o):gensubs.c:(.text+0x6e11): undefined reference to `_imp__GetTextMetricsA@8'
collect2.exe: error: ld returned 1 exit status
make: *** [MinGW/adjcost.exe] Error 1

Yes, I know that these APIs are normally only used in GUI programs,
but they're a part of a private library I link with all my programs,
GUI or console. The Borland compiler handles this with no complaints.
If I add the -mwindows parameter to the gcc calls, the error messages
disappear. But I want a console program, not a GUI program; besides,
for GUI programs compiled with MinGW, printf() doesn't print anything.

There are other problems (see the -Wl,--allow-multiple-definition
parameter above), but getting rid of the error messages above seems
like a good place to start.

Is there a good source of documentation for building Windows programs
with MinGW? I've searched high and low, but when it comes down to the
nitty-gritty I've found little information, especially on the magical
incantations to include needed libraries (e.g. -lws2_32 for sockets,
something I only found out from back-handed references in various
discussion groups).

If anyone can help, or point me to a better newsgroup, web site,
or documentation source, I'd really appreciate it.

--
/~\ Charlie Gibbs | Life is perverse.
\ / <cgibbs@kltpzyxm.invalid> | It can be beautiful...
X I'm really at ac.dekanfrus | but it won't.
/ \ if you read it the right way. | -- Lily Tomlin

Re: MinGW - some APIs are undefined for console programs

<7ody1il527am$.u6ukdjm8gt5y.dlg@40tude.net>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=1043&group=comp.os.ms-windows.programmer.win32#1043

  copy link   Newsgroups: comp.os.ms-windows.programmer.win32
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: jj4public@gmx.com (JJ)
Newsgroups: comp.os.ms-windows.programmer.win32
Subject: Re: MinGW - some APIs are undefined for console programs
Date: Wed, 18 May 2022 07:01:22 +0700
Organization: A noiseless patient Spider
Lines: 60
Message-ID: <7ody1il527am$.u6ukdjm8gt5y.dlg@40tude.net>
References: <dqBgK.60141$qMI1.48013@fx96.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Injection-Info: reader02.eternal-september.org; posting-host="c341660e242daf82d934a9ec873667ad";
logging-data="22023"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/LJ7ESRS7cWR931tWMhNTum4Sty8oICJY="
User-Agent: 40tude_Dialog/2.0.15.84
Cancel-Lock: sha1:fWTWjDxwBXpSLMvYTpQ4bBwE5yU=
X-Bitcoin: 1LcqwCQBQmhcWfWsVEAeyLchkAY8ZfuMnS
X-Face: \*\`0(1j~VfYC>ebz[&O.]=,Nm\oRM{of,liRO#7Eqi4|!]!(Gs=Akgh{J)605>C9Air?pa d{sSZ09u+A7f<^paR"/NH_#<mE1S"hde\c6PZLUB[t/s5-+Iu5DSc?P0+4%,Hl
 by: JJ - Wed, 18 May 2022 00:01 UTC

On Mon, 16 May 2022 23:49:29 GMT, Charlie Gibbs wrote:
> Are there any MinGW gurus out there? Or is there a better place
> to ask these questions?
>
> I wrote a suite of programs years ago; I've been compiling
> the Win32 versions (a mix of console and GUI programs) with
> Borland C++ Builder. I'd like to switch to MinGW so I can
> use a more modern, advanced compiler. (I've been compiling
> Linux versions of these programs under gcc 8.)
>
> My ultimate goal is to build the latest version of OpenSSL, 3.0.2
> (which probably can't be done with the Borland compiler), and link it
> with the programs in my suite which support SSL. Ditto for LibSSH2.
> OpenSSL comes with build instructions for MinGW.
>
> I've installed MinGW and have successfully compiled and run small
> test programs, both console and GUI. So far, though, I've not
> succeeded in getting my suite to compile (although a few of the
> simplest programs, both console and GUI, do compile and run).
> The program I'm currently trying to compile is a console program
> which comes up with the following messages:
>
> gcc -c revdate.c
> gcc -DWIN32 -DMINGW -Wall -Wno-format-overflow -c adjcost.c
> gcc -Wall -Wl,--allow-multiple-definition -o MinGW/adjcost.exe adjcost.o revdate.o MinGW/genesis.a
> c:/Strawberry/c/bin/../lib/gcc/i686-w64-mingw32/8.3.0/../../../../i686-w64-mingw32/bin/ld.exe: MinGW/genesis.a(gensubs.o):gensubs.c:(.text+0x4aea): undefined reference to `_imp__GetTextExtentPoint32A@16'
> c:/Strawberry/c/bin/../lib/gcc/i686-w64-mingw32/8.3.0/../../../../i686-w64-mingw32/bin/ld.exe: MinGW/genesis.a(gensubs.o):gensubs.c:(.text+0x580a): undefined reference to `_imp__TextOutA@20'
> c:/Strawberry/c/bin/../lib/gcc/i686-w64-mingw32/8.3.0/../../../../i686-w64-mingw32/bin/ld.exe: MinGW/genesis.a(gensubs.o):gensubs.c:(.text+0x5836): undefined reference to `_imp__GetTextMetricsA@8'
> c:/Strawberry/c/bin/../lib/gcc/i686-w64-mingw32/8.3.0/../../../../i686-w64-mingw32/bin/ld.exe: MinGW/genesis.a(gensubs.o):gensubs.c:(.text+0x592c): undefined reference to `_imp__GetDeviceCaps@8'
> c:/Strawberry/c/bin/../lib/gcc/i686-w64-mingw32/8.3.0/../../../../i686-w64-mingw32/bin/ld.exe: MinGW/genesis.a(gensubs.o):gensubs.c:(.text+0x5a57): undefined reference to `_imp__TextOutA@20'
> c:/Strawberry/c/bin/../lib/gcc/i686-w64-mingw32/8.3.0/../../../../i686-w64-mingw32/bin/ld.exe: MinGW/genesis.a(gensubs.o):gensubs.c:(.text+0x6e11): undefined reference to `_imp__GetTextMetricsA@8'
> collect2.exe: error: ld returned 1 exit status
> make: *** [MinGW/adjcost.exe] Error 1
>
> Yes, I know that these APIs are normally only used in GUI programs,
> but they're a part of a private library I link with all my programs,
> GUI or console. The Borland compiler handles this with no complaints.
> If I add the -mwindows parameter to the gcc calls, the error messages
> disappear. But I want a console program, not a GUI program; besides,
> for GUI programs compiled with MinGW, printf() doesn't print anything.
>
> There are other problems (see the -Wl,--allow-multiple-definition
> parameter above), but getting rid of the error messages above seems
> like a good place to start.
>
> Is there a good source of documentation for building Windows programs
> with MinGW? I've searched high and low, but when it comes down to the
> nitty-gritty I've found little information, especially on the magical
> incantations to include needed libraries (e.g. -lws2_32 for sockets,
> something I only found out from back-handed references in various
> discussion groups).
>
> If anyone can help, or point me to a better newsgroup, web site,
> or documentation source, I'd really appreciate it.

You're missing the Windows' DLL import libraries which are available from
Windows SDK. But I don't know if the LIB files from it, are usable by MingW,
cause its a *nix origin. If not, you'll need to manually create the import
library files from the DLLs. FYI, Borland C++ Builder works out of the box,
because it already include most of the import libraries.

Re: MinGW - some APIs are undefined for console programs

<e40hK.15171$zVe6.4021@fx43.iad>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=1044&group=comp.os.ms-windows.programmer.win32#1044

  copy link   Newsgroups: comp.os.ms-windows.programmer.win32
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx43.iad.POSTED!not-for-mail
Newsgroups: comp.os.ms-windows.programmer.win32
From: cgibbs@kltpzyxm.invalid (Charlie Gibbs)
Subject: Re: MinGW - some APIs are undefined for console programs
References: <dqBgK.60141$qMI1.48013@fx96.iad>
<7ody1il527am$.u6ukdjm8gt5y.dlg@40tude.net>
User-Agent: slrn/1.0.3 (Linux)
Lines: 38
Message-ID: <e40hK.15171$zVe6.4021@fx43.iad>
X-Complaints-To: https://www.astraweb.com/aup
NNTP-Posting-Date: Wed, 18 May 2022 06:09:14 UTC
Date: Wed, 18 May 2022 06:09:14 GMT
X-Received-Bytes: 2336
 by: Charlie Gibbs - Wed, 18 May 2022 06:09 UTC

On 2022-05-18, JJ <jj4public@gmx.com> wrote:

> On Mon, 16 May 2022 23:49:29 GMT, Charlie Gibbs wrote:

<snip>

>> I've installed MinGW and have successfully compiled and run small
>> test programs, both console and GUI. So far, though, I've not
>> succeeded in getting my suite to compile (although a few of the
>> simplest programs, both console and GUI, do compile and run).
>> The program I'm currently trying to compile is a console program
>> which comes up with the following messages:

<snip>

> You're missing the Windows' DLL import libraries which are available from
> Windows SDK. But I don't know if the LIB files from it, are usable by MingW,
> cause its a *nix origin. If not, you'll need to manually create the import
> library files from the DLLs. FYI, Borland C++ Builder works out of the box,
> because it already include most of the import libraries.

That sounds kind of familiar. I did once manage to build OpenSSL 1.0.1g
with the Borland compiler. I used Borland's implib utility to convert
the OpenSSL DLLs to library files that the Borland linker could use.
(I prefer to link statically.) What puzzles me in this case, though,
is that the error messages I mentioned in my original post disapper
if I include the -mwindows parameter; this suggests that the library
must be there, although -mwindows has other undesirable effects.

I can't find any documentation of the various -l parameters - the
one I did see mentioned, -lws2_32, brings in the socket libraries,
but that isn't too intuitive.

--
/~\ Charlie Gibbs | Microsoft is a dictatorship.
\ / <cgibbs@kltpzyxm.invalid> | Apple is a cult.
X I'm really at ac.dekanfrus | Linux is anarchy.
/ \ if you read it the right way. | Pick your poison.

Re: MinGW - some APIs are undefined for console programs

<t7i03t$7nh$2@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=1069&group=comp.os.ms-windows.programmer.win32#1069

  copy link   Newsgroups: comp.os.ms-windows.programmer.win32
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: elchino@cnn.cn (ElChino)
Newsgroups: comp.os.ms-windows.programmer.win32
Subject: Re: MinGW - some APIs are undefined for console programs
Date: Sun, 5 Jun 2022 12:21:49 +0200
Organization: A noiseless patient Spider
Lines: 15
Message-ID: <t7i03t$7nh$2@dont-email.me>
References: <dqBgK.60141$qMI1.48013@fx96.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 5 Jun 2022 10:21:49 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="c64887e061a9419017bb9c2aabd10519";
logging-data="7921"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+Pb8RWw9Lh1S3eEuFsm+6d"
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101
Thunderbird/60.9.0
Cancel-Lock: sha1:jhd3BTqu0ucvZ+JTY03qjBDhGtY=
In-Reply-To: <dqBgK.60141$qMI1.48013@fx96.iad>
Content-Language: nb-NO
X-Mozilla-News-Host: news://news.eternal-september.org
 by: ElChino - Sun, 5 Jun 2022 10:21 UTC

Charlie Gibbs wrote:

> gcc -c revdate.c
> gcc -DWIN32 -DMINGW -Wall -Wno-format-overflow -c adjcost.c
> gcc -Wall -Wl,--allow-multiple-definition -o MinGW/adjcost.exe adjcost.o revdate.o MinGW/genesis.a
> c:/Strawberry/c/bin/../lib/gcc/i686-w64-mingw32/8.3.0/../../../../i686-w64-mingw32/bin/ld.exe: MinGW/genesis.a(gensubs.o):gensubs.c:(.text+0x4aea): undefined reference to `_imp__GetTextExtentPoint32A@16'
> c:/Strawberry/c/bin/../lib/gcc/i686-w64-mingw32/8.3.0/../../../../i686-w64-mingw32/bin/ld.exe: MinGW/genesis.a(gensubs.o):gensubs.c:(.text+0x580a): undefined reference to `_imp__TextOutA@20'
> c:/Strawberry/c/bin/../lib/gcc/i686-w64-mingw32/8.3.0/../../../../i686-w64-mingw32/bin/ld.exe: MinGW/genesis.a(gensubs.o):gensubs.c:(.text+0x5836): undefined reference to `_imp__GetTextMetricsA@8'
> c:/Strawberry/c/bin/../lib/gcc/i686-w64-mingw32/8.3.0/../../../../i686-w64-mingw32/bin/ld.exe: MinGW/genesis.a(gensubs.o):gensubs.c:(.text+0x592c): undefined reference to `_imp__GetDeviceCaps@8'
> c:/Strawberry/c/bin/../lib/gcc/i686-w64-mingw32/8.3.0/../../../../i686-w64-mingw32/bin/ld.exe: MinGW/genesis.a(gensubs.o):gensubs.c:(.text+0x5a57): undefined reference to `_imp__TextOutA@20'
> c:/Strawberry/c/bin/../lib/gcc/i686-w64-mingw32/8.3.0/../../../../i686-w64-mingw32/bin/ld.exe: MinGW/genesis.a(gensubs.o):gensubs.c:(.text+0x6e11): undefined reference to `_imp__GetTextMetricsA@8'
> collect2.exe: error: ld returned 1 exit status
> make: *** [MinGW/adjcost.exe] Error 1

Easy, add '-lgdi32' to the link-command.

Re: MinGW - some APIs are undefined for console programs

<8F7nK.65113$ntj.3763@fx15.iad>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=1070&group=comp.os.ms-windows.programmer.win32#1070

  copy link   Newsgroups: comp.os.ms-windows.programmer.win32
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx15.iad.POSTED!not-for-mail
Newsgroups: comp.os.ms-windows.programmer.win32
From: cgibbs@kltpzyxm.invalid (Charlie Gibbs)
Subject: Re: MinGW - some APIs are undefined for console programs
References: <dqBgK.60141$qMI1.48013@fx96.iad> <t7i03t$7nh$2@dont-email.me>
User-Agent: slrn/1.0.3 (Linux)
Lines: 29
Message-ID: <8F7nK.65113$ntj.3763@fx15.iad>
X-Complaints-To: https://www.astraweb.com/aup
NNTP-Posting-Date: Sun, 05 Jun 2022 19:40:52 UTC
Date: Sun, 05 Jun 2022 19:40:52 GMT
X-Received-Bytes: 2616
 by: Charlie Gibbs - Sun, 5 Jun 2022 19:40 UTC

On 2022-06-05, ElChino <elchino@cnn.cn> wrote:

> Charlie Gibbs wrote:
>
>> gcc -c revdate.c
>> gcc -DWIN32 -DMINGW -Wall -Wno-format-overflow -c adjcost.c
>> gcc -Wall -Wl,--allow-multiple-definition -o MinGW/adjcost.exe adjcost.o revdate.o MinGW/genesis.a
>> c:/Strawberry/c/bin/../lib/gcc/i686-w64-mingw32/8.3.0/../../../../i686-w64-mingw32/bin/ld.exe: MinGW/genesis.a(gensubs.o):gensubs.c:(.text+0x4aea): undefined reference to `_imp__GetTextExtentPoint32A@16'
>> c:/Strawberry/c/bin/../lib/gcc/i686-w64-mingw32/8.3.0/../../../../i686-w64-mingw32/bin/ld.exe: MinGW/genesis.a(gensubs.o):gensubs.c:(.text+0x580a): undefined reference to `_imp__TextOutA@20'
>> c:/Strawberry/c/bin/../lib/gcc/i686-w64-mingw32/8.3.0/../../../../i686-w64-mingw32/bin/ld.exe: MinGW/genesis.a(gensubs.o):gensubs.c:(.text+0x5836): undefined reference to `_imp__GetTextMetricsA@8'
>> c:/Strawberry/c/bin/../lib/gcc/i686-w64-mingw32/8.3.0/../../../../i686-w64-mingw32/bin/ld.exe: MinGW/genesis.a(gensubs.o):gensubs.c:(.text+0x592c): undefined reference to `_imp__GetDeviceCaps@8'
>> c:/Strawberry/c/bin/../lib/gcc/i686-w64-mingw32/8.3.0/../../../../i686-w64-mingw32/bin/ld.exe: MinGW/genesis.a(gensubs.o):gensubs.c:(.text+0x5a57): undefined reference to `_imp__TextOutA@20'
>> c:/Strawberry/c/bin/../lib/gcc/i686-w64-mingw32/8.3.0/../../../../i686-w64-mingw32/bin/ld.exe: MinGW/genesis.a(gensubs.o):gensubs.c:(.text+0x6e11): undefined reference to `_imp__GetTextMetricsA@8'
>> collect2.exe: error: ld returned 1 exit status
>> make: *** [MinGW/adjcost.exe] Error 1
>
> Easy, add '-lgdi32' to the link-command.

Thanks, I finally managed to puzzle that one out by running
a "strings" command on the various .a files in MinGW\lib
and searching for "TextOut". It's clunky, but it lets me
figure out just what -l parameters I have to add for other
things as well.

--
/~\ Charlie Gibbs | Life is perverse.
\ / <cgibbs@kltpzyxm.invalid> | It can be beautiful...
X I'm really at ac.dekanfrus | but it won't.
/ \ if you read it the right way. | -- Lily Tomlin

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor