[ Main Page ]

Making VST plugins with MinGW

MinGW + MSYSでVST Plug-inを作る方法とサンプル。 Freeverb3@sourceforge.netではこれを利用したソースコードをGPLで配布しています。

必要なもの

落とし穴やその他

configure.inでは、AC_LIBTOOL_WIN32_DLLがAM_PROG_LIBTOOLの前に必要です。

LDFLAGS(libtool)には、-no-undefinedが必要です。

MinGWでは、 __declspec(dllexport)マクロによる関数EXPORTをサポートしています。 -fPICは必要ありません。PEはすべてがposition independentです。

mainをエクスポートすることができないコンパイラが多くあります。多くは 以下のようなエラーメッセージを吐いて止まります。

FreeverbMain.cpp:31: error: `main' must return `int'
FreeverbMain.cpp:32: error: `main' must return `int'
FreeverbMain.cpp: In function `int main(...)':
FreeverbMain.cpp:32: error: declaration of C function `int main(...)' conflicts with
FreeverbMain.cpp:31: error: previous declaration `AEffect* main(VstIntPtr (*)(AEffect*, VstInt32, VstInt32, VstIntPtr, void*, float))' here
FreeverbMain.cpp: In function `int main(...)':
FreeverbMain.cpp:32: error: `VSTPluginMain' was not declared in this scope
    

Windows DLLでは、 同じ関数を別名でDEFファイルによりEXPORTする方法があるのでそれを利用しましょう。

Freeverb4.def

LIBRARY Freeverb4.dll
EXPORTS main=VSTPluginMain
    

Makefile.am

EXTRA_DIST = Freeverb4.def
lib_LTLIBRARIES = Freeverb4.la
DLLDEF = -Wl,$(top_srcdir)/FreeverbVST/Freeverb4.def
INCLUDES = \
        -I$(top_srcdir)/VST \
        -I$(top_srcdir)/Components
Freeverb4_la_LDFLAGS = -module -avoid-version -no-undefined \
        $(DLLDEF)
Freeverb4_la_LIBADD = \
        $(top_srcdir)/Components/Components.la \
        $(top_srcdir)/VST/VST.la
Freeverb4_la_SOURCES = \
        Freeverb.cpp \
        Freeverb.hpp \
        FreeverbMain.cpp
    

objdump -x Freeverb4.dll

.edata の 0x6aa51000 に export テーブルがあります

Export テーブル (.edata セクションの内容を解釈)

Export フラグ                   0
時刻/日付スタンプ               45d9f339
Major/Minor                     0/0
名前                            000000000001103c Freeverb4.dll
序数ベース                      1
各種の数値:
        Export アドレステーブル         00000002
        [名前ポインタ/序数] テーブル    00000002
テーブルアドレス
        Export アドレステーブル         0000000000011028
        名前ポインタテーブル            0000000000011030
        序数テーブル                    0000000000011038

Export アドレステーブル -- 序数ベース 1
        [   0] +base[   1] 19e0 Export RVA
        [   1] +base[   2] 19e0 Export RVA

[序数/名前ポインタ] テーブル
        [   0] VSTPluginMain
        [   1] main
    

サンプル

⇒そのほかMinGW Tips

In those days, I thought, golly, there are zillions of bug tracking packages
out there. Every programmer has written a dinky bug tracking package. Why
would anyone buy ours? I knew one thing: programmers who start businesses
often have the bad habit of thinking everybody else is a programmer just like
them and wants the same stuff as them, and so they have an unhealthy tendency
to start businesses that sell programming tools. That's why you see so many
scrawny companies hawking source-code-generating geegaws, error catching and
emailing geegaws, debugging geegaws, syntax-coloring editing tchotchkes,
ftping baubles, and, ahem, bug tracking packages. All kinds of stuff that only
a programmer could love. I had no intention of falling into that trap!

Of course, nothing ever works out exactly as planned. FogBUGZ was popular.
Really popular. It accounts for a significant chunk of Fog Creek's revenue and
sales are growing steadily. The People won't stop buying it.

    -- Joel Spolsky
    -- Rub a dub dub ( http://www.joelonsoftware.com/articles/fog0000000348.html )

Will: "Roses are red,
Violets are Blue.
Jazz and I are black,
But, Carlton, what are you?"

Excerpt from "The Fresh Prince of Bel-Air"

    -- Andy Borowitz (Creator
    -- "The Fresh Prince of Bel-Air" ( http://en.wikipedia.org/wiki/The_Fresh_Prince_of_Bel-Air )


Powered by UNIX fortune(6)
[ Main Page ]