OpenPose linking error on std::thread - c++

So trying to build OpenPose from source, and was running into a linking problem. Current environment is Ubuntu 16.04.4. OpenCV version is 3.3.1. GCC version is 5.4.0.
[ 87%] Built target openpose
[ 87%] Linking CXX executable 1_extract_from_image.bin
[ 87%] Linking CXX executable openpose.bin
[ 87%] Linking CXX executable 3_user_input_processing_and_output.bin
[ 87%] Linking CXX executable 2_extract_pose_or_heatmat_from_image.bin
[ 87%] Linking CXX executable 1_custom_post_processing.bin
[ 87%] Linking CXX executable 2_user_processing_function.bin
[ 88%] Linking CXX executable 1_openpose_read_and_display.bin
/home/ubuntu/anaconda3/envs/tensorflow_p36/lib/libopencv_objdetect.so.3.3.1: undefined reference to std::thread::_State::~_State()#GLIBCXX_3.4.22
/home/ubuntu/anaconda3/envs/tensorflow_p36/lib/libopencv_objdetect.so.3.3.1: undefined reference to std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State> >, void (*)())#GLIBCXX_3.4.22
/home/ubuntu/anaconda3/envs/tensorflow_p36/lib/libopencv_objdetect.so.3.3.1: undefined reference to typeinfo for std::thread::_State#GLIBCXX_3.4.22
collect2: error: ld returned 1 exit status
examples/openpose/CMakeFiles/openpose.bin.dir/build.make:150: recipe for target 'examples/openpose/openpose.bin' failed
make[2]: *** [examples/openpose/openpose.bin] Error 1
CMakeFiles/Makefile2:1135: recipe for target 'examples/openpose/CMakeFiles/openpose.bin.dir/all' failed
make[1]: *** [examples/openpose/CMakeFiles/openpose.bin.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....

I just had the same issue and installed the latest versions of gcc and g++, which solved the problem. Like here:
https://askubuntu.com/a/789417
I just installed version 8 (thus gcc-8 and g++-8). Then you have to call update-alternatives as described there.

Related

opencv c++ fails the make -j4

I'm trying to install OpenCV in c++ locally on my machine with Ubuntu 20.04.5 LST following this manual.
The first two steps went good, but I'm stuck on the make -j4 substep of the third step. Running this command results in the following error message:
[ 83%] Linking CXX executable ../../bin/opencv_test_highgui
[ 83%] Built target opencv_test_calib3d
[ 83%] Built target opencv_perf_objdetect
[ 83%] Built target opencv_test_objdetect
[ 83%] Built target opencv_perf_stitching
[ 83%] Built target opencv_test_stitching
[ 83%] Built target opencv_perf_video
Scanning dependencies of target opencv_gapi
Scanning dependencies of target opencv_interactive-calibration
[ 83%] Built target opencv_test_video
[ 83%] Building CXX object apps/interactive-calibration/CMakeFiles/opencv_interactive-calibration.dir/calibController.cpp.o
[ 83%] Building CXX object apps/interactive-calibration/CMakeFiles/opencv_interactive-calibration.dir/calibPipeline.cpp.o
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/libfontconfig.so: undefined reference to `uuid_parse#UUID_1.0'
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/libfontconfig.so: undefined reference to `uuid_generate_random#UUID_1.0'
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/libfontconfig.so: undefined reference to `uuid_unparse#UUID_1.0'
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/libfontconfig.so: undefined reference to `uuid_copy#UUID_1.0'
collect2: error: ld returned 1 exit status
make[2]: *** [modules/highgui/CMakeFiles/opencv_test_highgui.dir/build.make:122: bin/opencv_test_highgui] Error 1
make[1]: *** [CMakeFiles/Makefile2:2958: modules/highgui/CMakeFiles/opencv_test_highgui.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 83%] Building CXX object apps/interactive-calibration/CMakeFiles/opencv_interactive-calibration.dir/frameProcessor.cpp.o
[ 83%] Building CXX object modules/gapi/CMakeFiles/opencv_gapi.dir/src/api/grunarg.cpp.o
[ 83%] Building CXX object apps/interactive-calibration/CMakeFiles/opencv_interactive-calibration.dir/main.cpp.o
[ 83%] Building CXX object apps/interactive-calibration/CMakeFiles/opencv_interactive-calibration.dir/parametersController.cpp.o
[ 83%] Building CXX object apps/interactive-calibration/CMakeFiles/opencv_interactive-calibration.dir/rotationConverters.cpp.o
[ 83%] Building CXX object modules/gapi/CMakeFiles/opencv_gapi.dir/src/api/gorigin.cpp.o
[ 83%] Building CXX object modules/gapi/CMakeFiles/opencv_gapi.dir/src/api/gmat.cpp.o
[ 83%] Building CXX object modules/gapi/CMakeFiles/opencv_gapi.dir/src/api/garray.cpp.o
[ 83%] Linking CXX executable ../../bin/opencv_interactive-calibration
I found this answer to get the missing libraries, but as I see its for the red hat, and I need it for Ubuntu.
Thanks in advance for any help.
I suppose you are in need of the uuid-dev package. Try running:
sudo apt install uuid-dev

trying to update TWSAPI.. getting error on linking? is this the new intel lib?

I utilize a conan recipe to build the TWS-API in C++ .. and recently (4-10 months ago) IBKR pushed in a prebuilt library into the mix.. some intel lib..
I tried to fix all the code , refresh function definitions.. but on linking I am getting stuck
...
-- Library z found /home/emcp/.conan/data/zlib/1.2.12/_/_/package/dfbe50feef7f3c6223a476cd5aeadb687084a646/lib/libz.a
-- Library bz2 found /home/emcp/.conan/data/bzip2/1.0.8/_/_/package/c32092bf4d4bb47cf962af898e02823f499b017e/lib/libbz2.a
-- Library backtrace found /home/emcp/.conan/data/libbacktrace/cci.20210118/_/_/package/dfbe50feef7f3c6223a476cd5aeadb687084a646/lib/libbacktrace.a
-- Library ssl found /home/emcp/.conan/data/openssl/1.1.1o/_/_/package/dfbe50feef7f3c6223a476cd5aeadb687084a646/lib/libssl.a
-- Library crypto found /home/emcp/.conan/data/openssl/1.1.1o/_/_/package/dfbe50feef7f3c6223a476cd5aeadb687084a646/lib/libcrypto.a
-- Conan: Adjusting default RPATHs Conan policies
-- Conan: Adjusting language standard
-- Current conanbuildinfo.cmake directory: /home/emcp/git/build_cmake
-- Conan: Compiler GCC>=5, checking major version 11
-- Conan: Checking correct version: 11
-- Configuring done
-- Generating done
-- Build files have been written to: /home/emcp/Dev/git/build_cmake
[ 12%] Building CXX object CMakeFiles/ibrokers_server.dir/src/ibrokers_server.cpp.o
[ 25%] Building CXX object CMakeFiles/ibrokers_server.dir/src/gen-cpp/ibrokers.cpp.o
[ 37%] Building CXX object CMakeFiles/ibrokers_server.dir/src/gen-cpp/ibrokers_types.cpp.o
[ 50%] Building CXX object CMakeFiles/ibrokers_server.dir/src/tws-client/AccountSummaryTags.cpp.o
[ 62%] Building CXX object CMakeFiles/ibrokers_server.dir/src/tws-client/AvailableAlgoParams.cpp.o
[ 75%] Building CXX object CMakeFiles/ibrokers_server.dir/src/tws-client/TestCppClient.cpp.o
[ 87%] Building CXX object CMakeFiles/ibrokers_server.dir/src/tws-client/Utils.cpp.o
[100%] Linking CXX executable bin/ibrokers_server
/usr/bin/ld: CMakeFiles/ibrokers_server.dir/src/tws-client/TestCppClient.cpp.o: in function `decimalStringToDisplay[abi:cxx11](unsigned long long)':
TestCppClient.cpp:(.text._Z22decimalStringToDisplayB5cxx11y[_Z22decimalStringToDisplayB5cxx11y]+0x46): undefined reference to `__bid64_to_string'
/usr/bin/ld: /home/emcp/.conan/data/twsapi/10.17.01/stonks/prod/package/062863c92a5a0a247840166e9f84ebe8d10786b9/lib/libtwsapi.a(EClient.cpp.o): in function `void EClient::EncodeField<unsigned long long>(std::ostream&, unsigned long long)':
EClient.cpp:(.text+0x52e): undefined reference to `__bid64_to_string'
/usr/bin/ld: /home/emcp/.conan/data/twsapi/10.17.01/stonks/prod/package/062863c92a5a0a247840166e9f84ebe8d10786b9/lib/libtwsapi.a(EDecoder.cpp.o): in function `EDecoder::DecodeField(unsigned long long&, char const*&, char const*)':
EDecoder.cpp:(.text+0x803c): undefined reference to `__bid64_from_string'
collect2: error: ld returned 1 exit status
gmake[2]: *** [CMakeFiles/ibrokers_server.dir/build.make:247: bin/ibrokers_server] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/ibrokers_server.dir/all] Error 2
gmake: *** [Makefile:91: all] Error 2
chmod: cannot access 'ibrokers_server': No such file or directory
Is there a way I can .. ensure or refresh my conan cache other than erase the build area and do
conan install .. --upgrade
?
according to this post https://github.com/InteractiveBrokers/tws-api/issues/1150#issuecomment-1215515313
we have a problem with the new intel code not linking properly.. this user was on Debian and was able to apt install the library.. and link it manually
sudo apt install libintelrdfpmath-dev
and in your linker.. add this module
bidgcc000

Cannot find lpublic library

Trying to compile my project on Centos 8.2 using cmake 3.12, im facing with the following error:
cannot find -lpublic
here is full log:
[ 20%] Building CXX object CMakeFiles/ .cpp.o
[ 40%] Building CXX object CMakeFiles/ .cpp.o
[ 60%] Linking CXX shared library .so
[ 60%] Built target myproj
Scanning dependencies of target nist01
[ 80%] Building CXX object CMakeFiles/ .cpp.o
[100%] Linking CXX executable
/usr/bin/ld: cannot find -lpublic
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/nist01.dir/build.make:85: ...] Error 1
make[1]: *** [CMakeFiles/Makefile2:105: CMakeFiles/...] Error 2
make: *** [Makefile:84: all] Error 2
Tried to find something on the internet, but nothing shown up.
Thanks for your help.
That seems like you try to link against the target "public", which is a suspicious target name. It might be target_link_libraries command with lowercase public instead of uppercase one, like target_link_libraryies(nist01 public something) instead of target_link_libraries(nist01 PUBLIC something).

Overcoming "undefined reference" error in cmake - a package is being requested by cmake and I have the package available

cmake says I have an undefined reference to gzopen64#ZLIB_1.2.3.3. I built zlib 1.2.3.3 from source, added the include directory to CPATH, added the lib directory to LD_LIBRARY_PATH, and pasted libz.so.1.2.3.3 into my build directory. I am still stuck on this error. Is there any other way I can lead cmake to the zlib 1.2.3.3 build?
Edit
OK here's the full error message:
$ make
Scanning dependencies of target utilscore
[ 4%] Building CXX object src/core/CMakeFiles/utilscore.dir/CFDMesh.cpp.o
[ 8%] Linking CXX static library libutilscore.a
[ 8%] Built target utilscore
Scanning dependencies of target nalu_preprocess
[ 13%] Building CXX object src/preprocessing/CMakeFiles/nalu_preprocess.dir/PreProcessingTask.cpp.o
[ 17%] Building CXX object src/preprocessing/CMakeFiles/nalu_preprocess.dir/NDTW2D.cpp.o
[ 21%] Building CXX object src/preprocessing/CMakeFiles/nalu_preprocess.dir/SamplingPlanes.cpp.o
[ 26%] Building CXX object src/preprocessing/CMakeFiles/nalu_preprocess.dir/ABLFields.cpp.o
[ 30%] Building CXX object src/preprocessing/CMakeFiles/nalu_preprocess.dir/ChannelFields.cpp.o
[ 34%] Building CXX object src/preprocessing/CMakeFiles/nalu_preprocess.dir/RotateMesh.cpp.o
[ 39%] Building CXX object src/preprocessing/CMakeFiles/nalu_preprocess.dir/BdyIOPlanes.cpp.o
[ 43%] Building CXX object src/preprocessing/CMakeFiles/nalu_preprocess.dir/PreProcessDriver.cpp.o
[ 47%] Building CXX object src/preprocessing/CMakeFiles/nalu_preprocess.dir/nalu_preprocess.cpp.o
[ 52%] Linking CXX executable nalu_preprocess
CMakeFiles/nalu_preprocess.dir/BdyIOPlanes.cpp.o: In function `stk::mesh::Bucket::begin_nodes(unsigned long) const':
/projects/windsim/exawind/SharedSoftwareA/spack/opt/spack/linux-centos6-x86_64/gcc-5.2.0/trilinos-develop-aeyspdjmeoo5inhcb7cpaojmrds7f6tt/include/stk_mesh/base/Bucket.hpp:306: undefined reference to `stk::mesh::Bucket::check_for_invalid_connectivity_request(stk::mesh::ConnectivityType const*) const'
/projects/windsim/exawind/SharedSoftwareA/spack/opt/spack/linux-centos6-x86_64/gcc-5.2.0/libxml2-2.9.4-ek3x27doaf3vg2izm363k755zy7nd67z/lib/libxml2.so.2: undefined reference to `gzopen64#ZLIB_1.2.3.3'
collect2: error: ld returned 1 exit status
make[2]: *** [src/preprocessing/nalu_preprocess] Error 1
make[1]: *** [src/preprocessing/CMakeFiles/nalu_preprocess.dir/all] Error 2
I understand there are similar questions about undefined reference errors. I'm not convinced this is a duplicate question. This answer nicely lays out all the possible causes of an undefined reference. I didn't find one that matched my specific situation, where a package is being requested by cmake and I have the package available.

Cannot build opencv 2.4 on a 64 bit mac for C++ project in Xcode

After looking around a lot and trying every option I found on SO, I'm a little confused about how to get the OpenCV library for architecture x86_64 loaded on my Mac. Here's a little bit of background info:
The first folder contains the Android SDK. The second is the iPhone framework, which uses i386 and armv7 architectures.
Now, I want to create a simple "Hello World" C++ application in Xcode which needs the correct library for x86_64 architecture.
I've looked at this tutorial as well as others' posted steps as follows:
mkdir build
cd build
cmake -G "Unix Makefiles" ..
make -j8
sudo make install
With all version (except OpenCV-2.4.6.1), the process fails at "make -j8". I get the same error every time:
Linking CXX shared library ../../lib/libopencv_core.dylib
Undefined symbols for architecture x86_64:
"___sincos_stret", referenced from:
cv::RotatedRect::points(cv::Point_<float>*) const in matrix.cpp.o
cv::RotatedRect::boundingRect() const in matrix.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [lib/libopencv_core.2.4.3.dylib] Error 1
make[1]: *** [modules/core/CMakeFiles/opencv_core.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 28%] Building CXX object 3rdparty/openexr/CMakeFiles/IlmImf.dir/IlmImf/ImfThreading.cpp.o
[ 28%] Building CXX object 3rdparty/openexr/CMakeFiles/IlmImf.dir/IlmImf/ImfTileDescriptionAttribute.cpp.o
[ 28%] Building CXX object 3rdparty/openexr/CMakeFiles/IlmImf.dir/IlmImf/ImfTiledInputFile.cpp.o
[ 29%] Building CXX object 3rdparty/openexr/CMakeFiles/IlmImf.dir/IlmImf/ImfTiledMisc.cpp.o
[ 29%] Building CXX object 3rdparty/openexr/CMakeFiles/IlmImf.dir/IlmImf/ImfTiledOutputFile.cpp.o
[ 29%] Building CXX object 3rdparty/openexr/CMakeFiles/IlmImf.dir/IlmImf/ImfTiledRgbaFile.cpp.o
[ 29%] Building CXX object 3rdparty/openexr/CMakeFiles/IlmImf.dir/IlmImf/ImfTileOffsets.cpp.o
[ 29%] Building CXX object 3rdparty/openexr/CMakeFiles/IlmImf.dir/IlmImf/ImfTimeCode.cpp.o
[ 29%] Building CXX object 3rdparty/openexr/CMakeFiles/IlmImf.dir/IlmImf/ImfTimeCodeAttribute.cpp.o
[ 29%] Building CXX object 3rdparty/openexr/CMakeFiles/IlmImf.dir/IlmImf/ImfVecAttribute.cpp.o
[ 29%] Building CXX object 3rdparty/openexr/CMakeFiles/IlmImf.dir/IlmImf/ImfVersion.cpp.o
[ 29%] [ 30%] Building CXX object 3rdparty/openexr/CMakeFiles/IlmImf.dir/IlmImf/ImfWav.cpp.o
Building CXX object 3rdparty/openexr/CMakeFiles/IlmImf.dir/IlmImf/ImfZipCompressor.cpp.o
Linking CXX static library ../lib/libIlmImf.a
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../lib/libIlmImf.a(IlmThread.cpp.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../lib/libIlmImf.a(IlmThreadMutex.cpp.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../lib/libIlmImf.a(IlmThreadSemaphore.cpp.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../lib/libIlmImf.a(IlmThreadSemaphorePosixCompat.cpp.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../lib/libIlmImf.a(IlmThread.cpp.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../lib/libIlmImf.a(IlmThreadMutex.cpp.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../lib/libIlmImf.a(IlmThreadSemaphore.cpp.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../lib/libIlmImf.a(IlmThreadSemaphorePosixCompat.cpp.o) has no symbols
[ 30%] Built target IlmImf
make: *** [all] Error 2
pdls-mbp:build pdl$
With OpenCV-2.4.6.1, the process fails at "sudo make install" and I get the following error:
Linking CXX shared library ../../lib/libopencv_core.dylib
Undefined symbols for architecture x86_64:
"___sincos_stret", referenced from:
cv::RotatedRect::points(cv::Point_<float>*) const in matrix.cpp.o
cv::RotatedRect::boundingRect() const in matrix.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [lib/libopencv_core.2.4.6.dylib] Error 1
make[1]: *** [modules/core/CMakeFiles/opencv_core.dir/all] Error 2
make: *** [all] Error 2
Lucys-MacBook-Pro:build pdl$
When I installed OpenCV using Homebrew, opencv was installed in use/local/opt/opencv and I can see all of the dylib files under the lib folder:
All of this completely confuses me, because I think all I need is a .a library file, no?
I have found the dylib files that were installed with HomeBrew in /usr/local/Cellar/opencv/2.4.6.1/lib but when I try to choose frameworks and libraries to add, they do not show up in the list. Instead, this is all I see:
Aldo, been following this MacPorts tutorial.
Have you considered using macports? It has opencv 2.4.8 available.
So after installing macports, all that nonsense you've been through, is reduced to:
$ sudo port selfupdate
$ sudo port install opencv
if you want a variant or two, for example OpenCL and Python support, then that would be:
$ sudo port install opencv +opencl +python27
and the binaries/libraries/whatever will be installed into /opt/local/....