Skip to content

undefined reference to pthread_create', pthread_detach, pthread_cancel, pthread_join` #1395

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

Closed
jiapei100 opened this issue Jul 22, 2021 · 9 comments
Labels
Module:OSS Build Issues building open source code triaged Issue has been triaged by maintainers

Comments

@jiapei100
Copy link

jiapei100 commented Jul 22, 2021

Description

Failed to build with the following error messages:

Linking CXX executable cmTC_a4f90
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_a4f90.dir/link.txt --verbose=1
/usr/local/bin/g++ -Wno-deprecated-declarations  -DBUILD_SYSTEM=cmake_oss  CMakeFiles/cmTC_a4f90.dir/src.cxx.o -o cmTC_a4f90 
/usr/bin/ld: CMakeFiles/cmTC_a4f90.dir/src.cxx.o: in function `main':
src.cxx:(.text+0x2d): undefined reference to `pthread_create'
/usr/bin/ld: src.cxx:(.text+0x39): undefined reference to `pthread_detach'
/usr/bin/ld: src.cxx:(.text+0x45): undefined reference to `pthread_cancel'
/usr/bin/ld: src.cxx:(.text+0x56): undefined reference to `pthread_join'
collect2: error: ld returned 1 exit status
make[1]: *** [CMakeFiles/cmTC_a4f90.dir/build.make:99: cmTC_a4f90] Error 1
make[1]: Leaving directory '....../TensorRT/build/CMakeFiles/CMakeTmp'
make: *** [Makefile:127: cmTC_a4f90/fast] Error 2

Environment

TensorRT Version: 8.0.1
NVIDIA GPU: GeForce RTX 2080 Ti
NVIDIA Driver Version: NVIDIA-SMI 460.84
CUDA Version: 11.3
CUDNN Version: 8.2.1
Operating System: Ubuntu 20.04
Python Version (if applicable): 3.8.10
Tensorflow Version (if applicable): 2.7.0
PyTorch Version (if applicable): 1.10.0
Baremetal or Container (if so, version): N/A

Relevant Files

....../TensorRT/build/CMakeFiles/CMakeTmp

Steps To Reproduce

Just build the source code via git clone.

@jiapei100 jiapei100 changed the title undefined reference to `pthread_create' undefined reference to pthread_create', pthread_detach, pthread_cancel, pthread_join` Jul 22, 2021
@bmfire1
Copy link

bmfire1 commented Jul 30, 2021

build you project with -pthread

@jiapei100
Copy link
Author

@bmfire1

Already linked with pthread by default. Still problematic.

@ttyio
Copy link
Collaborator

ttyio commented Aug 2, 2021

@ttyio ttyio added Module:OSS Build Issues building open source code Release: 8.x triaged Issue has been triaged by maintainers labels Aug 2, 2021
@tanndx17
Copy link

tanndx17 commented Sep 6, 2021

I had the same error, a little different

Linking CXX executable cmTC_ebefe
/usr/local/bin/cmake -E cmake_link_script CMakeFiles/cmTC_ebefe.dir/link.txt --verbose=1
/usr/bin/g++ -Wno-deprecated-declarations -DBUILD_SYSTEM=cmake_oss -DCMAKE_HAVE_LIBC_PTHREAD
CMakeFiles/cmTC_ebefe.dir/src.cxx.o -o cmTC_ebefe
CMakeFiles/cmTC_ebefe.dir/src.cxx.o: In function main': src.cxx:(.text+0x3e): undefined reference to pthread_create'
src.cxx:(.text+0x4a): undefined reference to pthread_detach' src.cxx:(.text+0x56): undefined reference to pthread_cancel'
src.cxx:(.text+0x67): undefined reference to pthread_join' src.cxx:(.text+0x7b): undefined reference to pthread_atfork'
collect2: error: ld returned 1 exit status
CMakeFiles/cmTC_ebefe.dir/build.make:106: recipe for target 'cmTC_ebefe' failed
make[1]: *** [cmTC_ebefe] Error 1
make[1]: Leaving directory '/data/TensorRT-8.0.1/build/CMakeFiles/CMakeTmp'
Makefile:141: recipe for target 'cmTC_ebefe/fast' failed
make: *** [cmTC_ebefe/fast] Error 2

How did you solved this?

@cherry-jam
Copy link

I had the same error too, using container

Linking CXX executable cmTC_10c48
/usr/local/bin/cmake -E cmake_link_script CMakeFiles/cmTC_10c48.dir/link.txt --verbose=1
/usr/bin/g++ -Wno-deprecated-declarations -DBUILD_SYSTEM=cmake_oss CMakeFiles/cmTC_10c48.dir/CheckSymbolExists.cxx.o -o cmTC_10c48
/usr/bin/ld: CMakeFiles/cmTC_10c48.dir/CheckSymbolExists.cxx.o: in function main': CheckSymbolExists.cxx:(.text+0x1f): undefined reference to pthread_create'
collect2: error: ld returned 1 exit status
make[1]: *** [CMakeFiles/cmTC_10c48.dir/build.make:87: cmTC_10c48] Error 1
make[1]: Leaving directory '/workspace/TensorRT-release-8.0/build/CMakeFiles/CMakeTmp'
make: *** [Makefile:121: cmTC_10c48/fast] Error 2

any news about this issue?

@styler00dollar
Copy link

styler00dollar commented Jan 31, 2022

I had a similar error.

git clone -b master https://github.com./nvidia/TensorRT TensorRT
cd TensorRT
git submodule update --init --recursive

mkdir -p build && cd build
export TRT_LIBPATH=/content/TensorRT-8.2.3.0
cmake .. -DTRT_LIB_DIR=$TRT_LIBPATH -DTRT_OUT_DIR=`pwd`/out
make -j$(nproc)
Run Build Command(s):/usr/bin/make -f Makefile cmTC_e9692/fast && /usr/bin/make  -f CMakeFiles/cmTC_e9692.dir/build.make CMakeFiles/cmTC_e9692.dir/build
make[1]: Entering directory '/content/TensorRT/build/CMakeFiles/CMakeTmp'
Building CXX object CMakeFiles/cmTC_e9692.dir/src.cxx.o
/usr/bin/g++ -DCMAKE_HAVE_LIBC_PTHREAD   -o CMakeFiles/cmTC_e9692.dir/src.cxx.o -c /content/TensorRT/build/CMakeFiles/CMakeTmp/src.cxx
Linking CXX executable cmTC_e9692
/usr/local/bin/cmake -E cmake_link_script CMakeFiles/cmTC_e9692.dir/link.txt --verbose=1
/usr/bin/g++ CMakeFiles/cmTC_e9692.dir/src.cxx.o -o cmTC_e9692 
CMakeFiles/cmTC_e9692.dir/src.cxx.o: In function `main':
src.cxx:(.text+0x3e): undefined reference to `pthread_create'
src.cxx:(.text+0x4a): undefined reference to `pthread_detach'
src.cxx:(.text+0x56): undefined reference to `pthread_cancel'
src.cxx:(.text+0x67): undefined reference to `pthread_join'
src.cxx:(.text+0x7b): undefined reference to `pthread_atfork'
collect2: error: ld returned 1 exit status
CMakeFiles/cmTC_e9692.dir/build.make:98: recipe for target 'cmTC_e9692' failed
make[1]: *** [cmTC_e9692] Error 1
make[1]: Leaving directory '/content/TensorRT/build/CMakeFiles/CMakeTmp'
Makefile:127: recipe for target 'cmTC_e9692/fast' failed
make: *** [cmTC_e9692/fast] Error 2

I solved it by replacing the variable with a path

cmake .. -DTRT_LIB_DIR=/content/TensorRT-8.2.3.0 -DTRT_OUT_DIR=/content/out

Edit:
It does actually compile a little and does not crash during cmake with that command, but it does crash later during compile. To fix that, use:

cmake .. -DTRT_LIB_DIR=/content/TensorRT-8.2.3.0/lib -DTRT_INC_DIR=/content/TensorRT-8.2.3.0/include -DTRT_OUT_DIR=/content/out

like this github issue suggested.

@jiapei100
Copy link
Author

jiapei100 commented Jan 31, 2022

Compatible with protobuf-3.19.4 ?
Can we ignore caffe ?

[ 56%] Building CXX object parsers/caffe/CMakeFiles/nvcaffeparser_static.dir/caffeParser/caffeParser.cpp.o
cd ....../TensorRT/build/parsers/caffe && /usr/local/bin/g++ -DGOOGLE_PROTOBUF_ARCH_64_BIT -Dgoogle=google_private -I/usr/local/cuda/include -I/include -I....../TensorRT/include -I....../TensorRT/parsers/caffe/. -I....../TensorRT/parsers/caffe/caffeParser -I....../TensorRT/parsers/caffe/caffeParser/opParsers -I....../TensorRT/parsers/caffe/caffeWeightFactory -I....../TensorRT/parsers/caffe/../common -I....../TensorRT/build/third_party.protobuf/include -I....../TensorRT/build/parsers/caffe/proto -Wno-deprecated-declarations  -DBUILD_SYSTEM=cmake_oss -O3 -DNDEBUG -std=c++11 -MD -MT parsers/caffe/CMakeFiles/nvcaffeparser_static.dir/caffeParser/caffeParser.cpp.o -MF CMakeFiles/nvcaffeparser_static.dir/caffeParser/caffeParser.cpp.o.d -o CMakeFiles/nvcaffeparser_static.dir/caffeParser/caffeParser.cpp.o -c ....../TensorRT/parsers/caffe/caffeParser/caffeParser.cpp
In file included from ....../TensorRT/parsers/caffe/caffeParser/caffeParser.cpp:23:
....../TensorRT/parsers/caffe/caffeParser/readProto.h: In function ‘bool nvcaffeparser1::readBinaryProto(trtcaffe::NetParameter*, const char*, size_t)’:
....../TensorRT/parsers/caffe/caffeParser/readProto.h:51:51: error: no matching function for call to ‘google_private::protobuf::io::CodedInputStream::SetTotalBytesLimit(int, int)’
   51 |     codedInput.SetTotalBytesLimit(int(bufSize), -1);
      |                                                   ^
In file included from ....../TensorRT/build/parsers/caffe/proto/trtcaffe.pb.h:23,
                 from ....../TensorRT/parsers/caffe/caffeWeightFactory/caffeWeightFactory.h:26,
                 from ....../TensorRT/parsers/caffe/caffeParser/caffeParser.h:26,
                 from ....../TensorRT/parsers/caffe/caffeParser/caffeParser.cpp:20:
....../TensorRT/build/third_party.protobuf/include/google/protobuf/io/coded_stream.h:406:8: note: candidate: ‘void google_private::protobuf::io::CodedInputStream::SetTotalBytesLimit(int)’
  406 |   void SetTotalBytesLimit(int total_bytes_limit);
      |        ^~~~~~~~~~~~~~~~~~
....../TensorRT/build/third_party.protobuf/include/google/protobuf/io/coded_stream.h:406:8: note:   candidate expects 1 argument, 2 provided
....../TensorRT/parsers/caffe/caffeParser/caffeParser.cpp: In member function ‘virtual const nvcaffeparser1::IBlobNameToTensor* nvcaffeparser1::CaffeParser::parseBuffers(const uint8_t*, std::size_t, const uint8_t*, std::size_t, nvinfer1::INetworkDefinition&, nvinfer1::DataType)’:
....../TensorRT/parsers/caffe/caffeParser/caffeParser.cpp:330:60: error: no matching function for call to ‘google_private::protobuf::io::CodedInputStream::SetTotalBytesLimit(std::size_t&, int)’
  330 |         codedModelStream.SetTotalBytesLimit(modelLength, -1);
      |                                                            ^
In file included from ....../TensorRT/build/parsers/caffe/proto/trtcaffe.pb.h:23,
                 from ....../TensorRT/parsers/caffe/caffeWeightFactory/caffeWeightFactory.h:26,
                 from ....../TensorRT/parsers/caffe/caffeParser/caffeParser.h:26,
                 from ....../TensorRT/parsers/caffe/caffeParser/caffeParser.cpp:20:
....../TensorRT/build/third_party.protobuf/include/google/protobuf/io/coded_stream.h:406:8: note: candidate: ‘void google_private::protobuf::io::CodedInputStream::SetTotalBytesLimit(int)’
  406 |   void SetTotalBytesLimit(int total_bytes_limit);
      |        ^~~~~~~~~~~~~~~~~~
....../TensorRT/build/third_party.protobuf/include/google/protobuf/io/coded_stream.h:406:8: note:   candidate expects 1 argument, 2 provided
....../TensorRT/parsers/caffe/caffeParser/caffeParser.cpp: In member function ‘virtual nvcaffeparser1::IBinaryProtoBlob* nvcaffeparser1::CaffeParser::parseBinaryProto(const char*)’:
....../TensorRT/parsers/caffe/caffeParser/caffeParser.cpp:627:46: error: no matching function for call to ‘google_private::protobuf::io::CodedInputStream::SetTotalBytesLimit(int, int)’
  627 |     codedInput.SetTotalBytesLimit(INT_MAX, -1);
      |                                              ^
In file included from ....../TensorRT/build/parsers/caffe/proto/trtcaffe.pb.h:23,
                 from ....../TensorRT/parsers/caffe/caffeWeightFactory/caffeWeightFactory.h:26,
                 from ....../TensorRT/parsers/caffe/caffeParser/caffeParser.h:26,
                 from ....../TensorRT/parsers/caffe/caffeParser/caffeParser.cpp:20:
....../TensorRT/build/third_party.protobuf/include/google/protobuf/io/coded_stream.h:406:8: note: candidate: ‘void google_private::protobuf::io::CodedInputStream::SetTotalBytesLimit(int)’
  406 |   void SetTotalBytesLimit(int total_bytes_limit);
      |        ^~~~~~~~~~~~~~~~~~
....../TensorRT/build/third_party.protobuf/include/google/protobuf/io/coded_stream.h:406:8: note:   candidate expects 1 argument, 2 provided
make[2]: *** [parsers/caffe/CMakeFiles/nvcaffeparser_static.dir/build.make:438: parsers/caffe/CMakeFiles/nvcaffeparser_static.dir/caffeParser/caffeParser.cpp.o] Error 1
make[2]: Leaving directory '....../TensorRT/build'
make[1]: *** [CMakeFiles/Makefile2:1399: parsers/caffe/CMakeFiles/nvcaffeparser_static.dir/all] Error 2
make[1]: Leaving directory '....../TensorRT/build'
make: *** [Makefile:159: all] Error 2

@nvpohanh
Copy link
Collaborator

@jiapei100 Did you compile this within the docker image we provide in README?

@nvpohanh
Copy link
Collaborator

nvpohanh commented Jul 1, 2022

Closing due to >14 days without activity. Please feel free to reopen if the issue still exists. Thanks

@nvpohanh nvpohanh closed this as completed Jul 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Module:OSS Build Issues building open source code triaged Issue has been triaged by maintainers
Projects
None yet
Development

No branches or pull requests

7 participants