title: Why is extern "C" used with shared object library determined at runtime?
body: <ol>
  <li><p>I saw in a C++ program that <code>dlfcn</code> library 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 <code>dlsym()</code> and other functions in <code>dlfcn</code>.</p>
  
  <ul>
  <li><p>Assume the user chooses a shared object library called  <code>x.so</code> during runtime. <code>x.so</code> was compiled from a cpp file with definitions
  of functions enclosed within <code>extern "C"</code>. A comment in the cpp file
  says that the usage of <code>extern "C"</code> is important but without further
  explanation, and I wonder why? </p></li>
  <li><p>Is it correct that there is only C++ code and no C code involved here? So is <code>extern "C"</code> not necessarily <strong>only</strong> used when mixing C and C++
  code together?</p></li>
  <li><p>Does whether <code>dlfcn</code> library is statically or dynamically linked to the C++ program matters to the questions above?</p></li>
  </ul></li>
  <li>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 <code>dlfcn</code> before 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?</li>
  </ol>
  
  <p>Thanks.</p>