0

I'm trying to compile a third-party package on my Ubuntu 16.04 system in order to use it in Anaconda which is the default Python environment. When I run make the compilation stops with the following error:

/home/myname/anaconda3/compiler_compat/ld: cannot find -lfftw3_omp
/home/myname/anaconda3/compiler_compat/ld: cannot find -lm
collect2: error: ld returned 1 exit status
error: command 'gcc' failed with exit status 1
Makefile:109: recipe for target '_shtns.so' failed
make: *** [_shtns.so] Error 1

It seems that Anaconda does not have access to the two libraries mentioned in the error message. The library fftw3_omp.so definitely exists in the folder /home/myname/usr/lib. I'm not sure what -lm is, though. How can I link the missing libraries correctly?

Ethunxxx
  • 1,229
  • 4
  • 16
  • 34

1 Answers1

2

I got the similar error:

/home/sfchen/anaconda3/envs/dlpy2/compiler_compat/ld: cannot find -lpthread /home/sfchen/anaconda3/envs/dlpy2/compiler_compat/ld: cannot find -lc

and solved by follow steps.

  1. find the root of the lib (e.g. lpthread)

    ld -lpthread --verbose

output like this:

attempt to open //usr/local/lib/x86_64-linux-gnu/libpthread.so failed
attempt to open //usr/local/lib/x86_64-linux-gnu/libpthread.a failed
attempt to open //lib/x86_64-linux-gnu/libpthread.so failed
attempt to open //lib/x86_64-linux-gnu/libpthread.a failed
attempt to open //usr/lib/x86_64-linux-gnu/libpthread.so succeeded
opened script file //usr/lib/x86_64-linux-gnu/libpthread.so
opened script file //usr/lib/x86_64-linux-gnu/libpthread.so
attempt to open /lib/x86_64-linux-gnu/libpthread.so.0 succeeded
/lib/x86_64-linux-gnu/libpthread.so.0
attempt to open /usr/lib/x86_64-linux-gnu/libpthread_nonshared.a succeeded
libc.so.6 needed by /lib/x86_64-linux-gnu/libpthread.so.0
found libc.so.6 at //lib/x86_64-linux-gnu/libc.so.6
ld-linux-x86-64.so.2 needed by /lib/x86_64-linux-gnu/libpthread.so.0
found ld-linux-x86-64.so.2 at //lib/x86_64-linux-gnu/ld-linux-x86-64.so.2
ld: warning: cannot find entry symbol _start; not setting start address
  1. From the 5th line above

attempt to open //usr/lib/x86_64-linux-gnu/libpthread.so succeeded

get the path1 = /usr/lib/x86_64-linux-gnu/libpthread.so

  1. From the error message: /home/sfchen/anaconda3/envs/dlpy2/compiler_compat/ld: cannot find -lpthread

get the path2 = /home/sfchen/anaconda3/envs/dlpy2/compiler_compat/

  1. Last, input like this :

    ln -s path1 path2

Specifically,

ln -s /usr/lib/x86_64-linux-gnu/libpthread.so /home/sfchen/anaconda3/envs/dlpy2/compiler_compat/

that's all, hope it may be helpful!

one
  • 2,205
  • 1
  • 15
  • 37