0

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

asked Nov 6, 2018 at 18:46
9
  • If you just want to compile the c++ files, use a make file Commented Nov 6, 2018 at 18:48
  • 1
    You don't need any compile.py, you need a compilation toolchain. Commented Nov 6, 2018 at 18:48
  • It's a school assignment, and that's what my teacher is asking for. I'd have used a makefile if I could.. :( @SPYBUG96 and VTT Commented Nov 6, 2018 at 18:51
  • @iNukeLaPeste Call GCC or whatever you use to compile the C++ code with from the python script Commented Nov 6, 2018 at 18:56
  • You can try Microsoft Visual C++ Compiler for Python 2.7. Commented Nov 6, 2018 at 18:57

1 Answer 1

1

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.

answered Nov 6, 2018 at 18:58
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.