- I saw in a C++ program that - dlfcnlibrary is used for dynamically linking to a shared object library chosen by the user of the C++ program during runtime, and for calling functions in the chosen shared object library via- dlsym()and other functions in- dlfcn.- Assume the user chooses a shared object library called - x.soduring runtime.- x.sowas compiled from a cpp file with definitions of functions enclosed within- extern "C". A comment in the cpp file says that the usage of- extern "C"is important but without further explanation, and I wonder why?
- Is it correct that there is only C++ code and no C code involved here? So is - extern "C"not necessarily only used when mixing C and C++ code together?
- Does whether - dlfcnlibrary is statically or dynamically linked to the C++ program matters to the questions above?
 
- Now compare to a simpler case, where the shared object library is
known much earlier than runtime, and the author of the C++ program
specifies it in the C++ program without using dlfcnbefore compiling it, and then dynamically links the shared object library and the C++ program during runtime. In this case, is `extern "C" still necessary in the cpp file which was compiled into the shared object library?
Thanks.
 
     
    