how run the GNU mingw compiler with arguments?

i had found these program:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
void run(string FileName, string Parameters="")
{
    SHELLEXECUTEINFO ShExecInfo;
    ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
    ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
    ShExecInfo.hwnd = NULL;
    ShExecInfo.lpVerb = "open";
    ShExecInfo.lpFile = FileName.c_str();
    ShExecInfo.lpParameters = Parameters.c_str();
    ShExecInfo.lpDirectory = NULL;
    ShExecInfo.nShow = SW_SHOWNORMAL;
    ShExecInfo.hInstApp = NULL;

    ShellExecuteEx(&ShExecInfo);

    if(ShExecInfo.hProcess)
    CloseHandle(ShExecInfo.hProcess);
}

the program run.... but the arguments i don't know if they are correct... can anyone advice me?
(what i see is the GNU compiler is executed, but i don't know if receives the parameters correctly..)
for now i need ask if 'ShExecInfo.lpParameters' is realy for program parameters?
Last edited on
after several tests the exe is created:
1
2
3
string FileName1="C:\\Program Files\\mingw-w64\\x86_64-7.2.0-win32-seh-rt_v5-rev1\\mingw64\\bin\\x86_64-w64-mingw32-g++.exe";
    run(FileName1,"-c \"C:\\Users\\Cambalinho\\Documents\\CB\\testfolder\\bin\\Debug\\test2.cpp\"");
    run(FileName1,"-o C:\\Users\\Cambalinho\\Documents\\CB\\testfolder\\bin\\Debug\\test2.exe C:\\Users\\Cambalinho\\Documents\\CB\\testfolder\\bin\\Debug\\test2.o");

but the exe isn't executed, only with dependencies dll's.
that's why on codeblocks:
x86_64-w64-mingw32-g++.exe -Wall -g -std=c++14 -c C:\Users\Cambalinho\Documents\CB\testfolder\main.cpp -o obj\Debug\main.o
x86_64-w64-mingw32-g++.exe -L"C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Lib\x86" -o bin\Debug\testfolder.exe obj\Debug\main.o -static-libstdc++ -static-libgcc -fpermissive "..\..\..\..\..\Program Files\mingw-w64\x86_64-7.2.0-win32-seh-rt_v5-rev1\mingw64\x86_64-w64-mingw32\lib\libgdi32.a"
Output file is bin\Debug\testfolder.exe with size 2.92 MB
Process terminated with status 0 (0 minute(s), 8 second(s))
0 error(s), 0 warning(s) (0 minute(s), 8 second(s))

ok.. too big but these part:
-static-libstdc++ -static-libgcc

it's the dll's depencies.. but i don't understand how can i add it on my string.. i tryied several times, but the exe isn't created... what i'm doing wrong?
after several tryies i can make it work and thinking now that i was forgetting a library without notice... yes some API functions need the right libraries
1
2
3
string FileName1="C:\\Program Files\\mingw-w64\\x86_64-7.2.0-win32-seh-rt_v5-rev1\\mingw64\\bin\\x86_64-w64-mingw32-g++.exe";
    run(FileName1,"-Wall -g -std=c++14  -c \"C:\\Users\\Cambalinho\\Documents\\CB\\testfolder\\bin\\Debug\\test2.cpp\" -o \"C:\\Users\\Cambalinho\\Documents\\CB\\testfolder\\bin\\Debug\\test2.o\"");
    run(FileName1,"-o C:\\Users\\Cambalinho\\Documents\\CB\\testfolder\\bin\\Debug\\test2.exe C:\\Users\\Cambalinho\\Documents\\CB\\testfolder\\bin\\Debug\\test2.o -static-libstdc++ -static-libgcc -fpermissive \"C:\\Program Files\\mingw-w64\\x86_64-7.2.0-win32-seh-rt_v5-rev1\\mingw64\\x86_64-w64-mingw32\\lib\\libgdi32.a\"");

now works like i need ;)
thank you so much for all
Topic archived. No new replies allowed.