Skip to content

Instantly share code, notes, and snippets.

@jpz
Last active April 18, 2023 09:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jpz/39cb0f2778a1a5bb24e5fd855bbe3d38 to your computer and use it in GitHub Desktop.
Save jpz/39cb0f2778a1a5bb24e5fd855bbe3d38 to your computer and use it in GitHub Desktop.
mutually dependent binaries
#include <iostream>
__declspec(dllimport) void b();
__declspec(dllexport) void a()
{
std::cout << "a()\n";
}
void calls_other_b()
{
std::cout << "calling b()\n";
b();
}
int main()
{
calls_other_b();
}
#include <iostream>
__declspec(dllimport) void a();
__declspec(dllexport) void b()
{
std::cout << "b()\n";
std::cout << "calling a()\n";
a();
}
LIBRARY b
EXPORTS
?b@@YAXXZ @1
% generate b.lib
lib /def:b.def
% build a.exe and produce a.lib
cl.exe a.cpp b.lib
% build b.dll
cl.exe /LD b.cpp a.lib
a.exe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment