Last active
April 2, 2017 14:56
-
-
Save elieux/1ebd7cd1599648c74ad4 to your computer and use it in GitHub Desktop.
DLL troubles
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 <stdio.h> | |
extern const int answer; | |
extern __declspec(dllexport) void print42() { | |
printf("Hello %d.\n", answer); | |
} |
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
__declspec(dllexport) const int answer = 42; |
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 <stdio.h> | |
__declspec(dllimport) void print42(); | |
__declspec(dllimport) const int answer; | |
int main() { | |
printf("Hello %d. ", answer); | |
print42(); | |
return 0; | |
} |
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
all: main.exe | |
foo.o: foo.c | |
gcc -c foo.c -o foo.o | |
libfoo.a: foo.o | |
ar sr libfoo.a foo.o | |
bar.o: bar.c | |
gcc -c bar.c -o bar.o | |
libbar.dll: bar.o libfoo.a | |
gcc -shared -o libbar.dll -Wl,--out-implib,libbar.dll.a bar.o -L. -lfoo | |
main.exe: main.c libbar.dll | |
gcc -o main.exe main.c -L. -lbar |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment