I’m writing a python program that needs to set the environment CFLAGS as needed.
I’m using the subprocess module to perform some operations, but, I’m not sure this is the correct way of doing this.
The script will first set the CFLAGS and then compile some code, so the cflags need to stay put while the code is compiled.
I know there is the os.environ['CXXFLAGS'] which defaults to “” in my system. So my question is, do I just need to set the os.environ['CXXFLAGS'] value before compiling the code, or do I need to do it some other way?
Please advise
Setting it in the environment by modifying
os.environ['CXXFLAGS']should work. However, the way I’ve always passed extraCXXFLAGSto./configureis by passing it on the command line, e.g.:When done this way, you shouldn’t need to set
CXXFLAGSin the environment or explicitly pass it to make (autotools will create the Makefiles so that they include your customCXXFLAGS).