[SciPy-user] Strange fortran (g95) build error on Mac OS X - not finding fortran compiler

Robert Kern robert.kern@gmail....
Fri Jan 25 12:59:12 CST 2008


Adam Mercer wrote:
> On Jan 21, 2008 2:40 PM, Adam Mercer <ramercer@gmail.com> wrote:
> 
>> I'm running into a strange problem trying to build scipy-0.6.0 using
>> the g95-0.90 fortran compiler (from http://www.g95.org) on Mac OS X.
> 
> following up on this, I've managed to get past this error but am now
> running into the following problem:
> 
> /opt/local/bin/g95 -shared -shared
> build/temp.macosx-10.3-i386-2.5/build/src.macosx-10.3-i386-2.5/scipy/fftpack/_fftpackmodule.o
> build/temp.macosx-10.3-i386-2.5/scipy/fftpack/src/zfft.o
> build/temp.macosx-10.3-i386-2.5/scipy/fftpack/src/drfft.o
> build/temp.macosx-10.3-i386-2.5/scipy/fftpack/src/zrfft.o
> build/temp.macosx-10.3-i386-2.5/scipy/fftpack/src/zfftnd.o
> build/temp.macosx-10.3-i386-2.5/build/src.macosx-10.3-i386-2.5/fortranobject.o
> -L/opt/local/lib -Lbuild/temp.macosx-10.3-i386-2.5 -ldfftpack -lfftw3
> -o build/lib.macosx-10.3-i386-2.5/scipy/fftpack/_fftpack.so
> g95: unrecognized option '-shared'
> g95: unrecognized option '-shared'
> Undefined symbols:
>   "_PyExc_AttributeError", referenced from:
>       _PyExc_AttributeError$non_lazy_ptr in fortranobject.o
>   "_PyObject_Str", referenced from:
>       _array_from_pyobj in fortranobject.o
>   "_PyArg_ParseTupleAndKeywords", referenced from:
>       _f2py_rout__fftpack_zfft in _fftpackmodule.o
>       _f2py_rout__fftpack_drfft in _fftpackmodule.o
>       _f2py_rout__fftpack_zrfft in _fftpackmodule.o
>       _f2py_rout__fftpack_zfftnd in _fftpackmodule.o
>       _f2py_rout__fftpack_destroy_zfft_cache in _fftpackmodule.o
>       _f2py_rout__fftpack_destroy_zfftnd_cache in _fftpackmodule.o
>       _f2py_rout__fftpack_destroy_drfft_cache in _fftpackmodule.o
>   "_PyExc_ValueError", referenced from:
>       _PyExc_ValueError$non_lazy_ptr in fortranobject.o
>   "_PyExc_TypeError", referenced from:
>       _PyExc_TypeError$non_lazy_ptr in fortranobject.o
>   "_PyDict_GetItemString", referenced from:
>       _fortran_getattr in fortranobject.o
>   "_PyCObject_AsVoidPtr", referenced from:
>       _init_fftpack in _fftpackmodule.o
>   "_Py_BuildValue", referenced from:
>       _f2py_rout__fftpack_zfft in _fftpackmodule.o
>       _f2py_rout__fftpack_drfft in _fftpackmodule.o
>       _f2py_rout__fftpack_zrfft in _fftpackmodule.o
>       _f2py_rout__fftpack_zfftnd in _fftpackmodule.o
>       _f2py_rout__fftpack_destroy_zfft_cache in _fftpackmodule.o
>       _f2py_rout__fftpack_destroy_zfftnd_cache in _fftpackmodule.o
>       _f2py_rout__fftpack_destroy_drfft_cache in _fftpackmodule.o
>   "_PyComplex_Type", referenced from:
>       _PyComplex_Type$non_lazy_ptr in _fftpackmodule.o
>   "_PyDict_New", referenced from:
>       _PyFortranObject_NewAsAttr in fortranobject.o
>       _fortran_setattr in fortranobject.o
>       _PyFortranObject_New in fortranobject.o
>       _PyFortranObject_New in fortranobject.o
>   "_PyDict_SetItemString", referenced from:
>       _init_fftpack in _fftpackmodule.o
>       _init_fftpack in _fftpackmodule.o
>       _init_fftpack in _fftpackmodule.o
>       _F2PyDict_SetItemString in fortranobject.o
>       _fortran_getattr in fortranobject.o
>       _fortran_getattr in fortranobject.o
>       _fortran_setattr in fortranobject.o
>       _PyFortranObject_New in fortranobject.o
>   "_PyType_Type", referenced from:
>       _PyType_Type$non_lazy_ptr in _fftpackmodule.o
>   "__PyObject_New", referenced from:
>       _PyFortranObject_NewAsAttr in fortranobject.o
>       _PyFortranObject_New in fortranobject.o
>       _PyFortranObject_New in fortranobject.o
>   "_PyInt_Type", referenced from:
>       _PyInt_Type$non_lazy_ptr in _fftpackmodule.o
>   "_PyString_FromString", referenced from:
>       _init_fftpack in _fftpackmodule.o
>       _init_fftpack in _fftpackmodule.o
>       _fortran_getattr in fortranobject.o
>       _fortran_getattr in fortranobject.o
>   "_PyErr_Occurred", referenced from:
>       _int_from_pyobj in _fftpackmodule.o
>       _f2py_rout__fftpack_zfft in _fftpackmodule.o
>       _f2py_rout__fftpack_zfft in _fftpackmodule.o
>       _f2py_rout__fftpack_drfft in _fftpackmodule.o
>       _f2py_rout__fftpack_drfft in _fftpackmodule.o
>       _f2py_rout__fftpack_zrfft in _fftpackmodule.o
>       _f2py_rout__fftpack_zrfft in _fftpackmodule.o
>       _f2py_rout__fftpack_zfftnd in _fftpackmodule.o
>       _f2py_rout__fftpack_zfftnd in _fftpackmodule.o
>       _f2py_rout__fftpack_zfftnd in _fftpackmodule.o
>       _f2py_rout__fftpack_zfftnd in _fftpackmodule.o
>       _f2py_rout__fftpack_destroy_zfft_cache in _fftpackmodule.o
>       _f2py_rout__fftpack_destroy_zfftnd_cache in _fftpackmodule.o
>       _f2py_rout__fftpack_destroy_drfft_cache in _fftpackmodule.o
>       _init_fftpack in _fftpackmodule.o
>       _F2PyDict_SetItemString in fortranobject.o
>   "_PyErr_NewException", referenced from:
>       _init_fftpack in _fftpackmodule.o
>   "_PyImport_ImportModule", referenced from:
>       _init_fftpack in _fftpackmodule.o
>   "_PyMem_Free", referenced from:
>       _fortran_dealloc in fortranobject.o
>       _fortran_dealloc in fortranobject.o
>   "_MAIN_", referenced from:
>       _main in libf95.a(main.o)
>   "_PyCObject_Type", referenced from:
>       _PyCObject_Type$non_lazy_ptr in _fftpackmodule.o
>   "_PyExc_ImportError", referenced from:
>       _PyExc_ImportError$non_lazy_ptr in _fftpackmodule.o
>   "_PyErr_Format", referenced from:
>       _init_fftpack in _fftpackmodule.o
>       _fortran_call in fortranobject.o
>       _fortran_call in fortranobject.o
>   "_PyNumber_Int", referenced from:
>       _int_from_pyobj in _fftpackmodule.o
>   "_PyCObject_FromVoidPtr", referenced from:
>       _fortran_getattr in fortranobject.o
>   "_PyObject_GetAttrString", referenced from:
>       _int_from_pyobj in _fftpackmodule.o
>       _init_fftpack in _fftpackmodule.o
>   "_PyErr_Print", referenced from:
>       _init_fftpack in _fftpackmodule.o
>       _F2PyDict_SetItemString in fortranobject.o
>   "_PyString_Type", referenced from:
>       _PyString_Type$non_lazy_ptr in _fftpackmodule.o
>   "__Py_NoneStruct", referenced from:
>       __Py_NoneStruct$non_lazy_ptr in _fftpackmodule.o
>       __Py_NoneStruct$non_lazy_ptr in fortranobject.o
>   "_Py_FindMethod", referenced from:
>       _fortran_getattr in fortranobject.o
>   "_PyString_ConcatAndDel", referenced from:
>       _fortran_getattr in fortranobject.o
>   "_PyErr_Clear", referenced from:
>       _int_from_pyobj in _fftpackmodule.o
>       _F2PyDict_SetItemString in fortranobject.o
>   "_Py_InitModule4", referenced from:
>       _init_fftpack in _fftpackmodule.o
>   "_PyModule_GetDict", referenced from:
>       _init_fftpack in _fftpackmodule.o
>   "_PyExc_RuntimeError", referenced from:
>       _PyExc_RuntimeError$non_lazy_ptr in _fftpackmodule.o
>       _PyExc_RuntimeError$non_lazy_ptr in fortranobject.o
>   "_PyDict_DelItemString", referenced from:
>       _fortran_setattr in fortranobject.o
>   "_PyObject_Type", referenced from:
>       _array_from_pyobj in fortranobject.o
>   "_PySequence_Check", referenced from:
>       _int_from_pyobj in _fftpackmodule.o
>   "_PyString_AsString", referenced from:
>       _array_from_pyobj in fortranobject.o
>   "_PySequence_GetItem", referenced from:
>       _int_from_pyobj in _fftpackmodule.o
>   "_PyErr_SetString", referenced from:
>       _int_from_pyobj in _fftpackmodule.o
>       _f2py_rout__fftpack_zfft in _fftpackmodule.o
>       _f2py_rout__fftpack_zfft in _fftpackmodule.o
>       _f2py_rout__fftpack_zfft in _fftpackmodule.o
>       _f2py_rout__fftpack_drfft in _fftpackmodule.o
>       _f2py_rout__fftpack_drfft in _fftpackmodule.o
>       _f2py_rout__fftpack_drfft in _fftpackmodule.o
>       _f2py_rout__fftpack_zrfft in _fftpackmodule.o
>       _f2py_rout__fftpack_zrfft in _fftpackmodule.o
>       _f2py_rout__fftpack_zrfft in _fftpackmodule.o
>       _f2py_rout__fftpack_zfftnd in _fftpackmodule.o
>       _f2py_rout__fftpack_zfftnd in _fftpackmodule.o
>       _f2py_rout__fftpack_zfftnd in _fftpackmodule.o
>       _f2py_rout__fftpack_zfftnd in _fftpackmodule.o
>       _f2py_rout__fftpack_zfftnd in _fftpackmodule.o
>       _init_fftpack in _fftpackmodule.o
>       _array_from_pyobj in fortranobject.o
>       _fortran_setattr in fortranobject.o
>       _fortran_setattr in fortranobject.o
>   "_PyType_IsSubtype", referenced from:
>       _int_from_pyobj in _fftpackmodule.o
>       _int_from_pyobj in _fftpackmodule.o
>       _int_from_pyobj in _fftpackmodule.o
>       _array_from_pyobj in fortranobject.o
> ld: symbol(s) not found
> 
> Any ideas?

No one has implemented the correct link flags for the g95 compiler on the OS X 
platform. They are probably similar to those required for gfortran. Look in 
numpy/fcompiler/gnu.py for the gfortran implementation (Gnu95FCompiler and its 
superclass GnuFCompiler) to port it to numpy/fcompiler/g95.py. Also double-check 
if you have the environment variable LDFLAGS set. It overrides the link flags 
entirely, including those added by Python itself to link to the Python framework.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
  that is made terrible by our own mad attempt to interpret it as though it had
  an underlying truth."
   -- Umberto Eco


More information about the SciPy-user mailing list