diff --git a/c/undef_ref/win/shared.c b/c/undef_ref/win/shared.c new file mode 100644 index 0000000..dc14f4d --- /dev/null +++ b/c/undef_ref/win/shared.c @@ -0,0 +1,8 @@ +#include + +void shared_func () +{ + puts ("shared_func() called successfully! ;-)"); + printf ("Calling test_func() from library: "); + test_func (); +} diff --git a/c/undef_ref/win/test.c b/c/undef_ref/win/test.c new file mode 100644 index 0000000..a98dc41 --- /dev/null +++ b/c/undef_ref/win/test.c @@ -0,0 +1,4 @@ +void main () +{ + dll_main (); +} diff --git a/c/undef_ref/win/test.sh b/c/undef_ref/win/test.sh new file mode 100755 index 0000000..33e6ccd --- /dev/null +++ b/c/undef_ref/win/test.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +gcc -o test_dll.dll test_dll.c -shared +gcc -o shared.dll shared.c -shared -L. -ltest_dll +gcc -o test.exe test.c -L. -ltest_dll -lshared +./test.exe diff --git a/c/undef_ref/win/test_dll.c b/c/undef_ref/win/test_dll.c new file mode 100644 index 0000000..ccb6b78 --- /dev/null +++ b/c/undef_ref/win/test_dll.c @@ -0,0 +1,19 @@ +#include +#include + +test_func () +{ + puts ("test_func() called successfully! ;-)"); +} + +typedef void (*pfunc)(); + +void dll_main () +{ + printf ("Calling shared_func() from main: "); + + HMODULE lib = LoadLibrary ("shared.dll"); + pfunc shared_func = (pfunc)GetProcAddress(lib, "shared_func"); + shared_func (); + FreeLibrary (lib); +}