过程:
1.编写myMath.cpp(该文件中需用回调函数),myMath.h
2.利用gcc手动将第一步的两个文件编译为dll文件
3.编写main.cpp(该文件中有回调函数的具体定义),然后调用第二步的dll
具体过程如下:
1.(1)myMath.h如下图:
(2)myMath.cpp如下:
2.利用gcc编译:
gcc -c myMath.cpp -o myMath.o
gcc myMath.o -o myMath.dll -shared
编译后当前目录生成dll文件:
3.编写main.cpp(调用dll):
然后运行main.cpp,运行结果如下: