[ 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

A few days ago I joined #mandriva on Freenode trying to get to the bottom of a
problem I have with KMail at work, where I cannot start KAddressBook from
inside it. I asked my question and soon afterwards received:

* One Thunderbird recommendation.
* Two Evolution recommendations.
* One Sylpheed Claws recommendation.
* One GMail recommendation.

The problem is that I wasn't interested to learn about alternative E-mail
clients, and just wanted to get my problem solved. And in GMail's case it was
completely out of the question due to my work's constraints.

-- Shlomi Fish in --
http://www.shlomifish.org/philosophy/computers/web/use-qmail-instead/

    -- Shlomi Fish
    -- The "Use qmail instead" Syndrome ( http://www.shlomifish.org/philosophy/computers/web/use-qmail-instead/ )

God created the world out of nothing, but
the nothingness still shows through.

	-- One of Nadav Har'El's Email Signatures.


Powered by UNIX fortune(6)
[ Main Page ]