0

I want to set environment variables for my gcc compiler. Specifically, i want to set one of these two flags:

-fPIC Generate position-independent code if possible (large mode)

-fPIE Generate position-independent code for executables if possible (large mode)

what environment variables do i have to set before code compilation to have these flags enabled?

Basically, what i want is my setup.py file that i run build on, to use one of these flags when it is compiled.

  • These are not environment, these are flags to command line. Like `gcc -fPIC a.c`. Your question makes no sense. – Konstantin Vladimirov Aug 24 '16 at 12:16
  • @KonstantinVladimirov what i was thinking is using something like `os.environ["CFLAGS"] = "-fPIC"` –  Aug 24 '16 at 12:21
  • gcc doesn't look at environment variables like CFLAGS. – n. m. could be an AI Aug 24 '16 at 12:35
  • @n.m. could using a makefile solve this? http://stackoverflow.com/questions/332767/recompile-with-fpic-option-but-the-option-is-already-in-the-makefile –  Aug 24 '16 at 12:39
  • If you set CFLAGS then make will use it, but what problem are you trying to solve in the first place? – n. m. could be an AI Aug 24 '16 at 12:42
  • @n.m. So Im freezing my project with cx_Freeze into a folder with an executable. Now, when I move my folder with `.exe` file somewhere else and run my `.exe`, I get traceback messages. All of those messages are referring to files and directories from the time when i froze my project not to the current directories where i have copied my frozen project to. For example. I built my project in `C:/myProject/` then i copy it to `C:/Users/User/Desktop` and get a traceback. Traceback says error in `C:myProject/build/script.py, line 15` rather than `C:/Users/User/Desktop/build/script.py, line 15` –  Aug 24 '16 at 13:00
  • 1
    @nikolaevra: You're on the wrong track. The sense of _position-independent code_ that `-fPIC` and `-fPIE` mean has nothing at all to do with the "position" of the "code" within the file system. – Armali Aug 25 '16 at 09:26
  • @Armali alright, thanks. At least, I'm not losing hope and will start looking for another solution. BTW, do you know what flags might help me? –  Aug 25 '16 at 14:41
  • 1
    I'm sure the said error messages have nothing to do with `gcc`, but rather with cx_Freeze, which I'm not familiar with, so you might want to add the tag `cx-freeze` to your question. Perhaps this from [**Using cx_Freeze**](https://cx-freeze.readthedocs.io/en/latest/overview.html#using-cx-freeze) might help: _You can make a simple Windows installer using a setup script with the bdist_msi option_, or something from [**Frequently Asked Questions**](https://cx-freeze.readthedocs.io/en/latest/faq.html#frequently-asked-questions). – Armali Aug 26 '16 at 06:40

0 Answers0