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

Build error: /usr/bin/ld: cannot find /path/to/miniconda3/envs/k2s/lib: File format not recognized #15

Closed
EmreOzkose opened this issue Nov 2, 2021 · 8 comments

Comments

@EmreOzkose
Copy link

Hi,

I am trying to install package from source. I set cmake arguments like this*. However I got "" error.

-- Generating done
-- Build files have been written to: /path/to/k2/kaldifeat/build/temp.linux-x86_64-3.8
Scanning dependencies of target kaldifeat_core
[  5%] Building CXX object kaldifeat/csrc/CMakeFiles/kaldifeat_core.dir/feature-fbank.cc.o
[ 11%] Building CXX object kaldifeat/csrc/CMakeFiles/kaldifeat_core.dir/feature-functions.cc.o
[ 16%] Building CXX object kaldifeat/csrc/CMakeFiles/kaldifeat_core.dir/feature-mfcc.cc.o
[ 22%] Building CXX object kaldifeat/csrc/CMakeFiles/kaldifeat_core.dir/feature-plp.cc.o
[ 27%] Building CXX object kaldifeat/csrc/CMakeFiles/kaldifeat_core.dir/feature-spectrogram.cc.o
[ 33%] Building CXX object kaldifeat/csrc/CMakeFiles/kaldifeat_core.dir/feature-window.cc.o
[ 38%] Building CXX object kaldifeat/csrc/CMakeFiles/kaldifeat_core.dir/matrix-functions.cc.o
[ 44%] Building CXX object kaldifeat/csrc/CMakeFiles/kaldifeat_core.dir/mel-computations.cc.o
[ 50%] Linking CXX shared library ../../lib/libkaldifeat_core.so
/usr/bin/ld: cannot find /path/to/miniconda3/envs/k2s/lib: File format not recognized
collect2: error: ld returned 1 exit status
kaldifeat/csrc/CMakeFiles/kaldifeat_core.dir/build.make:203: recipe for target 'lib/libkaldifeat_core.so' failed
make[3]: *** [lib/libkaldifeat_core.so] Error 1
CMakeFiles/Makefile2:393: recipe for target 'kaldifeat/csrc/CMakeFiles/kaldifeat_core.dir/all' failed
make[2]: *** [kaldifeat/csrc/CMakeFiles/kaldifeat_core.dir/all] Error 2
CMakeFiles/Makefile2:454: recipe for target 'kaldifeat/python/csrc/CMakeFiles/_kaldifeat.dir/rule' failed
make[1]: *** [kaldifeat/python/csrc/CMakeFiles/_kaldifeat.dir/rule] Error 2
Makefile:220: recipe for target '_kaldifeat' failed
make: *** [_kaldifeat] Error 2

  • export KALDIFEAT_CMAKE_ARGS='-DCMAKE_BUILD_TYPE=Release -DCUDNN_LIBRARY_PATH="path/to/miniconda3/envs/k2s/lib" -DCUDNN_INCLUDE_PATH="path/to/miniconda3/envs/k2s/include"'
@csukuangfj
Copy link
Owner

Which version of cmake are you using?

Looks like CMake did not add -L to the lib path.

@EmreOzkose
Copy link
Author

cmake version is 3.16.3

@EmreOzkose
Copy link
Author

I noticed that, somehow, cmake cannot see libpthread
Screenshot from 2021-11-02 14-45-58

I will try to fix this.

@EmreOzkose
Copy link
Author

The output of cat CMakeFiles/CMakeError.log:

Performing C SOURCE FILE Test CMAKE_HAVE_LIBC_PTHREAD failed with the following output:
Change Dir: /path/to/k2/kaldifeat/build/temp.linux-x86_64-3.8/CMakeFiles/CMakeTmp

Run Build Command(s):/usr/bin/make cmTC_f1a96/fast && /usr/bin/make -f CMakeFiles/cmTC_f1a96.dir/build.make CMakeFiles/cmTC_f1a96.dir/build
make[1]: Entering directory '/path/to/k2/kaldifeat/build/temp.linux-x86_64-3.8/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_f1a96.dir/src.c.o
/usr/bin/cc   -DCMAKE_HAVE_LIBC_PTHREAD   -o CMakeFiles/cmTC_f1a96.dir/src.c.o   -c /path/to/k2/kaldifeat/build/temp.linux-x86_64-3.8/CMakeFiles/CMakeTmp/src.c
Linking C executable cmTC_f1a96
/usr/local/bin/cmake -E cmake_link_script CMakeFiles/cmTC_f1a96.dir/link.txt --verbose=1
/usr/bin/cc  -DCMAKE_HAVE_LIBC_PTHREAD    CMakeFiles/cmTC_f1a96.dir/src.c.o  -o cmTC_f1a96 
CMakeFiles/cmTC_f1a96.dir/src.c.o: In function `main':
src.c:(.text+0x3e): undefined reference to `pthread_create'
src.c:(.text+0x4a): undefined reference to `pthread_detach'
src.c:(.text+0x5b): undefined reference to `pthread_join'
src.c:(.text+0x6f): undefined reference to `pthread_atfork'
collect2: error: ld returned 1 exit status
CMakeFiles/cmTC_f1a96.dir/build.make:86: recipe for target 'cmTC_f1a96' failed
make[1]: *** [cmTC_f1a96] Error 1
make[1]: Leaving directory '/path/to/k2/kaldifeat/build/temp.linux-x86_64-3.8/CMakeFiles/CMakeTmp'
Makefile:121: recipe for target 'cmTC_f1a96/fast' failed
make: *** [cmTC_f1a96/fast] Error 2


Source file was:
#include <pthread.h>

void* test_func(void* data)
{
  return data;
}

int main(void)
{
  pthread_t thread;
  pthread_create(&thread, NULL, test_func, NULL);
  pthread_detach(thread);
  pthread_join(thread, NULL);
  pthread_atfork(NULL, NULL, NULL);
  pthread_exit(NULL);

  return 0;
}

Determining if the function pthread_create exists in the pthreads failed with the following output:
Change Dir: /path/to/k2/kaldifeat/build/temp.linux-x86_64-3.8/CMakeFiles/CMakeTmp

Run Build Command(s):/usr/bin/make cmTC_2145e/fast && /usr/bin/make -f CMakeFiles/cmTC_2145e.dir/build.make CMakeFiles/cmTC_2145e.dir/build
make[1]: Entering directory '/path/to/k2/kaldifeat/build/temp.linux-x86_64-3.8/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_2145e.dir/CheckFunctionExists.c.o
/usr/bin/cc   -DCHECK_FUNCTION_EXISTS=pthread_create   -o CMakeFiles/cmTC_2145e.dir/CheckFunctionExists.c.o   -c /usr/local/share/cmake-3.16/Modules/CheckFunctionExists.c
Linking C executable cmTC_2145e
/usr/local/bin/cmake -E cmake_link_script CMakeFiles/cmTC_2145e.dir/link.txt --verbose=1
/usr/bin/cc  -DCHECK_FUNCTION_EXISTS=pthread_create    CMakeFiles/cmTC_2145e.dir/CheckFunctionExists.c.o  -o cmTC_2145e  -lpthreads 
/usr/bin/ld: cannot find -lpthreads
collect2: error: ld returned 1 exit status
CMakeFiles/cmTC_2145e.dir/build.make:86: recipe for target 'cmTC_2145e' failed
make[1]: *** [cmTC_2145e] Error 1
make[1]: Leaving directory '/path/to/k2/kaldifeat/build/temp.linux-x86_64-3.8/CMakeFiles/CMakeTmp'
Makefile:121: recipe for target 'cmTC_2145e/fast' failed
make: *** [cmTC_2145e/fast] Error 2

Error : /usr/bin/ld: cannot find -lpthreads.

pthreads is already installed, there is /usr/lib/x86_64-linux-gnu/libpthread.so file.

@csukuangfj
Copy link
Owner

Can you have a look at https://stackoverflow.com/questions/31948521/building-error-using-cmake-cannot-find-lpthreads ?

I have not seen this problem before.

Changing

target_link_libraries(kaldifeat_core PUBLIC ${TORCH_LIBRARIES})

to

 target_link_libraries(kaldifeat_core PUBLIC ${TORCH_LIBRARIES} -pthreads) 

might help.

@EmreOzkose
Copy link
Author

EmreOzkose commented Nov 2, 2021

target_link_libraries(kaldifeat_core PUBLIC ${TORCH_LIBRARIES} -pthreads) gives
Screenshot from 2021-11-02 16-45-23

I also tried these:
target_link_libraries(kaldifeat_core PUBLIC ${TORCH_LIBRARIES} -pthread)
target_link_libraries(kaldifeat_core PUBLIC ${TORCH_LIBRARIES} -lpthread)

, but the problem is not changed.

@EmreOzkose
Copy link
Author

EmreOzkose commented Nov 2, 2021

I tired installation on different machine, and it works (cmake versions are same). So it is somehow machine-related problem. Hence I am closing this issue. If I can solve, I will update the issue.

@csukuangfj
Copy link
Owner

export KALDIFEAT_CMAKE_ARGS='-DCMAKE_BUILD_TYPE=Release -DCUDNN_LIBRARY_PATH="path/to/miniconda3/envs/k2s/lib" -DCUDNN_INCLUDE_PATH="path/to/miniconda3/envs/k2s/include"'

By the way, it should be

-DCUDNN_LIBRARY_PATH="path/to/miniconda3/envs/k2s/lib/libcudnn.so" 

Please see k2-fsa/icefall#120 (comment)

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

2 participants