2025-07-06 11:18:03 -07:00
2025-07-06 11:18:03 -07:00
2025-07-06 11:18:03 -07:00
2025-07-06 11:10:11 -07:00
2025-07-06 11:18:03 -07:00

To list every symbol in a dll, use "nm".

"nm -g hello.so" output "T square", where hello.so is created from a C source file containing function square. "nm -g callee.so" output "T _Z7isprimex", "_Z9sumprimesx", where callee.so is created from a C++ file containing function isprime and sumprimes.

Why does the names differ? C++ compilers use "name mangling" to support overloading, etc, resulting in names that differ from names in the source file. This is not done in C compilers (since C does not support overloading as well).

To prevent name mangling, use extern "C" directive in the function declaration. The extern keyword may be applied to a global variable, function, or template declaration. It specifies that the symbol has external linkage. extern "C" specifies that the function is defined elsewhere and uses the C-language calling convention, which includes do not mangle names.

Description
Example of calling C and C++ functions in Python
Readme MIT 33 KiB
Languages
Python 53.4%
C 23.9%
C++ 13.1%
Makefile 9.6%