PointCloudLibrary / PointCloudLibrary/pcl

[compile error] Linker errors when building static libs with `PCL_BUIILD_SHARED=OFF`

Open
#4,377 8 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

kind: compile error module: cmake needs: testing platform: linux skill: cmake
Dominant language
C++
Stars
11.1k
Forks
4.7k
Avg merge
4d 10h
Merged PRs (30d)
6

Description

Describe the error

Compilation of 1.11.0 fails when build configured with cmake .. -DPCL_SHARED_LIBS=OFF -DWITH_OPENGL=OFF -DCMAKE_VERBOSE_MAKEFILE=1.

The errors are of the form

/usr/lib/x86_64-linux-gnu/libpthread.a(ptw-write.o): In function `__write_nocancel':
/build/glibc-e6zv40/glibc-2.23/nptl/../sysdeps/unix/syscall-template.S:84: undefined reference to `__syscall_error'
/build/glibc-e6zv40/glibc-2.23/nptl/../sysdeps/unix/syscall-template.S:84: undefined reference to `__syscall_error'
/usr/lib/x86_64-linux-gnu/libpthread.a(ptw-read.o): In function `__read_nocancel':
/build/glibc-e6zv40/glibc-2.23/nptl/../sysdeps/unix/syscall-template.S:84: undefined reference to `__syscall_error'
/build/glibc-e6zv40/glibc-2.23/nptl/../sysdeps/unix/syscall-template.S:84: undefined reference to `__syscall_error'
/usr/lib/x86_64-linux-gnu/libpthread.a(ptw-close.o): In function `__close_nocancel':
/build/glibc-e6zv40/glibc-2.23/nptl/../sysdeps/unix/syscall-template.S:84: undefined reference to `__syscall_error'
/usr/lib/x86_64-linux-gnu/libpthread.a(ptw-close.o):/build/glibc-e6zv40/glibc-2.23/nptl/../sysdeps/unix/syscall-template.S:84: more undefined references to `__syscall_error' follow

and occur for some compilation units, but others build fine. One affected target is pcl_pcd_introduce_nan.

To Reproduce

  • be on Ubuntu 16.04 (bare-bones docker container)
  • download 1.11.0 release
  • cmake .. -DPCL_SHARED_LIBS=OFF -DWITH_OPENGL=OFF -DCMAKE_VERBOSE_MAKEFILE=1
  • make -j8

Screenshots/Code snippets/Build information
The cmake output is this

cmake .. -DPCL_SHARED_LIBS=OFF -DWITH_OPENGL=OFF -DCMAKE_VERBOSE_MAKEFILE=1 -DCMAKE_BUILD_TYPE=Debug
-- The C compiler identification is GNU 5.4.0
-- The CXX compiler identification is GNU 5.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.1")
-- Could NOT find ClangFormat (missing: ClangFormat_EXECUTABLE ClangFormat_VERSION) (Required is at least version "10")
-- Performing Test HAVE_MARCH
-- Performing Test HAVE_MARCH - Success
-- Using CPU native flags for SSE optimization: -march=native
-- Performing Test HAVE_MM_MALLOC
-- Performing Test HAVE_MM_MALLOC - Success
-- Performing Test HAVE_POSIX_MEMALIGN
-- Performing Test HAVE_POSIX_MEMALIGN - Success
-- Performing Test HAVE_SSE4_2_EXTENSIONS
-- Performing Test HAVE_SSE4_2_EXTENSIONS - Success
-- Performing Test HAVE_SSE4_1_EXTENSIONS
-- Performing Test HAVE_SSE4_1_EXTENSIONS - Success
-- Performing Test HAVE_SSSE3_EXTENSIONS
-- Performing Test HAVE_SSSE3_EXTENSIONS - Success
-- Performing Test HAVE_SSE3_EXTENSIONS
-- Performing Test HAVE_SSE3_EXTENSIONS - Success
-- Performing Test HAVE_SSE2_EXTENSIONS
-- Performing Test HAVE_SSE2_EXTENSIONS - Success
-- Performing Test HAVE_SSE_EXTENSIONS
-- Performing Test HAVE_SSE_EXTENSIONS - Success
-- Found OpenMP_C: -fopenmp (found version "4.0")
-- Found OpenMP_CXX: -fopenmp (found version "4.0")
-- Found OpenMP: TRUE (found version "4.0") found components:  C CXX
-- Found OpenMP, spec date 201307
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- Checking for module 'eigen3'
--   Found eigen3, version 3.2.92
-- Found Eigen: /usr/include/eigen3 (Required is at least version "3.1")
-- Eigen found (include: /usr/include/eigen3, version: 3.2.92)
-- Checking for module 'flann>=1.7.0'
--   Found flann, version 1.8.4
-- Found FLANN: /usr/lib/x86_64-linux-gnu/libflann_cpp_s.a (Required is at least version "1.7.0")
-- Could NOT find LIBUSB_1 (missing: LIBUSB_1_LIBRARY LIBUSB_1_INCLUDE_DIR)
-- Checking for module 'libusb-1.0'
--   No package 'libusb-1.0' found
-- Could NOT find USB_10 (missing: USB_10_LIBRARY USB_10_INCLUDE_DIR)
-- OpenNI disabled because libusb-1.0 not found.
-- OpenNI grabber support: not building because OpenNI not found
-- Checking for module 'libusb-1.0'
--   No package 'libusb-1.0' found
-- Could NOT find USB_10 (missing: USB_10_LIBRARY USB_10_INCLUDE_DIR)
-- OpenNI 2 disabled because libusb-1.0 not found.
-- OpenNI2 grabber support: not building because OpenNI2 not found
-- Could NOT find ENSENSO (missing: ENSENSO_LIBRARIES ENSENSO_INCLUDE_DIRS)
-- IDS-Imaging Ensenso camera support: not building because Ensenso not found
-- Could NOT find davidSDK (missing: DAVIDSDK_LIBRARY DAVIDSDK_INCLUDE_DIR)
-- David Vision Systems SDK support: not building because davidSDK not found
-- Could NOT find DSSDK (missing: DSSDK_LIBRARIES DSSDK_INCLUDE_DIRS)
-- DepthSense SDK support: not building because DSSDK not found
-- Could NOT find RSSDK (missing: RSSDK_LIBRARIES RSSDK_INCLUDE_DIRS)
-- RealSense SDK support: not building because RSSDK not found
-- Could NOT find RSSDK2
-- RealSense SDK 2.0 (librealsense) support: not building because RSSDK2 not found
-- Checking for module 'metslib'
--   No package 'metslib' found
-- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.a (found version "1.2.8")
-- Found PNG: /usr/lib/x86_64-linux-gnu/libpng.a (found version "1.2.54")
-- Could NOT find Qhull (missing: QHULL_LIBRARIES QHULL_INCLUDE_DIRS)
-- The imported target "vtkRenderingPythonTkWidgets" references the file
   "/usr/lib/x86_64-linux-gnu/libvtkRenderingPythonTkWidgets.so"
but this file does not exist.  Possible reasons include:
* The file was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and contained
   "/usr/lib/cmake/vtk-6.2/VTKTargets.cmake"
but not all the files it references.

-- The imported target "vtk" references the file
   "/usr/bin/vtk"
but this file does not exist.  Possible reasons include:
* The file was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and contained
   "/usr/lib/cmake/vtk-6.2/VTKTargets.cmake"
but not all the files it references.

-- VTK_MAJOR_VERSION 6, rendering backend: OpenGL
Warning: You are to build PCL in STATIC but VTK is SHARED!
Warning: VTK disabled!
-- Found PCAP: /usr/lib/x86_64-linux-gnu/libpcap.a
-- Found Boost: /usr/include (found suitable version "1.58.0", minimum required is "1.55.0") found components:  filesystem date_time iostreams system regex
-- Could NOT find OpenGL (missing: OPENGL_opengl_LIBRARY OPENGL_glx_LIBRARY)
-- Could NOT find GLEW (missing: GLEW_INCLUDE_DIRS GLEW_LIBRARIES)
-- DOXYGEN_FOUND
-- HTML_HELP_COMPILER
-- Found CPack generators: DEB
-- The following subsystems will be built:
--   common
--   kdtree
--   octree
--   search
--   sample_consensus
--   filters
--   2d
--   geometry
--   io
--   features
--   ml
--   segmentation
--   surface
--   registration
--   keypoints
--   tracking
--   recognition
--   stereo
--   tools
-- The following subsystems will not be built:
--   visualization: VTK was not found.
--   apps: Disabled by default
--   outofcore: Disabled manually.
--   examples: Code examples are disabled by default.
--   people: Disabled manually.
--   simulation: Disabled by default.
--   global_tests: Disabled by default
-- Configuring done
-- Generating done

Your Environment (please complete the following information):

  • OS: Ubuntu 16.04
  • Compiler: GCC 5.4.0
  • PCL Version:1.11.0
  • PCL Type: Compiled from source

If PCL was compiled from source or failure in compiling PCL itself:

  • GPU, Kinfu, CUDA enabled? No
  • List and Version of dependencies used: See cmake output above
  • Compilation flags are used: See cmake args above

Possible Solution

Some googling suggested this may be due to the fact that libc is not linked statically, maybe some flags like -static-libgcc or -static-libstdc++ are missing? Then again from what I read, one should not attempt to statically link libgcc. However this means the option to build static libpcl appears not to work in this configuration. It seems though that when I add -static -static-libstdc++ -static-libgcc to CMAKE_CXX_COMPILE_FLAGS that linking succeeds, but I had to explicitly configure -DWITH_VTK=OFF.

Update: Without adding the compiler flags, I manually removed /usr/lib/x86_64-linux-gnu/libpthread.a from the compiler invocation and then the target builds. I did not find a way to force cmake to not link pthreads dynamically. The CMAKE_FIND_LIBRARY_SUFFIXES get set to ".a" when building static libs. I tried switching this temporarily to ".so" for the find_packge(Threads) call, but that does not help. maybe because the lib is also brought in through another dependency such as OpenMP?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the Ubuntu 16.04 build using the listed CMake options and inspect the verbose link command for pcl_pcd_introduce_nan and other failing targets. Trace how CMake selects pthread and OpenMP dependencies when PCL_SHARED_LIBS=OFF; done means the static-library configuration builds without the reported __syscall_error linker failures.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake, cpp
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.