fold all codes

windows下dll的编译和链接

/cpp/dll/fun.cpp
#include "fun.h"

int fun(int n)
{
    if (n < 1)
        return 1;

    return n * fun(n - 1);
}

/cpp/dll/fun.h
#ifndef FUN_H
#define FUN_H

int fun(int n);

#endif // FUN_H

/cpp/dll/main.cpp
#include <iostream>
using namespace std;

#include "fun.h"

int main()
{
    cout << fun(5) << endl;
}

/cpp/dll/Makefile
main:
	g++ -c fun.cpp main.cpp
	g++ -shared fun.o -o fun.dll
	g++ main.o -I. -L. -lfun -o main.exe
	strip fun.dll main.exe

clean:
	del *.bak *.o *.dll *.exe

posted @ 2012-05-11 19:59  hylent  阅读(419)  评论(0编辑  收藏  举报