distutils & and C++ extentions

eric jones eric at enthought.com
Thu Jan 17 15:01:58 EST 2002


Hey Jesper,

I think gcc should treat .cxx files as C++.

For the linking, I've used the following to force g++ as the linker:

#!/usr/bin/env python
from distutils.core import setup, Extension

# Forces g++ instead of gcc on most systems I've tried.
import distutils.sysconfig

old_init_posix = distutils.sysconfig._init_posix

def _init_posix():
    old_init_posix()
    distutils.sysconfig._config_vars['LDSHARED'] = 'g++ -shared'

distutils.sysconfig._init_posix = _init_posix

if __name__ == '__main__':
    ext = Extension('testfn2', ["testfn2.cxx"])
    setup(name='testfn2',ext_modules = [ext])

hope this helps,

eric





More information about the Python-list mailing list