AtomDB / pyatomdb

AtomDB project (www.atomdb.org)
Docs: atomdb.readthedocs.io
Other
32 stars 12 forks source link

[SOLVED] Install Problem with Anaconda: "lib64/crti.o: file not recognized: file format not recognized" #18

Closed alexkolo closed 5 years ago

alexkolo commented 5 years ago

Below is the full error message. Any ideas?

FYI, same result when using pip.

$ python setup.py install --user
running install
running bdist_egg
running egg_info
writing pyatomdb.egg-info/PKG-INFO
writing dependency_links to pyatomdb.egg-info/dependency_links.txt
writing requirements to pyatomdb.egg-info/requires.txt
writing top-level names to pyatomdb.egg-info/top_level.txt
reading manifest file 'pyatomdb.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'pyatomdb.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_py
running build_ext
building 'linear_approx' extension
gcc -pthread -B /anaconda3/envs/science/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DMAJOR_VERSION=1 -DMINOR_VERSION=0 -I/anaconda3/envs/science/include/python3.6m -c linear_approx.c -o build/temp.linux-x86_64-3.6/linear_approx.o
gcc -pthread -shared -B /anaconda3/envs/science/compiler_compat -L/anaconda3/envs/science/lib -Wl,-rpath=/anaconda3/envs/science/lib -Wl,--no-as-needed -Wl,--sysroot=/ build/temp.linux-x86_64-3.6/linear_approx.o -o build/lib.linux-x86_64-3.6/linear_approx.cpython-36m-x86_64-linux-gnu.so
/anaconda3/envs/science/compiler_compat/ld: /usr/lib64/../lib64/crti.o: unable to initialize decompress status for section .debug_aranges
/anaconda3/envs/science/compiler_compat/ld: /usr/lib64/../lib64/crti.o: unable to initialize decompress status for section .debug_aranges
/anaconda3/envs/science/compiler_compat/ld: /usr/lib64/../lib64/crti.o: unable to initialize decompress status for section .debug_aranges
/anaconda3/envs/science/compiler_compat/ld: /usr/lib64/../lib64/crti.o: unable to initialize decompress status for section .debug_aranges
/usr/lib64/../lib64/crti.o: file not recognized: file format not recognized
collect2: error: ld returned 1 exit status
error: command 'gcc' failed with exit status 1
jagophile commented 5 years ago

Uh... yikes.

My initial guess (and it's a guess!) is that this is to do with the C compiler. Anaconda is trying to use a combination of the system and it's own gcc in a confused manner, and therefore it can't find some internal libraries it's looking for.

I can't give you a cleaner answer than that as I don't really know - it's an Anaconda gcc issue, not pyatomdb, and it's way beyond my expertise.

One suggestion which might work is manually compiling the c code.

Find the file linear_approx.c and change to its directory then: gcc -shared -o linear_approx.so -fPIC linear_approx.c

maybe that'll work?

alexkolo commented 5 years ago

Thanks. I will try this and also look into anaconda gcc issue.

jagophile commented 5 years ago

I think it's something to do with 32 vs 64 bit compiled libraries, but don't quote me on that

alexkolo commented 5 years ago

so this gcc -shared -o linear_approx.so -fPIC linear_approx.c worked. import pyatomdb didn't give an error. I'm currently running pyatomdb.util.initialize() (downloading some files). I will update here, if I run into any issues.

alexkolo commented 5 years ago

So far, everything works fine. I was able to reproduce the emissivity of XSPEC to high accuracy.

jagophile commented 5 years ago

Great. I am going to close this, though I know it's not exactly fixed as such.

alexkolo commented 4 years ago

So, I had the same issue stated here when installing a totally different python package, where something needed to be compiled during the installation. Based on this I found a solution, which also works here. One needs to install anacondas most recent compiler before the package installation:

conda install -c anaconda gcc_linux-64

The inspiration came when studying this site:

jagophile commented 4 years ago

Thank you! This is great to know for the future.

awst-baum commented 4 years ago

Since I stumbled over this while searching for the same error in another package: This seems to be cause by conda using its own ld. It can also be fixed by removing that linker and replacing it with a link to the system linker, see https://github.com/pytorch/pytorch/issues/16683#issuecomment-459982988

alexkolo commented 4 years ago

Thanks a lot for this comment. This also explains why installing anacondas most recent compiler solved the issue, which is probably also the safer fix in comparison to temporarily renaming conda's own ld as suggested in https://github.com/pytorch/pytorch/issues/16683