Sure:
(venv)dovah:gerrit justin$ cat sw/A/BUILD
package(default_visibility = ["//visibility:public"])
cc_library(
name="A",
srcs=['a.h', 'a.c'],
hdrs=['a.h'],
)
(venv)dovah:gerrit justin$ cat sw/B/BUILD
package(default_visibility = ["//visibility:public"])
cc_library(
name="B",
srcs=['b.h', 'b.c'],
hdrs=['b.h'],
deps=['//sw/A'],
# linkopts=['//sw/A'], # commenting this out breaks the build!
)
(venv)dovah:gerrit justin$ cat sw/A/
BUILD a.c a.h
(venv)dovah:gerrit justin$ cat sw/A/a.h
int afunc(void);
(venv)dovah:gerrit justin$ cat sw/A/a.c
int afunc(void) {
return 42;
}
(venv)dovah:gerrit justin$ cat sw/B/b.h
int bfunc(void);
(venv)dovah:gerrit justin$ cat sw/B/b.c
#include "sw/A/a.h"
int bfunc(void) {
return afunc();
}
(venv)dovah:gerrit justin$ bazel build //sw/B --verbose_failures
INFO: Found 1 target...
INFO: From Linking sw/B/libB.so:
Undefined symbols for architecture x86_64:
"_afunc", referenced from:
_bfunc in b.pic.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ERROR: /Users/justin/git/gerrit/sw/B/BUILD:3:1: Linking of rule '//sw/B:B' failed: gcc failed: error executing command
(cd /private/var/tmp/_blaze_justin/b6a111fd3f2695a4aa1c6bdefefa0d6f/gerrit && \
exec env - \
/usr/bin/gcc -shared -o bazel-out/local_darwin-fastbuild/bin/sw/B/libB.so bazel-out/local_darwin-fastbuild/bin/sw/B/_objs/B/sw/B/b.pic.o -lstdc++ -B/usr/bin -Wl,-S): com.google.devtools.build.lib.shell.BadExitStatusException: Process exited with status 1: gcc failed: error executing command
(cd /private/var/tmp/_blaze_justin/b6a111fd3f2695a4aa1c6bdefefa0d6f/gerrit && \
exec env - \
/usr/bin/gcc -shared -o bazel-out/local_darwin-fastbuild/bin/sw/B/libB.so bazel-out/local_darwin-fastbuild/bin/sw/B/_objs/B/sw/B/b.pic.o -lstdc++ -B/usr/bin -Wl,-S): com.google.devtools.build.lib.shell.BadExitStatusException: Process exited with status 1.
Target //sw/B:B failed to build
INFO: Elapsed time: 0.103s, Critical Path: 0.04s