Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Yes you can but I would strongly recommend against it if you don't have to. It's fiddly and it feels like you need to sort out your dependencies better.</p> <p>To do it, you have to use <code>LIB.EXE</code> to create an import library from the object files of one binary before you actually link it; use this import library to link other binary and create an import library for the other binary; finally use the other library's import library to link the original binary.</p> <p>E.g.</p> <p>exe.c:</p> <pre><code>#include &lt;stdio.h&gt; void __declspec(dllimport) dllfn(void); void __declspec(dllexport) exefn(void) { puts("Hello, world!"); } int main(void) { dllfn(); return 0; } </code></pre> <p>Compiler with <code>cl /c exe.c</code>. <code>exe.obj</code> is created.</p> <p>exe.def:</p> <pre><code>LIBRARY exe.exe </code></pre> <p>Create import library with <code>lib /def:exe.def exe.obj</code>. <code>exe.lib</code> and <code>exe.exp</code> are created.</p> <p>dll.c:</p> <pre><code>void __declspec(dllimport) exefn(void); void __declspec(dllexport) dllfn(void) { exefn(); } </code></pre> <p>Compile with <code>cl /c dll.c</code>. <code>dll.obj</code> is created.</p> <p>Link DLL with <code>link /dll dll.obj exe.lib</code>. <code>dll.dll</code>, <code>dll.lib</code> and <code>dll.exp</code> are created.</p> <p>Link EXE with <code>link exe.obj dll.lib</code>. <code>exe.exe</code> is created. (<code>exe.lib</code> and <code>exe.exp</code> are also recreated.)</p> <p>Run exe, note the <code>Hello, world!</code> output.</p>
 

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