Last active
April 18, 2023 09:53
-
-
Save jpz/39cb0f2778a1a5bb24e5fd855bbe3d38 to your computer and use it in GitHub Desktop.
mutually dependent binaries
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
__declspec(dllimport) void a(); | |
__declspec(dllexport) void b() | |
{ | |
std::cout << "b()\n"; | |
std::cout << "calling a()\n"; | |
a(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
LIBRARY b | |
EXPORTS | |
?b@@YAXXZ @1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% 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