动态库没有静态库文件的符号
Dynamic library do not have symbol of static library file
动态库(.so(文件中没有静态库文件或函数的符号。
我使用的是 ubuntu 18.04 和 12.04 系统。 我使用 -fPIC 选项从 cpp 文件创建了一个对象文件,而不是创建的静态库 (.a(。 之后,我使用命令创建了一个动态库:g++ -shared -I(include path( -L(other Library path( -l(librariess( -o filename.so -wl,-soname,filename.so staticlib.a" 我显示在 12.04 ubuntu 系统中创建的符号,但不显示在 18.04 系统中。 我显示由 so 文件中没有符号创建的文件。我们可以使用 nm -g 文件名 .so 进行检查。
如果我尝试使用 12.04,我在 18.04 系统中的 nm 命令中得到了这种类型的结果,它会给我所有 cpp 文件的整个系统。
$ nm -g libPJ.so
w _ITM_deregisterTMCloneTable
w _ITM_registerTMCloneTable
0000000000201020 B __bss_start
w __cxa_finalize
w __gmon_start__
0000000000201020 D _edata
0000000000201028 B _end
000000000000052c T _fini
0000000000000410 T _init
从静态库链接共享库时-Wl,-whole-archive
添加链接器标志。从man ld
:
--whole-archive For each archive mentioned on the command line after the --whole-archive option, include every object file in the archive in the link, rather than searching the archive for the required object files. This is normally used to turn an archive file into a shared library, forcing every object to be included in the resulting shared library. This option may be used more than once. Two notes when using this option from gcc: First, gcc doesn’t know about this option, so you have to use -Wl,-whole-archive. Second, don’t forget to use -Wl,-no-whole-archive after your list of archives, because gcc will add its own list of archives to your link and you may not want this flag to affect those as well.
相关文章:
- 使用gcc从静态链接的文件中查找可选符号
- 检测 COFF 对象文件中C++内联符号
- 使用 fopen 打开 .pak 文件并使该文件应用于 const 无符号字符* (C++)
- 如何从二进制文件中的给定符号中获取调用程序图
- 如何将 UTF-8 文本从文件转换为某个可以迭代的容器,并检查每个符号是否为C++字母数字?
- CMake 生成的 MSVC 项目找不到符号,即使为其相关 dll 正确生成了 lib 文件也是如此
- 错误:当我从"WinDbg"打开可执行文件时,找不到符号文件。默认导出 ntdll 的符号.dll
- 可以在 cpp 文件中C++定义为特殊符号的变量β
- 尝试将字符串从文件读取到无符号字符向量中
- C++和带有国家符号的文件路径(也许用 UTF8 编码)
- 体系结构x86_64的未定义符号:c++/ h 文件和 cpp 文件
- 错误LNK2019:未解析的外部符号.c文件到cpp
- Visual Studio 2012 性能分析无法加载符号文件
- 查看给定VC++ exe中的所有符号/文件的方法
- gdb:在0x2aaaaaaab000添加的符号文件系统提供的 DSO 中找不到可加载的部分
- gdb:在添加的符号文件系统提供的编号为0x#的DSO中找不到可加载的节
- 类型是否在最终二进制文件中公开?它们在符号文件和RTTI中可用吗?
- Oracle是否为OCCI/OCI提供公共符号文件(PDB)
- gdb:什么是用于调试的符号文件
- 非常困如何找到符号文件