C/C++ Linking

C/C++ Linking

If I make a C++ library and supply it to a clientwho does not have a C++ compiler, can theycall my C++ functions from their C routines?That is, is it possible to use the C++ library without having a C++ compiler installed (on UNIIX).

It is possible to use your library as long as your client uses a language that allows them to call the library. For example, this is possible from C but they will need at least a C compiler.

There are some more complicated issues, however. Because C++ allows you to create functions with the same name as long as the arguments are different (function overloading), C++ “mangles” the function name based on the arguments so the linker can tell the difference. Therefore, in order to call C++ routines from C, you must either know the mangled names and call them, or you must export your C++ functions as C functions.


Share the Post: