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.
On Mon, 16 May 2022 23:49:29 GMT, Charlie Gibbs wrote:
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:
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.
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
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.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 379 |
Nodes: | 16 (2 / 14) |
Uptime: | 42:05:45 |
Calls: | 8,141 |
Calls today: | 4 |
Files: | 13,085 |
Messages: | 5,857,792 |