64,637
社区成员
发帖
与我相关
我的任务
分享
//main.cpp
extern int g;
void print_g();
int main()
{
print_g();
g++;
print_g();
return 0;
}
//dll.cpp
#include <iostream>
using namespace std;
int g = 0;
void print_g()
{
cout << g << endl;
}
//makefile
target: a.exe dll.dll
dll.dll: dll.cpp
g++ -g -Wall -std=c++11 -shared -o dll.dll dll.cpp
a.exe: main.cpp dll.dll
g++ -g -Wall -std=c++11 -o a.exe main.cpp dll.dll
//cmd
a.exe > output.txt
//output.txt
0
1