问题:在Anaconda的环境下编译.pyx文件时遇到如下错误:
gcc -pthread -shared -B /opt/miniconda3/envs/xxx/compiler_compat -L/opt/miniconda3/envs/xxx/lib -Wl,-rpath=/opt/miniconda3/envs/xxx/lib -Wl,--no-as-needed -Wl,--sysroot=/ build/temp.linux-x86_64-2.7/xxx.o build/temp.linux-x86_64-2.7/xxx.o -L/opt/miniconda3/envs/xxx/lib -lm -lpython2.7 -o xxx.so
/opt/miniconda3/envs/xxx/compiler_compat/ld: build/temp.linux-x86_64-2.7/xxx.o: unable to initialize decompress status for section .debug_info
...
build/temp.linux-x86_64-2.7/xxx.o: file not recognized: file format not recognized
collect2: error: ld returned 1 exit status
error: command 'gcc' failed with exit status 1
解决方法:产生这个问题的原因是使用Anaconda环境中的compiler_compat造成的,解决方法是改用/usr/bin/:
gcc -pthread -shared -B /usr/bin/ -L/opt/miniconda3/envs/xxx/lib -Wl,-rpath=/opt/miniconda3/envs/xxx/lib -Wl,--no-as-needed -Wl,--sysroot=/ build/temp.linux-x86_64-2.7/xxx.o build/temp.linux-x86_64-2.7/xxx.o -L/opt/miniconda3/envs/xxx/lib -lm -lpython2.7 -o xxx.so