Discussion:
[Mingw-users] How do I write native windows code with MinGW? POSIX calls are compiling?.
k***@thekingklan.com
2017-03-16 23:33:05 UTC
Permalink
How do I write native windows code with MinGW? Getting POSIX calls to
compile.

From the MinGW web page <quote..>
MinGW compilers provide access to the functionality of the Microsoft C
runtime and some language-specific runtimes. MinGW, being Minimalist,
does not, and never will, attempt to provide a POSIX runtime environment
for POSIX application deployment on MS-Windows. If you want POSIX
application deployment on this platform, please consider Cygwin instead.
<.../quote>

Exactly what I want – Let me explain. I followed the directions for a
new instillation. I have a Linux program that works in Linux. It will
also work in Cygwin. The program has several POSIX calls that I know
windows does NOT support (getopt(), glob(), ...). I tried compiling this
program with MinGW expecting errors --- but to my surprise it compiles,
links, and runs. Clearly, it has linked with some libs that provide
POSIX – how do I get Windows and nothing but windows?

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
MinGW-users mailing list
MinGW-***@lists.sourceforge.net

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same. Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:mingw-users-***@lists.sourceforge.net?subject=
Eli Zaretskii
2017-03-17 08:25:42 UTC
Permalink
Date: Thu, 16 Mar 2017 19:33:05 -0400
How do I write native windows code with MinGW? Getting POSIX calls to
compile.
There's no single answer to that, it depends on the APIs you need.
But as a rule of thumb, mots Posix APIs are absent.
Exactly what I want – Let me explain. I followed the directions for a
new instillation. I have a Linux program that works in Linux. It will
also work in Cygwin. The program has several POSIX calls that I know
windows does NOT support (getopt(), glob(), ...). I tried compiling this
program with MinGW expecting errors --- but to my surprise it compiles,
links, and runs. Clearly, it has linked with some libs that provide
POSIX – how do I get Windows and nothing but windows?
MinGW adds a small set of popular Posix functions in the libmingwex
library that is scanned by default by the linker when linking
programs. If you want to know which additional functions are
available, use something like 'nm -A libmingwex.a | grep " T "', and
you will see them. Most of them are math functions, but some, like
getopt and glob, are not.

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
MinGW-users mailing list
MinGW-***@lists.sourceforge.net

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same. Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:mingw-users-***@lists.sourceforge.net?subject=unsubs
Earnie
2017-03-18 13:38:11 UTC
Permalink
Post by Eli Zaretskii
Date: Thu, 16 Mar 2017 19:33:05 -0400
How do I write native windows code with MinGW? Getting POSIX calls to
compile.
There's no single answer to that, it depends on the APIs you need.
But as a rule of thumb, mots Posix APIs are absent.
Exactly what I want – Let me explain. I followed the directions for a
new instillation. I have a Linux program that works in Linux. It will
also work in Cygwin. The program has several POSIX calls that I know
windows does NOT support (getopt(), glob(), ...). I tried compiling this
program with MinGW expecting errors --- but to my surprise it compiles,
links, and runs. Clearly, it has linked with some libs that provide
POSIX – how do I get Windows and nothing but windows?
MinGW adds a small set of popular Posix functions in the libmingwex
library that is scanned by default by the linker when linking
programs. If you want to know which additional functions are
available, use something like 'nm -A libmingwex.a | grep " T "', and
you will see them. Most of them are math functions, but some, like
getopt and glob, are not.
Don't forget though that all of those symbols may not be declared due to
defined constants which get defined by various methods. If you want to
eliminate the POSIX emulations use -std=c## where ## is replaced by your
favorite standard version moniker e.g. -std=c99. I also suggest using
-Wall -Werror if you want to ensure that there are no hidden issues.
--
Earnie

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
MinGW-users mailing list
MinGW-***@lists.sourceforge.net

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same. Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:mingw
Loading...