How do I write native windows code with MinGW? POSIX calls are compiling?.

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

How do I write native windows code with MinGW? POSIX calls are compiling?.

kk.mingw
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
[hidden email]

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:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: How do I write native windows code with MinGW? POSIX calls are compiling?.

Eli Zaretskii
> Date: Thu, 16 Mar 2017 19:33:05 -0400
> From: [hidden email]
>
> 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
[hidden email]

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:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: How do I write native windows code with MinGW? POSIX calls are compiling?.

Earnie Boyd
On 3/17/2017 4:25 AM, Eli Zaretskii wrote:

>> Date: Thu, 16 Mar 2017 19:33:05 -0400
>> From: [hidden email]
>>
>> 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
[hidden email]

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:[hidden email]?subject=unsubscribe