0

I get a bunch of these linker errors when building a cmake library

I've installed the latest build of fbthrift successfully. However for this library when I try to make it gives these errors

It seems to be failing when trying to link FBThrift::thriftcpp2

This is the error message

-- Boost version: 1.65.1
-- Found the following Boost libraries:
...
-- Found FBThrift: /usr/local
...
CMake Error at shm/CMakeLists.txt:3 (add_library):
  Target "target_shm" links to target "FBThrift::thriftprotocol" but the
  target was not found.  Perhaps a find_package() call is missing for an
  IMPORTED target, or an ALIAS target is missing?


CMake Error at navy/CMakeLists.txt:3 (add_library):
  Target "target_navy" links to target "FBThrift::thriftcpp2" but the
  target was not found.  Perhaps a find_package() call is missing for an
  IMPORTED target, or an ALIAS target is missing?


CMake Error at navy/CMakeLists.txt:3 (add_library):
  Target "target_navy" links to target "FBThrift::thriftprotocol" but the
  target was not found.  Perhaps a find_package() call is missing for an
  IMPORTED target, or an ALIAS target is missing?


CMake Error at allocator/CMakeLists.txt:12 (add_library):
  Target "target_allocator" links to target "FBThrift::thriftcpp2" but the
  target was not found.  Perhaps a find_package() call is missing for an
  IMPORTED target, or an ALIAS target is missing?


CMake Error at allocator/CMakeLists.txt:12 (add_library):
  Target "target_allocator" links to target "FBThrift::thriftprotocol" but
  the target was not found.  Perhaps a find_package() call is missing for an
  IMPORTED target, or an ALIAS target is missing?

In the main CMakeLists.txt I see

find_package(Boost REQUIRED COMPONENTS
             system filesystem regex context program_options thread)
find_package(Sodium REQUIRED)
find_package(Gflags REQUIRED)
find_package(Glog REQUIRED)
find_package(GTest REQUIRED)
find_package(GMock REQUIRED)
find_package(folly CONFIG REQUIRED)
find_package(fizz CONFIG REQUIRED)
find_package(fmt CONFIG REQUIRED)
find_package(wangle CONFIG REQUIRED)
find_package(Zlib REQUIRED)
find_package(Zstd REQUIRED)
find_package(FBThrift REQUIRED) # must come after wangle

And in common/CMakeLists.txt I see

target_link_libraries(target PUBLIC
  FBThrift::thriftcpp2
  FBThrift::thriftprotocol
  folly
  Folly::folly_exception_tracer
  Folly::folly_exception_tracer_base
  Folly::folly_exception_counter
)

My cmake is somewhat weak, I'm trying to figure out what's going on here. From a glance, fbthrift library files are in the right place.

If its any help, earlier in the dockerfile I build thrift

(cd /opt/fbthrift/build && \
     LDFLAGS="-ljemalloc" && \
     PYTHON_SIX_PATH=/usr/local/lib/python-six \
     cmake \
        -Dcompiler_only=ON -DBUILD_SHARED_LIBS=ON \
        -DCMAKE_CXX_STANDARD=17 \
     .. && \
     make && make install)
Samson Hu
  • 201
  • 1
  • 9
  • 1
    Maybe you can start from checking if cmake found the correct `FBThrift`? [This](https://stackoverflow.com/q/31343813/4123703) might help. – Louis Go Jul 27 '21 at 07:27
  • 1
    "installed the latest build of fbthrift successfully" is it possible you need an _older_ version to build this library? Perhaps they restructured their CMake package. – Alex Reinking Jul 27 '21 at 16:16

0 Answers0