iNukeLaPeste
iNukeLaPeste

Reputation: 29

How do I get to generate an executable from C++ files using a Python script?

I have all my .cpp and .hpp files and I need to generate an .exe file from them (so my program works on Windows) with a compile.py file.

I need to code the compile.py file.

How should I do that please?

Already took a look at py2exe and PyInstaller, but I believe this is for python files only, not C++ files. Thanks

Upvotes: 0

Views: 1000

Answers (1)

iz_
iz_

Reputation: 16603

You need a C++ compiler, not a compile.py file. If you REALLY need to use Python, use either subprocess (better) or os.system to call command line commands:

import subprocess
subprocess.run('your C++ compiler command')

import os
os.system('compiler command')

But it would be much simpler to do it from the command line, directly executing the compile command.

Upvotes: 1

Related Questions