Error with compilation of C / Fortran extensions

91 views
Skip to first unread message

Ian Overton

unread,
Apr 29, 2020, 6:56:52 AM4/29/20
to HotNet
I hit errors trying to compile the fortran and C extensions as described in the README. Please let me know what the issue is?

Initial error with the setup script then tried running f2py directly, but still got an error (please see below):

######### ERROR MESSAGE BELOW

f2py -c fortran_routines.f95 -m fortran_routines
running build
running config_cc
unifing config_cc, config, build_clib, build_ext, build commands --compiler options
running config_fc
unifing config_fc, config, build_clib, build_ext, build commands --fcompiler options
running build_src
build_src
building extension "fortran_routines" sources
f2py options: []
f2py:> /tmp/tmpXtjIAX/src.linux-x86_64-2.7/fortran_routinesmodule.c
creating /tmp/tmpXtjIAX/src.linux-x86_64-2.7
Reading fortran codes...
        Reading file 'fortran_routines.f95' (format:free)
Post-processing...
        Block: fortran_routines
                        Block: compute_sim
                        Block: compute_sim_classic
                        Block: condense_graph
                        Block: remove_edges
                        Block: slice_array
                        Block: strongly_connected_components
Post-processing (stage 2)...
Building modules...
        Building module "fortran_routines"...
                Constructing wrapper function "compute_sim"...
                  m = compute_sim(infmat,h,indices,[p,q])
                Constructing wrapper function "compute_sim_classic"...
                  m = compute_sim_classic(infmat,h,indices,[p,q])
                Constructing wrapper function "condense_graph"...
                  b = condense_graph(a,v,k,[m,n])
                Constructing wrapper function "remove_edges"...
                  b = remove_edges(a,weight,[m,n])
                Constructing wrapper function "slice_array"...
                  b = slice_array(a,columns,rows,[m,n,p,q])
                Constructing wrapper function "strongly_connected_components"...
                  scc_vertices = strongly_connected_components(a,[n])
        Wrote C/API module "fortran_routines" to file "/tmp/tmpXtjIAX/src.linux-x86_64-2.7/fortran_routinesmodule.c"
  adding '/tmp/tmpXtjIAX/src.linux-x86_64-2.7/fortranobject.c' to sources.
  adding '/tmp/tmpXtjIAX/src.linux-x86_64-2.7' to include_dirs.
error: file '/usr/lib64/python2.7/site-packages/numpy/f2py/src/fortranobject.c' does not exist

########## EOM

I then tried a bit of troubleshooting - located the file fortranobject.c (in build/src.linux-x86_64-2.7/build/src.linux-x86_64-2.7/) and placed it in the /usr/lib64/python2.7/site-packages/numpy/f2py/src/ - I had a different error (can't find Python.h):

##### ERROR MESSAGE BELOW

f2py -c fortran_routines.f95 -m fortran_routines
running build
running config_cc
unifing config_cc, config, build_clib, build_ext, build commands --compiler options
running config_fc
unifing config_fc, config, build_clib, build_ext, build commands --fcompiler options
running build_src
build_src
building extension "fortran_routines" sources
f2py options: []
f2py:> /tmp/tmpKlY0i3/src.linux-x86_64-2.7/fortran_routinesmodule.c
creating /tmp/tmpKlY0i3/src.linux-x86_64-2.7
Reading fortran codes...
        Reading file 'fortran_routines.f95' (format:free)
Post-processing...
        Block: fortran_routines
                        Block: compute_sim
                        Block: compute_sim_classic
                        Block: condense_graph
                        Block: remove_edges
                        Block: slice_array
                        Block: strongly_connected_components
Post-processing (stage 2)...
Building modules...
        Building module "fortran_routines"...
                Constructing wrapper function "compute_sim"...
                  m = compute_sim(infmat,h,indices,[p,q])
                Constructing wrapper function "compute_sim_classic"...
                  m = compute_sim_classic(infmat,h,indices,[p,q])
                Constructing wrapper function "condense_graph"...
                  b = condense_graph(a,v,k,[m,n])
                Constructing wrapper function "remove_edges"...
                  b = remove_edges(a,weight,[m,n])
                Constructing wrapper function "slice_array"...
                  b = slice_array(a,columns,rows,[m,n,p,q])
                Constructing wrapper function "strongly_connected_components"...
                  scc_vertices = strongly_connected_components(a,[n])
        Wrote C/API module "fortran_routines" to file "/tmp/tmpKlY0i3/src.linux-x86_64-2.7/fortran_routinesmodule.c"
  adding '/tmp/tmpKlY0i3/src.linux-x86_64-2.7/fortranobject.c' to sources.
  adding '/tmp/tmpKlY0i3/src.linux-x86_64-2.7' to include_dirs.
copying /usr/lib64/python2.7/site-packages/numpy/f2py/src/fortranobject.c -> /tmp/tmpKlY0i3/src.linux-x86_64-2.7
copying /usr/lib64/python2.7/site-packages/numpy/f2py/src/fortranobject.h -> /tmp/tmpKlY0i3/src.linux-x86_64-2.7
build_src: building npy-pkg config files
running build_ext
customize UnixCCompiler
customize UnixCCompiler using build_ext
get_default_fcompiler: matching types: '['gnu95', 'intel', 'lahey', 'pg', 'absoft', 'nag', 'vast', 'compaq', 'intele', 'intelem', 'gnu', 'g95', 'pathf95', 'nagfor']'
customize Gnu95FCompiler
Found executable /usr/bin/gfortran
customize Gnu95FCompiler
customize Gnu95FCompiler using build_ext
building 'fortran_routines' extension
compiling C sources
C compiler: gcc -pthread -fno-strict-aliasing -fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -g -DNDEBUG -fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -g -DOPENSSL_LOAD_CONF -fwrapv -fPIC

creating /tmp/tmpKlY0i3/tmp
creating /tmp/tmpKlY0i3/tmp/tmpKlY0i3
creating /tmp/tmpKlY0i3/tmp/tmpKlY0i3/src.linux-x86_64-2.7
compile options: '-I/tmp/tmpKlY0i3/src.linux-x86_64-2.7 -I/usr/lib64/python2.7/site-packages/numpy/core/include -I/usr/include/python2.7 -c'
gcc: /tmp/tmpKlY0i3/src.linux-x86_64-2.7/fortranobject.c
gcc: /tmp/tmpKlY0i3/src.linux-x86_64-2.7/fortran_routinesmodule.c
/tmp/tmpKlY0i3/src.linux-x86_64-2.7/fortran_routinesmodule.c:14:10: fatal error: Python.h: No such file or directory
 #include "Python.h"
          ^~~~~~~~~~
compilation terminated.
In file included from /tmp/tmpKlY0i3/src.linux-x86_64-2.7/fortranobject.c:2:0:
/tmp/tmpKlY0i3/src.linux-x86_64-2.7/fortranobject.h:7:10: fatal error: Python.h: No such file or directory
 #include "Python.h"
          ^~~~~~~~~~
compilation terminated.
error: Command "gcc -pthread -fno-strict-aliasing -fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -g -DNDEBUG -fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -g -DOPENSSL_LOAD_CONF -fwrapv -fPIC -I/tmp/tmpKlY0i3/src.linux-x86_64-2.7 -I/usr/lib64/python2.7/site-packages/numpy/core/include -I/usr/include/python2.7 -c /tmp/tmpKlY0i3/src.linux-x86_64-2.7/fortran_routinesmodule.c -o /tmp/tmpKlY0i3/tmp/tmpKlY0i3/src.linux-x86_64-2.7/fortran_routinesmodule.o -MMD -MF /tmp/tmpKlY0i3/tmp/tmpKlY0i3/src.linux-x86_64-2.7/fortran_routinesmodule.o.d" failed with exit status 1

#### EOM




Reply all
Reply to author
Forward
0 new messages