Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Remember that when you link against a static LIB, by default the linker is only pulling in the functions, classes, and data that the client (which in this case is your <strong>DLL</strong>) actually references.</p> <p>So what happens is this:</p> <ol> <li>You build your static LIB, and that's fine. This LIB is 100% valid.</li> <li>You now build your static DLL around the original binary LIB. It pulls in <em>only the stuff that it actually references</em>. It doesn't pull in the <em>entire class definition</em> which is what it needs to do. This DLL, though it builds, is invalid.</li> <li>A client then uses the DLL, and expects to see a complete binary definition for the exported class, because that's what the client sees in the accompanying header file.</li> <li>However the class has only been <em>partially</em> imported, and this is why you're getting those link errors.</li> </ol> <p>To fix:</p> <ul> <li>If you're able to, don't build your DLL off your static LIB. Build your DLL off the original source code. And build your static LIB off the original source code.</li> <li>Otherwise you can possibly fiddle with linker settings but I strongly recommend option 1 above. Note that OPT:NOREF won't work here as OPT:NOREF has no effect on static LIBs.</li> </ul> <p>What wont't fix it:</p> <ul> <li>High-level linker tweaks like OPT:NOREF, anything involving COMDATs, etc. If you want those functions present, you have to make sure they're referenced, either by referencing them, or by telling the linker explicitly, "hey, this Symbol X is referenced".</li> </ul> <p>As a side note:</p> <ul> <li>Anytime I build a DLL or LIB, I build <em>both</em> a DLL and a LIB, using exactly the technique you're using. Having a single code base that can generate either a DLL or a LIB by toggling a setting is ideal. But building a DLL off of a (binary) static LIB when you own the source code for both... I'm having a hard time imagining when such a scenario would be necessary.</li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload