Linking Folly library causes /usr/bin/ld: cannot find -lgflags_shared
- Dominant language
- C++
- Stars
- 30.5k
- Forks
- 5.9k
- PR merge metrics
- No merged PRs in 30d
Description
OS: Ubuntu 20.04
Folly version: v2023.02.06.00
I've built Folly using instructions from the readme:
```
./build/fbcode_builder/getdeps.py install-system-deps --recursive
python3 ./build/fbcode_builder/getdeps.py --allow-system-packages build
```
Then I added Folly in Cmake:
```
find_package(Folly CONFIG REQUIRED)
```
When I'm trying to link Folly library to an executable build process fails:
```
/usr/bin/ld: cannot find -lgflags_shared
```
However, `gflags` was installed (libgflags-dev) and found by Cmake as `gflags::gflags_shared`
I looked at `${install_dir]/folly/lib/cmake/folly/folly-targets.cmake` and found that `gflags_shared` is linked to `folly_deps`:
```
set_target_properties(Folly::folly_deps PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "/usr/include;${_IMPORT_PREFIX}/include"
INTERFACE_LINK_LIBRARIES "... ;gflags_shared; ..."
)
```
I changed `gflags_shared` to `gflags::gflags_shared` and the issue has gone.
Is it correct that `gflags_shared` lib is linked to Folly without `gflags::` prefix?
Contributor guide
Research direction
Start with the generated ${install_dir}/folly/lib/cmake/folly/folly-targets.cmake and the Folly CMake package configuration used by find_package(Folly CONFIG REQUIRED). Reproduce the link failure with the Ubuntu 20.04 setup, then compare how gflags::gflags_shared is found with the exported folly_deps link entry. Done means a consumer can link Folly through its package configuration without manually editing the generated targets file.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cmake, cpp
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100