Created
August 15, 2016 23:06
-
-
Save retep998/48d70365b101e2c36d33374f8f420287 to your computer and use it in GitHub Desktop.
This file contains hidden or 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) int bunny = 273; | |
__declspec(dllexport) int rabbit() { return 273; } |
This file contains hidden or 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
> cl /c bar.c ; link /dll bar.obj ; cl /c foo.c ; link foo.obj bar.lib | |
Microsoft (R) C/C++ Optimizing Compiler Version 19.00.24213.1 for x64 | |
Copyright (C) Microsoft Corporation. All rights reserved. | |
bar.c | |
Microsoft (R) Incremental Linker Version 14.00.24213.1 | |
Copyright (C) Microsoft Corporation. All rights reserved. | |
Creating library bar.lib and object bar.exp | |
Microsoft (R) C/C++ Optimizing Compiler Version 19.00.24213.1 for x64 | |
Copyright (C) Microsoft Corporation. All rights reserved. | |
foo.c | |
Microsoft (R) Incremental Linker Version 14.00.24213.1 | |
Copyright (C) Microsoft Corporation. All rights reserved. | |
foo.obj : error LNK2019: unresolved external symbol bunny referenced in function main | |
foo.exe : fatal error LNK1120: 1 unresolved externals |
This file contains hidden or 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 int bunny; | |
__declspec(dllimport) int rabbit(); | |
int main() { | |
printf("%d", bunny); | |
printf("%d", rabbit()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment