Hi all,

I compiled a C program with a system() call in a mingw64 shell. And it
works there. However I want to ditribute it without the complete msys
environment, therefore, it must work in a Win10 cmd shell.

When I execute the program (together with msys-2.0.dll) in a cmd shell
it only works when the program resides in the msys installation
directory. If I move these two files to another directory (i.e. bin) it
fails.

Here is an simple example:

vvvvvvvvvvvvvvvvvvvv

systest.c

#include <stdlib.h>
#include <stdio.h>

int main( void )
{
    FILE *fp;

    printf("+++ system NULL: %d\n", system( NULL ));
    printf("+++ system echo: %d\n", system( "echo hello" ));
}

^^^^^^^^^^^^^^^^^^^^^
compiled with: gcc -o systest systest.c

If I execute it in a cmd shell in my mingw64 home directory the output is

+++ system NULL: 1
hello
+++ system echo: 0

Moved to the other directory I get the following output:

+++ system NULL: 1
+++ system echo: 127

Can anyone tell me how to make such a program working within a cmd shell
in other locations than the mingw64 home directory?

Thanks.

Flo

PS: If I replace echo with a nonexisting command, I get an error message
instead of 'hello' in the first place but again nothing in the second run.


_______________________________________________
Msys2-users mailing list
Msys2-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/msys2-users

Reply via email to