Compiling Fortran code for Python module
Frank Schima
macsforever2000 at macports.org
Thu May 2 15:35:58 PDT 2013
On May 2, 2013, at 2:29 PM, Frank Schima <macsforever2000 at macports.org> wrote:
> I'm attempting to create a port for py-qutip [1]. It has some code that requires a Fortran compiler so I created gcc4X variants for it. But it fails to compile from Macports and works if built by hand.
>
> The build command is simply:
>
> sudo python setup.py install --with-f90mc
> That flag is added in my Portfile with the line:
>
> build.post_args-append --with-f90mc
>
> Here is the line that fails with the beginning of the error:
>
> /opt/local/bin/gfortran-mp-4.7 -Wall build/temp.macosx-10.8-x86_64-2.7/build/src.macosx-10.8-x86_64-2.7/qutip/fortran/qutraj_runmodule.o build/temp.macosx-10.8-x86_64-2.7/build/src.macosx-10.8-x86_64-2.7/fortranobject.o build/temp.macosx-10.8-x86_64-2.7/qutip/fortran/qutraj_precision.o build/temp.macosx-10.8-x86_64-2.7/qutip/fortran/mt19937.o build/temp.macosx-10.8-x86_64-2.7/qutip/fortran/linked_list.o build/temp.macosx-10.8-x86_64-2.7/qutip/fortran/qutraj_general.o build/temp.macosx-10.8-x86_64-2.7/qutip/fortran/qutraj_hilbert.o build/temp.macosx-10.8-x86_64-2.7/qutip/fortran/qutraj_evolve.o build/temp.macosx-10.8-x86_64-2.7/qutip/fortran/qutraj_linalg.o build/temp.macosx-10.8-x86_64-2.7/qutip/fortran/qutraj_run.o build/temp.macosx-10.8-x86_64-2.7/build/src.macosx-10.8-x86_64-2.7/qutip/fortran/qutraj_run-f2pywrappers2.o -L/opt/local/lib -L/opt/local/lib/gcc47/gcc/x86_64-apple-darwin12/4.7.3 -Lbuild/temp.macosx-10.8-x86_64-2.7 -lzvode -llapack -llapack -lgfortran -o build/lib.macosx-10.8-x86_64-2.7/qutip/fortran/qutraj_run.so
>
> Undefined symbols for architecture x86_64:
> "_PyArg_ParseTupleAndKeywords", referenced from:
> _f2py_rout_qutraj_run_qutraj_run_test_real_precision in qutraj_runmodule.o
> _f2py_rout_qutraj_run_qutraj_run_finalize_sol in qutraj_runmodule.o
> _f2py_rout_qutraj_run_qutraj_run_finalize_work in qutraj_runmodule.o
> _f2py_rout_qutraj_run_qutraj_run_get_rho_sparse in qutraj_runmodule.o
> _f2py_rout_qutraj_run_qutraj_run_get_collapses in qutraj_runmodule.o
> _f2py_rout_qutraj_run_qutraj_run_init_tlist in qutraj_runmodule.o
> _f2py_rout_qutraj_run_qutraj_run_init_psi0 in qutraj_runmodule.o
> ...
>
> And here is a version that works when I cd to the build directory and run it from Terminal:
>
> /opt/local/bin/gfortran -Wall -Wall -undefined dynamic_lookup -bundle build/temp.macosx-10.8-x86_64-2.7/build/src.macosx-10.8-x86_64-2.7/qutip/fortran/qutraj_runmodule.o build/temp.macosx-10.8-x86_64-2.7/build/src.macosx-10.8-x86_64-2.7/fortranobject.o build/temp.macosx-10.8-x86_64-2.7/qutip/fortran/qutraj_precision.o build/temp.macosx-10.8-x86_64-2.7/qutip/fortran/mt19937.o build/temp.macosx-10.8-x86_64-2.7/qutip/fortran/linked_list.o build/temp.macosx-10.8-x86_64-2.7/qutip/fortran/qutraj_general.o build/temp.macosx-10.8-x86_64-2.7/qutip/fortran/qutraj_hilbert.o build/temp.macosx-10.8-x86_64-2.7/qutip/fortran/qutraj_evolve.o build/temp.macosx-10.8-x86_64-2.7/qutip/fortran/qutraj_linalg.o build/temp.macosx-10.8-x86_64-2.7/qutip/fortran/qutraj_run.o build/temp.macosx-10.8-x86_64-2.7/build/src.macosx-10.8-x86_64-2.7/qutip/fortran/qutraj_run-f2pywrappers2.o -L/opt/local/lib -L/opt/local/lib/gcc47/gcc/x86_64-apple-darwin12/4.7.3 -Lbuild/temp.macosx-10.8-x86_64-2.7 -lzvode -llapack -llapack -lgfortran -o build/lib.macosx-10.8-x86_64-2.7/qutip/fortran/qutraj_run.so
>
> The difference is that when I run it manually, the following flags are added:
>
> "-Wall -undefined dynamic_lookup -bundle"
>
> How can I add those gfortran flags to my Portfile? I'm attaching my in progress Portfile for reference.
>
>
> Cheers!
> Frank
>
> [1] <http://qutip.googlecode.com/svn/doc/2.2.0/html/installation.html#installation-on-mac-os-x-10-6>
> <Portfile>
As an update. I added the following line to the Portfile which fixed the Fortran code and then goes on to break the C code being compiled later:
build.env-append LDFLAGS=-undefined dynamic_lookup -bundle
/usr/bin/clang -bundle -undefined dynamic_lookup -L/opt/local/lib dynamic_lookup build/temp.macosx-10.8-x86_64-2.7/qutip/cyQ/spmatfuncs.o -Lbuild/temp.macosx-10.8-x86_64-2.7 -o build/lib.macosx-10.8-x86_64-2.7/qutip/cyQ/spmatfuncs.so
clang: error: no such file or directory: 'dynamic_lookup'
Any ideas?
Thank you,
Frank
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-dev/attachments/20130502/fbde8e77/attachment-0001.html>
More information about the macports-dev
mailing list