2010年3月11日木曜日

MinGWでDLLを作ってみる (32bitと64bit)

手軽な方法はこれ。

$ g++ -static -shared -o hello.dll hello.cc world.cc -Wl,--out-implib,libhello.a

gcc 4.4.0 (32bit)を使って、上記の方法でDLLをつくると、必要以上に多くの関数をexportしちゃっている。

ちゃんとDEFファイルを用意して必要な関数だけをexportする場合は次のようにすればよいみたい。

$ g++ -c hello.cc
$ g++ -c world.cc
$ g++ -mdll -o hello.dll.tmp -Wl,--base-file,hello.dll.base hello.o world.o
$ dlltool -l libhello.a --dllname hello.dll --base-file hello.dll.base --output-exp hello.dll.exp --def hello.def
$ g++ -mdll -o hello.dll -Wl,hello.dll.exp -static hello.o world.o

0 件のコメント:

コメントを投稿