How Do I Dynamically Link an Existing SO File?

36 views
Skip to first unread message

丛有钱

unread,
Jun 21, 2023, 4:16:10 AM6/21/23
to gn-dev
1.In BUILDCONFIG.gn file,the following variables are defined:

boringssl_shared_library_name = "libboringssl.so"
if (target_cpu == "x64") {
    boringssl_shared_library_stored_path = rebase_path("//third_party/libs/boringssl/linux/")
} else {
  use_boringssl_library_server = false
}

2.In BUILD.gn file, I used libs
libs += [ boringssl_shared_library_stored_path + boringssl_shared_library_name ]

3.The generated .so file does not contain libboringssl.so
 0x0000000000000001 (NEEDED)             Shared library: [libdl.so.2]
 0x0000000000000001 (NEEDED)             Shared library: [libpthread.so.0]
 0x0000000000000001 (NEEDED)             Shared library: [libm.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [libgcc_s.so.1]
 0x0000000000000001 (NEEDED)             Shared library: [libc.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [ld-linux-x86-64.so.2]
 0x000000000000000e (SONAME)             Library soname: [libhquic.so]

David Turner

unread,
Jun 21, 2023, 5:40:18 AM6/21/23
to 丛有钱, gn-dev
What is the actual command being run for your target? It would be useful to use `gn desc <build_dir> <target_label>` to see whether the path to your libboringssl.so is actually used in the end, and if a linker flag like `--as-needed` is used (if so, if your final link target, or one of its other dependencies, do not import a symbol from libboringssl.so, the library will be omitted from the final DT_NEEDED list).

See https://linux.die.net/man/1/ld

--
To unsubscribe from this group and stop receiving emails from it, send an email to gn-dev+un...@chromium.org.
Reply all
Reply to author
Forward
0 new messages