@[nn] なかんじの *.dll を gcc/cygwin でコンパイル その2

前回の続き. 今度は -mno-cygwin オプションをつけて, cygwin な dll が不要なモジュールを作成しましょう.

$ gcc -mno-cygwin test.c -L. -lAAA
d000007.o:(.text+0x0): multiple definition of `__onexit'
/usr/lib/gcc/i686-pc-mingw32/3.4.4/../../../../i686-pc-mingw32/lib/crt2.o:crt1.c:(.text+0x2d0): first defined here
d000009.o:(.text+0x0): multiple definition of `_atexit'
/usr/lib/gcc/i686-pc-mingw32/3.4.4/../../../../i686-pc-mingw32/lib/crt2.o:crt1.c:(.text+0x2c0): first defined here
collect2: ld returned 1 exit status
make: *** [test_simple] Error 1

ためしに -lAAA ではなくて AAA.dll をフルパス指定で gcc に与えてみるとエラーの内容が変わる.

$ gcc -mno-cygwin test.c /cygdrive/d/..../AAA.dll
test.o: test.c:(.text+0xbf): undefined reference to `_FFF@24`

今度は -lAAA ではなくて AAA.lib をフルパス指定で渡すとうまくいった.

$ gcc -mno-cygwin test.c /cygdrive/d/..../AAA.lib


ほかのソースをコンパイルしてみると今度は違うエラーが(-mno-cygwin がなければコンパイルは通る)

$ gcc -mno-cygwin test2.c -L. -lAAA
test2.o:test2.c:(.text+0x157): undefined reference to `__imp___iob'
test2.o:test2.c:(.text+0x191): undefined reference to `__imp___iob'
test2.o:test2.c:(.text+0x1cb): undefined reference to `__imp___iob'
test2.o:test2.c:(.text+0x205): undefined reference to `__imp___iob'
test2.o:test2.c:(.text+0x23f): undefined reference to `__imp___iob'
test2.o:test2.c:(.text+0x279): more undefined references to `__imp___iob' follow
collect2: ld returned 1 exit status

なんじゃらほい.