How to specify C++11 with distutils?

后端 未结 2 1817
[愿得一人]
[愿得一人] 2021-02-04 03:18

I have a module that needs to be compiled with C++11. On GCC and Clang, that means a std=c++11 switch, or std=c++0x on older compilers.

Python

2条回答
  •  北海茫月
    2021-02-04 03:22

    You can override the default values for various Distutils compilation and link flags using environment variables. This may require some experimentation depending on which platform you are on and how the Python you was using was built. But generally overriding CFLAGS will affect the compilation phase and either one of LDSHARED or LDFLAGS will affect the link phase.

    export CFLAGS='-std=c++11'
    pip install blah
    

    or

    export CFLAGS='-std=c++11'
    python setup.py install
    

    On OS X, another option is to use the ARCHFLAGS environment variable which has the advantage of not wiping out the original CFLAGS or LDSHARED values.

提交回复
热议问题