Click here to Skip to main content
15,918,617 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
Hi,

I installed Mingw32 in C:\Ming32\ Folder.

I added this path to PATH variable.

When I type the command mingw32-make.exe in Command prompt from any path, the system is able to find the file. But when I tried with the CreateProcess as a first argument it is failing with error code 2.

Also i tried as a second argument and i got the error code 237.

How to solve this problem. I don't want to use the Mingw32 path in my code, because my application will run in different systems and they may install the gcc in different folders.

Thanks,
Posted
Updated 1-Feb-12 4:09am
v2
Comments
JackDingler 1-Feb-12 10:46am    
Your question is very confusing. I don't understand exactly what you mean by using CreateProcess as the first argument.

Could you post your code please?
Sergey Alexandrovich Kryukov 1-Feb-12 14:41pm    
I think the question is rather clear, but based on a deep OP's confusion. I think I understand it.

No wonder you were confused though.
"CreateProcess as a first argument" is just wrong wording. From the context you can see that OP tried to use wrong first argument, probably environment variable (by a weirdest reason I tried to debunk in my answer). Naturally, the error as #2, which simply means "file not found".

Please see my answer.
--SA

Well on option you'll have is to either determine the mingw32 installation path at install time or better yet supply the additional opportunity to have this configurable in your application. For the most part I really try to avoid hard coded stuff except for algorithm or system relevant constants.

Besides that you probably missed this bit here in the MSDN documentation on CreateProcess[^]:

The string can specify the full path and file name of the module to execute or it can specify a partial name. In the case of a partial name, the function uses the current drive and current directory to complete the specification. The function will not use the search path. This parameter must include the file name extension; no default extension is assumed.

—MSDN
The functionality you are after is usually supplied by the/a shell (cmd e.g.). You might want to look at the function ShellExecute[^].

Regards,

Manfred
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 1-Feb-12 14:32pm    
This information is very useful and relevant to the question, but it does not answer main questions (see the title) which is generic and based on major misconception of OP.

So, I voted 4 this time and tried to clarify on that; please see my answer.
--SA
Espen Harlinn 1-Feb-12 16:43pm    
5'ed!
Passing an environment variable as a parameter makes no sense, whatsoever. The semantic of parameters is totally defined by the application used to run as a child process. This application received a command line string (which more usually typed in the console after the name of the application file) and processed by the application, according to its semantic.

Even though, speculatively speaking, the semantics of some command line parameters of the application might mean the name and/or value of an environment variable, no reasonable application will use such semantic, because it would not make any sense at all.

The environment variables play the role of "global constants" or rather "global read-only values", global to the system. They are used for some global settings and never changed during run-time of any application, excluding rare cases when one needs to change some global settings or add some settings. Sometimes it happens as a result of installation of a new software product.

Moreover, using environment variables for installation (and later run time) of any application is the indication of a really bad style of configuration, or maybe the way of backward compatibility with some software legacy. More appropriate style is using system isolated configuration or settings files, per application.

For more detail, please see http://en.wikipedia.org/wiki/Environment_variable[^].

[EDIT]

The error message is explained in my comment to the comment by JackDingler to the original question, please see.

—SA
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900