'How to make a shared library not link to its deps in gn
I am using gn as make system, and I have a shared libS which deps libA and libB, but I want to functions in libA are not linked into libS ( it will be linked into main ) while functions libB are linked into libS.
My problem is:
- If I use deps or public deps for libA, the include path will be added ( it is what I want) but all functions will also be linked too ( it is not what I want)
- If I use data_deps, the functions will not be linked (I want), but the include path will not be added too ( not I want )
Solution 1:[1]
If you only want libS to have libA's include paths, you can use a config.
//path/to/libA/BUILD.gn:
config("config") {
include_dirs = [ "include" ]
}
static_library("libA") {
public_configs = [ ":config" ]
sources = [ ... ]
# etc
}
//path/to/libS/BUILD.gn:
shared_library("libS") {
configs = [ "//path/to/libA:config" ]
deps = [ "//path/to/libB" ]
}
This way GN will add -Ipath/to/libA to the compile lines for the sources in libS, but not add anything from libA to the link line.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Charles Nicholson |
