写了一个最简单的动态链接库程序,使用g++命令行编译。怕以后忘记,就把它记到blog中。
动态库导出头文件:
/** * file: dll.h * Powered by JGood 2009-09-22 */ #ifndef __dll_h__ #define __dll_h__ #ifdef __MY_DLL_LIB__ #define DLL_EXPORT extern "C" __declspec(dllexport) #else #define DLL_EXPORT extern "C" __declspec(dllimport) #endif DLL_EXPORT int jmax(int x, int y); #endif
/** * file: dll.cpp * Powered by JGood 2009-09-22 */ #define __MY_DLL_LIB__ #include "dll.h" int jmax(int x, int y) { return x > y ? x : y; }
/** * file: main.cpp * Powered by JGood 2009-09-22 */ #include "dll.h" #include <iostream> using namespace std; int main() { int a = 20; int b = 40; cout << jmax(a, b) << endl; return 0; }
8764



被折叠的 条评论
为什么被折叠?



