bazel-contrib / bazel-contrib/rules_foreign_cc

Symbol lookup error when running `cc_test`

Open
#1,164 0 comments 3 reactions 0 assignees View on GitHub
Dominant language
Starlark
Stars
737
Forks
270
PR merge metrics
No merged PRs in 30d

Description

This may not be a `rules_foreign_cc` issue but I am hoping someone here has encountered this before and can provide pointers.

I have the following setup:
```
cc_test(foo_test) -> cc_library(foo) -> cmake(opencv)
```

I am building opencv as a static library with `BUILD_SHARED_LIBS=OFF`. The test fails to run with the following error:
```
foo_test: symbol lookup error: libfoo.so: undefined symbol: cv::imencode
```

I can avoid this issue by forcing static-linking using any of the following strategies:
1. `bazel test :foo_test --dynamic_mode off`
2. `cc_library(foo, linkstatic = True)`

Is this expected? Is there a better way?

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the `cc_test(foo_test) -> cc_library(foo) -> cmake(opencv)` setup with `bazel test :foo_test`. Compare the default run with `--dynamic_mode off` and `linkstatic = True`, then trace how the OpenCV static build is linked into `libfoo.so`. Done means determining whether this is expected and documenting or correcting the supported linking configuration.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake, opencv
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.