I have gone through various questions on the internet to execute a cpp file from python or another cpp file, however, I faced some issues that I would like to share.
Case 1.
a) When I try to run a cpp file from python as described here, I get this error hp, ht, pid, tid = _winapi.CreateProcess(executable, args, FileNotFoundError: [WinError 2] The system cannot find the file specified
. However, a.out
is created inside the same directory but it still says no file found.
Case 2.
a) When I try to run .cpp
file from another cpp file as described here, I don't get an error but let's say I want to run a.cpp
from b.cpp
so first I need to build a.exe
and then call system("a.exe")
from b.cpp
code, but I want something as shown below since I don't want to manually create an executable file for a.cpp
every time.
// b.cpp
method("a.cpp");
OR
command to create a.exe
system("a.exe")