MinGW support for non ASCII paths

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

MinGW support for non ASCII paths

ashish g
Hi

I am trying to create an application that makes use of minGW. However when I try to compile a file using minGW which is in a non ascii path, it error out saying Invalid Arguments.

For example:
my file location is 'L:\test撧\sample.c'


Upon searching online, I found few posts mentioning that minGW on win64 does not support non ascii paths. But I could not find any concrete documentation mentioning this limitation.  So just wanted to check this.


If this is a limitation of minGW, are there any workarounds?  If it helps, Im using a 'createProcessW' call from my application to execute gcc command on cmd.exe

Thank you

--
Ashish Gudla


------------------------------------------------------------------------------

_______________________________________________
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: MinGW support for non ASCII paths

Eli Zaretskii
> From: ashish g <[hidden email]>
> Date: Sun, 9 Aug 2015 17:57:07 -0400
>
> I am trying to create an application that makes use of minGW. However when I
> try to compile a file using minGW which is in a non ascii path, it error out
> saying Invalid Arguments.
>
> For example:
> my file location is 'L:\test撧\sample.c'
>
> Upon searching online, I found few posts mentioning that minGW on win64 does
> not support non ascii paths.

If you are using the "normal" APIs that accept 'char *' file names,
they only support non-ASCII file names that can be encoded in your
system's codepage.

> But I could not find any concrete documentation mentioning this
> limitation.

Read about "ANSI" and "Unicode" file names.

> If this is a limitation of minGW, are there any workarounds? If it helps, Im
> using a 'createProcessW' call from my application to execute gcc command on
> cmd.exe

The solution is indeed to use the "wide" (a.k.a. "Unicode") APIs, such
as CreateProcessW.  But it's not enough to do that on one side, the
process you invoke also needs to use the "wide" APIs to get the
command-line arguments and process them.


------------------------------------------------------------------------------
_______________________________________________
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: MinGW support for non ASCII paths

ashish g
Hi Eli,

My calls are something like this:

createProcessW(my_cmd,....)

where 
my_cmd =  C:\windows\system32\cmd.exe /c (gcc  L:\test撧\sample.c) > outfile 2> errfile

This fails with invalid argument error message

However , when my cmd is as follows, to use visual studio, it works fine.

my_cmd =  C:\windows\system32\cmd.exe /c (cl  L:\test撧\sample.c) > outfile 2> errfile


Any pointers on how to get it working with mingw?

Thank you
Ashish

On Sun, Aug 9, 2015 at 10:36 PM, Eli Zaretskii <[hidden email]> wrote:
> From: ashish g <[hidden email]>
> Date: Sun, 9 Aug 2015 17:57:07 -0400
>
> I am trying to create an application that makes use of minGW. However when I
> try to compile a file using minGW which is in a non ascii path, it error out
> saying Invalid Arguments.
>
> For example:
> my file location is 'L:\test撧\sample.c'
>
> Upon searching online, I found few posts mentioning that minGW on win64 does
> not support non ascii paths.

If you are using the "normal" APIs that accept 'char *' file names,
they only support non-ASCII file names that can be encoded in your
system's codepage.

> But I could not find any concrete documentation mentioning this
> limitation.

Read about "ANSI" and "Unicode" file names.

> If this is a limitation of minGW, are there any workarounds? If it helps, Im
> using a 'createProcessW' call from my application to execute gcc command on
> cmd.exe

The solution is indeed to use the "wide" (a.k.a. "Unicode") APIs, such
as CreateProcessW.  But it's not enough to do that on one side, the
process you invoke also needs to use the "wide" APIs to get the
command-line arguments and process them.


------------------------------------------------------------------------------
_______________________________________________
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



--
Ashish Gudla


------------------------------------------------------------------------------

_______________________________________________
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: MinGW support for non ASCII paths

Eli Zaretskii
> From: ashish g <[hidden email]>
> Date: Sun, 9 Aug 2015 23:13:04 -0400
>
> My calls are something like this:
>
> createProcessW(my_cmd,....)
>
> where
> my_cmd = C:\windows\system32\cmd.exe /c (gcc L:\test撧\sample.c) > outfile 2>
> errfile
>
> This fails with invalid argument error message
>
> However , when my cmd is as follows, to use visual studio, it works fine.
>
> my_cmd = C:\windows\system32\cmd.exe /c (cl L:\test撧\sample.c) > outfile 2>
> errfile
>
> Any pointers on how to get it working with mingw?

Like I said: you need gcc.exe to access its arguments using the "wide"
APIs, such as GetCommandLineW.  Since (AFAIK) gcc.exe doesn't, there's
no way to do what you want.  You must either use non-ASCII file names
compatible with your system codepage, or use the short 8+3 alias of
L:\test撧 (you can see it with "dir /x L:\").


------------------------------------------------------------------------------
_______________________________________________
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: MinGW support for non ASCII paths

Robert Hartmann-2
Hi,

Am 10.08.2015 um 19:08 schrieb Eli Zaretskii:

>> From: ashish g <[hidden email]>
>> Date: Sun, 9 Aug 2015 23:13:04 -0400
>>
>> My calls are something like this:
>>
>> createProcessW(my_cmd,....)
>>
>> where
>> my_cmd = C:\windows\system32\cmd.exe /c (gcc L:\test撧\sample.c) > outfile 2>
>> errfile
>>
>> This fails with invalid argument error message
>>
>> However , when my cmd is as follows, to use visual studio, it works fine.
>>
>> my_cmd = C:\windows\system32\cmd.exe /c (cl L:\test撧\sample.c) > outfile 2>
>> errfile
>>
>> Any pointers on how to get it working with mingw?

Perhaps you build with VS a UNICODE-Build?


>
> Like I said: you need gcc.exe to access its arguments using the "wide"
> APIs, such as GetCommandLineW.  Since (AFAIK) gcc.exe doesn't, there's
> no way to do what you want.



int main(int argc, char* argv[]) {
#ifdef UNICODE
        UNREFERENCED_PARAMETER( argc );
        UNREFERENCED_PARAMETER( argv );
        int wArgc = 0;
        wchar_t **wArgv = ::CommandLineToArgvW(GetCommandLineW(), &wArgc);

#define TARGC wArgc
#define TARGV wArgv
#else
#define TARGC argc
#define TARGV argv
#endif

}

Best regards,
Robert



------------------------------------------------------------------------------
_______________________________________________
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