Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ld returned 1 exit status, gcc failed with exit status 1 #851

Closed
scarlion1 opened this issue Mar 6, 2017 · 5 comments
Closed

ld returned 1 exit status, gcc failed with exit status 1 #851

scarlion1 opened this issue Mar 6, 2017 · 5 comments

Comments

@scarlion1
Copy link

We are using CentOS 6.8 with python 2.7.8. I'm trying to install h5py with 'pip install h5py' but getting the errors:
"Failed building wheel for h5py"
"/usr/bin/ld: /usr/local/lib/libpython2.7.a(abstract.o): relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a shared object; recompile with -fPIC"

a problem with our gcc? the system's gcc is 4.4.7 but i also tried with 5.3.1 from the software collections and got same error... a problem with the python from software collections?

[root@pac ~]# pip install h5py
You are using pip version 7.1.0, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Collecting h5py
  Using cached h5py-2.6.0.tar.gz
Requirement already satisfied (use --upgrade to upgrade): numpy>=1.6.1 in /opt/rh/python27/root/usr/lib/python2.7/site-packages (from h5py)
Requirement already satisfied (use --upgrade to upgrade): six in /opt/rh/python27/root/usr/lib/python2.7/site-packages (from h5py)
Building wheels for collected packages: h5py
  Running setup.py bdist_wheel for h5py
  Complete output from command /opt/rh/python27/root/usr/bin/python2 -c "import setuptools;__file__='/tmp/pip-build-o43mj5/h5py/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" bdist_wheel -d /tmp/tmp5ND7jHpip-wheel-:
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-x86_64-2.7
  creating build/lib.linux-x86_64-2.7/h5py
  copying h5py/__init__.py -> build/lib.linux-x86_64-2.7/h5py
  copying h5py/highlevel.py -> build/lib.linux-x86_64-2.7/h5py
  copying h5py/ipy_completer.py -> build/lib.linux-x86_64-2.7/h5py
  copying h5py/version.py -> build/lib.linux-x86_64-2.7/h5py
  creating build/lib.linux-x86_64-2.7/h5py/_hl
  copying h5py/_hl/selections.py -> build/lib.linux-x86_64-2.7/h5py/_hl
  copying h5py/_hl/selections2.py -> build/lib.linux-x86_64-2.7/h5py/_hl
  copying h5py/_hl/__init__.py -> build/lib.linux-x86_64-2.7/h5py/_hl
  copying h5py/_hl/attrs.py -> build/lib.linux-x86_64-2.7/h5py/_hl
  copying h5py/_hl/filters.py -> build/lib.linux-x86_64-2.7/h5py/_hl
  copying h5py/_hl/base.py -> build/lib.linux-x86_64-2.7/h5py/_hl
  copying h5py/_hl/dims.py -> build/lib.linux-x86_64-2.7/h5py/_hl
  copying h5py/_hl/files.py -> build/lib.linux-x86_64-2.7/h5py/_hl
  copying h5py/_hl/dataset.py -> build/lib.linux-x86_64-2.7/h5py/_hl
  copying h5py/_hl/datatype.py -> build/lib.linux-x86_64-2.7/h5py/_hl
  copying h5py/_hl/group.py -> build/lib.linux-x86_64-2.7/h5py/_hl
  creating build/lib.linux-x86_64-2.7/h5py/tests
  copying h5py/tests/__init__.py -> build/lib.linux-x86_64-2.7/h5py/tests
  copying h5py/tests/common.py -> build/lib.linux-x86_64-2.7/h5py/tests
  creating build/lib.linux-x86_64-2.7/h5py/tests/old
  copying h5py/tests/old/test_h5t.py -> build/lib.linux-x86_64-2.7/h5py/tests/old
  copying h5py/tests/old/test_attrs_data.py -> build/lib.linux-x86_64-2.7/h5py/tests/old
  copying h5py/tests/old/test_datatype.py -> build/lib.linux-x86_64-2.7/h5py/tests/old
  copying h5py/tests/old/__init__.py -> build/lib.linux-x86_64-2.7/h5py/tests/old
  copying h5py/tests/old/test_h5.py -> build/lib.linux-x86_64-2.7/h5py/tests/old
  copying h5py/tests/old/test_dimension_scales.py -> build/lib.linux-x86_64-2.7/h5py/tests/old
  copying h5py/tests/old/common.py -> build/lib.linux-x86_64-2.7/h5py/tests/old
  copying h5py/tests/old/test_attrs.py -> build/lib.linux-x86_64-2.7/h5py/tests/old
  copying h5py/tests/old/test_dataset.py -> build/lib.linux-x86_64-2.7/h5py/tests/old
  copying h5py/tests/old/test_base.py -> build/lib.linux-x86_64-2.7/h5py/tests/old
  copying h5py/tests/old/test_selections.py -> build/lib.linux-x86_64-2.7/h5py/tests/old
  copying h5py/tests/old/test_slicing.py -> build/lib.linux-x86_64-2.7/h5py/tests/old
  copying h5py/tests/old/test_objects.py -> build/lib.linux-x86_64-2.7/h5py/tests/old
  copying h5py/tests/old/test_file.py -> build/lib.linux-x86_64-2.7/h5py/tests/old
  copying h5py/tests/old/test_h5f.py -> build/lib.linux-x86_64-2.7/h5py/tests/old
  copying h5py/tests/old/test_group.py -> build/lib.linux-x86_64-2.7/h5py/tests/old
  copying h5py/tests/old/test_h5p.py -> build/lib.linux-x86_64-2.7/h5py/tests/old
  creating build/lib.linux-x86_64-2.7/h5py/tests/hl
  copying h5py/tests/hl/test_dataset_getitem.py -> build/lib.linux-x86_64-2.7/h5py/tests/hl
  copying h5py/tests/hl/test_datatype.py -> build/lib.linux-x86_64-2.7/h5py/tests/hl
  copying h5py/tests/hl/__init__.py -> build/lib.linux-x86_64-2.7/h5py/tests/hl
  copying h5py/tests/hl/test_dataset_swmr.py -> build/lib.linux-x86_64-2.7/h5py/tests/hl
  copying h5py/tests/hl/test_dims_dimensionproxy.py -> build/lib.linux-x86_64-2.7/h5py/tests/hl
  copying h5py/tests/hl/test_attribute_create.py -> build/lib.linux-x86_64-2.7/h5py/tests/hl
  copying h5py/tests/hl/test_file.py -> build/lib.linux-x86_64-2.7/h5py/tests/hl
  copying h5py/tests/hl/test_threads.py -> build/lib.linux-x86_64-2.7/h5py/tests/hl
  running build_ext
  Autodetected HDF5 1.8.7
  ********************************************************************************
                         Summary of the h5py configuration
  
      Path to HDF5: None
      HDF5 Version: '1.8.7'
       MPI Enabled: False
  Rebuild Required: False
  
  ********************************************************************************
  Executing api_gen rebuild of defs
  Executing cythonize()
  ./h5py/api_types_ext.pxd: cannot find cimported module 'mpi4py.MPI'
  /tmp/pip-build-o43mj5/h5py/h5py/h5p.pyx: cannot find cimported module 'mpi4py.libmpi'
  /tmp/pip-build-o43mj5/h5py/h5py/h5p.pyx: cannot find cimported module 'mpi4py.mpi_c'
  Compiling /tmp/pip-build-o43mj5/h5py/h5py/defs.pyx because it changed.
  Compiling /tmp/pip-build-o43mj5/h5py/h5py/_errors.pyx because it changed.
  Compiling /tmp/pip-build-o43mj5/h5py/h5py/_objects.pyx because it changed.
  Compiling /tmp/pip-build-o43mj5/h5py/h5py/_proxy.pyx because it changed.
  Compiling /tmp/pip-build-o43mj5/h5py/h5py/h5fd.pyx because it changed.
  Compiling /tmp/pip-build-o43mj5/h5py/h5py/h5z.pyx because it changed.
  Compiling /tmp/pip-build-o43mj5/h5py/h5py/h5.pyx because it changed.
  Compiling /tmp/pip-build-o43mj5/h5py/h5py/h5i.pyx because it changed.
  Compiling /tmp/pip-build-o43mj5/h5py/h5py/h5r.pyx because it changed.
  Compiling /tmp/pip-build-o43mj5/h5py/h5py/utils.pyx because it changed.
  Compiling /tmp/pip-build-o43mj5/h5py/h5py/_conv.pyx because it changed.
  Compiling /tmp/pip-build-o43mj5/h5py/h5py/h5t.pyx because it changed.
  Compiling /tmp/pip-build-o43mj5/h5py/h5py/h5s.pyx because it changed.
  Compiling /tmp/pip-build-o43mj5/h5py/h5py/h5p.pyx because it changed.
  Compiling /tmp/pip-build-o43mj5/h5py/h5py/h5d.pyx because it changed.
  Compiling /tmp/pip-build-o43mj5/h5py/h5py/h5a.pyx because it changed.
  Compiling /tmp/pip-build-o43mj5/h5py/h5py/h5f.pyx because it changed.
  Compiling /tmp/pip-build-o43mj5/h5py/h5py/h5g.pyx because it changed.
  Compiling /tmp/pip-build-o43mj5/h5py/h5py/h5l.pyx because it changed.
  Compiling /tmp/pip-build-o43mj5/h5py/h5py/h5o.pyx because it changed.
  Compiling /tmp/pip-build-o43mj5/h5py/h5py/h5ds.pyx because it changed.
  Compiling /tmp/pip-build-o43mj5/h5py/h5py/h5ac.pyx because it changed.
  [ 1/22] Cythonizing /tmp/pip-build-o43mj5/h5py/h5py/_conv.pyx
  [ 2/22] Cythonizing /tmp/pip-build-o43mj5/h5py/h5py/_errors.pyx
  [ 3/22] Cythonizing /tmp/pip-build-o43mj5/h5py/h5py/_objects.pyx
  [ 4/22] Cythonizing /tmp/pip-build-o43mj5/h5py/h5py/_proxy.pyx
  [ 5/22] Cythonizing /tmp/pip-build-o43mj5/h5py/h5py/defs.pyx
  [ 6/22] Cythonizing /tmp/pip-build-o43mj5/h5py/h5py/h5.pyx
  [ 7/22] Cythonizing /tmp/pip-build-o43mj5/h5py/h5py/h5a.pyx
  [ 8/22] Cythonizing /tmp/pip-build-o43mj5/h5py/h5py/h5ac.pyx
  [ 9/22] Cythonizing /tmp/pip-build-o43mj5/h5py/h5py/h5d.pyx
  [10/22] Cythonizing /tmp/pip-build-o43mj5/h5py/h5py/h5ds.pyx
  [11/22] Cythonizing /tmp/pip-build-o43mj5/h5py/h5py/h5f.pyx
  [12/22] Cythonizing /tmp/pip-build-o43mj5/h5py/h5py/h5fd.pyx
  [13/22] Cythonizing /tmp/pip-build-o43mj5/h5py/h5py/h5g.pyx
  [14/22] Cythonizing /tmp/pip-build-o43mj5/h5py/h5py/h5i.pyx
  [15/22] Cythonizing /tmp/pip-build-o43mj5/h5py/h5py/h5l.pyx
  [16/22] Cythonizing /tmp/pip-build-o43mj5/h5py/h5py/h5o.pyx
  [17/22] Cythonizing /tmp/pip-build-o43mj5/h5py/h5py/h5p.pyx
  [18/22] Cythonizing /tmp/pip-build-o43mj5/h5py/h5py/h5r.pyx
  [19/22] Cythonizing /tmp/pip-build-o43mj5/h5py/h5py/h5s.pyx
  [20/22] Cythonizing /tmp/pip-build-o43mj5/h5py/h5py/h5t.pyx
  [21/22] Cythonizing /tmp/pip-build-o43mj5/h5py/h5py/h5z.pyx
  [22/22] Cythonizing /tmp/pip-build-o43mj5/h5py/h5py/utils.pyx
  building 'h5py.defs' extension
  creating build/temp.linux-x86_64-2.7
  creating build/temp.linux-x86_64-2.7/tmp
  creating build/temp.linux-x86_64-2.7/tmp/pip-build-o43mj5
  creating build/temp.linux-x86_64-2.7/tmp/pip-build-o43mj5/h5py
  creating build/temp.linux-x86_64-2.7/tmp/pip-build-o43mj5/h5py/h5py
  gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DH5_USE_16_API -I/tmp/pip-build-o43mj5/h5py/lzf -I/opt/local/include -I/usr/local/include -I/opt/rh/python27/root/usr/lib/python2.7/site-packages/numpy/core/include -I/opt/rh/python27/root/usr/include/python2.7 -c /tmp/pip-build-o43mj5/h5py/h5py/defs.c -o build/temp.linux-x86_64-2.7/tmp/pip-build-o43mj5/h5py/h5py/defs.o
  In file included from /opt/rh/python27/root/usr/lib/python2.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1788,
                   from /opt/rh/python27/root/usr/lib/python2.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:18,
                   from /opt/rh/python27/root/usr/lib/python2.7/site-packages/numpy/core/include/numpy/arrayobject.h:4,
                   from /tmp/pip-build-o43mj5/h5py/h5py/api_compat.h:26,
                   from /tmp/pip-build-o43mj5/h5py/h5py/defs.c:473:
  /opt/rh/python27/root/usr/lib/python2.7/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:15:2: warning: #warning "Using deprecated NumPy API, disable it by " "#defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION"
  /opt/rh/python27/root/usr/lib/python2.7/site-packages/numpy/core/include/numpy/__multiarray_api.h:1448: warning: ‘_import_array’ defined but not used
  gcc -pthread -shared build/temp.linux-x86_64-2.7/tmp/pip-build-o43mj5/h5py/h5py/defs.o -L/opt/local/lib -L/usr/local/lib -L/opt/rh/python27/root/usr/lib64 -Wl,-R/opt/local/lib -Wl,-R/usr/local/lib -lhdf5 -lhdf5_hl -lpython2.7 -o build/lib.linux-x86_64-2.7/h5py/defs.so
  /usr/bin/ld: /usr/local/lib/libpython2.7.a(abstract.o): relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a shared object; recompile with -fPIC
  /usr/local/lib/libpython2.7.a: could not read symbols: Bad value
  collect2: ld returned 1 exit status
  error: command 'gcc' failed with exit status 1
  
  ----------------------------------------
  Failed building wheel for h5py
Failed to build h5py
Installing collected packages: h5py
  Running setup.py install for h5py
    Complete output from command /opt/rh/python27/root/usr/bin/python2 -c "import setuptools, tokenize;__file__='/tmp/pip-build-o43mj5/h5py/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-gST3pm-record/install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    running build_ext
    Autodetected HDF5 1.8.7
    ********************************************************************************
                           Summary of the h5py configuration
    
        Path to HDF5: None
        HDF5 Version: '1.8.7'
         MPI Enabled: False
    Rebuild Required: False
    
    ********************************************************************************
    Executing cythonize()
    ./h5py/api_types_ext.pxd: cannot find cimported module 'mpi4py.MPI'
    /tmp/pip-build-o43mj5/h5py/h5py/h5p.pyx: cannot find cimported module 'mpi4py.libmpi'
    /tmp/pip-build-o43mj5/h5py/h5py/h5p.pyx: cannot find cimported module 'mpi4py.mpi_c'
    building 'h5py.defs' extension
    gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DH5_USE_16_API -I/tmp/pip-build-o43mj5/h5py/lzf -I/opt/local/include -I/usr/local/include -I/opt/rh/python27/root/usr/lib/python2.7/site-packages/numpy/core/include -I/opt/rh/python27/root/usr/include/python2.7 -c /tmp/pip-build-o43mj5/h5py/h5py/defs.c -o build/temp.linux-x86_64-2.7/tmp/pip-build-o43mj5/h5py/h5py/defs.o
    In file included from /opt/rh/python27/root/usr/lib/python2.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1788,
                     from /opt/rh/python27/root/usr/lib/python2.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:18,
                     from /opt/rh/python27/root/usr/lib/python2.7/site-packages/numpy/core/include/numpy/arrayobject.h:4,
                     from /tmp/pip-build-o43mj5/h5py/h5py/api_compat.h:26,
                     from /tmp/pip-build-o43mj5/h5py/h5py/defs.c:473:
    /opt/rh/python27/root/usr/lib/python2.7/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:15:2: warning: #warning "Using deprecated NumPy API, disable it by " "#defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION"
    /opt/rh/python27/root/usr/lib/python2.7/site-packages/numpy/core/include/numpy/__multiarray_api.h:1448: warning: ‘_import_array’ defined but not used
    gcc -pthread -shared build/temp.linux-x86_64-2.7/tmp/pip-build-o43mj5/h5py/h5py/defs.o -L/opt/local/lib -L/usr/local/lib -L/opt/rh/python27/root/usr/lib64 -Wl,-R/opt/local/lib -Wl,-R/usr/local/lib -lhdf5 -lhdf5_hl -lpython2.7 -o build/lib.linux-x86_64-2.7/h5py/defs.so
    /usr/bin/ld: /usr/local/lib/libpython2.7.a(abstract.o): relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a shared object; recompile with -fPIC
    /usr/local/lib/libpython2.7.a: could not read symbols: Bad value
    collect2: ld returned 1 exit status
    error: command 'gcc' failed with exit status 1
    
    ----------------------------------------
Command "/opt/rh/python27/root/usr/bin/python2 -c "import setuptools, tokenize;__file__='/tmp/pip-build-o43mj5/h5py/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-gST3pm-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-o43mj5/h5py
[root@pac ~]#
@andreabedini
Copy link
Contributor

@scarf I am not familiar with that error message, have you tried googling it?

@scarlion1
Copy link
Author

I did but not sure what it means. I think i could try adding "-fPIC" to the gcc command but do you know how to modify that part?
Thanks

@scarlion1
Copy link
Author

I found a way to download h5py and i updated setup.py and added extra_compile_args = ["-fPIC"], extra_link_args=["-fPIC"], to the end of setup() part but the final gcc command still doesn't have -fPIC in it and get the same error. maybe there is another way to add it?

@aragilar
Copy link
Member

How is your HDF5 built/where do you get HDF5 from?
I'm concerned about the static linking (linking to libpython.a not libpython.so), that could indicate there's some distutils change to your python install.
Anyhow, you could try adding adding the arguments to the dictionary in setup_build.py, rather than setup.py.

@scarlion1
Copy link
Author

I found we had an alias linking "python" to /usr/local/bin/python27 and so it wasn't using the right environment for the software channel python27.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants