MinGW の下で、エンチャントに依存する gtkspell に依存するものをコンパイルしようとしています。gtkspell/gtkspell.c:757: undefined reference to '_imp__enchant_broker_init'
これは、{static,dynamic} ライブラリに対してリンクする必要があるときに、別のライブラリにリンクしようとしていることが原因であるか、または imp の前にアンダースコアが 1 つしかないためであると思われるようなエラーが発生
します。 2 つある必要があります。私は得る
$ objdump -t /d/opt/enchant-1.6.0/lib/libenchant.a | grep enchant_broker_init
[ 85](sec 1)(fl 0x00)(ty 20)(scl 2) (nx 0) 0x00002ac0 _enchant_broker_init
と
$ objdump -t /d/opt/enchant-1.6.0/lib/libenchant.dll.a | grep enchant_broker_init
[ 6](sec 1)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00000000 _enchant_broker_init
[ 7](sec 3)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00000000 __imp__enchant_broker_init
インターネット (http://lists.freedesktop.org/archives/gstreamer-devel/2007-January/013975.html) は、インプのマングリングが
_declspec(dll{import,export})
エンチャントは使っているようですが
__declspec(dll{import,export})
enchant_broker_init
、および enchant.h の関連する行をコメントアウトすると、ではなくgtkspell.c リクエストが作成_imp__enchant_broker_init
されますが、libenchant に表示されるシンボルは変更されません。gcc が名前を壊さないようにする方法はありますか、または何が問題になっているのか、またはそれを修正する方法についてアイデアを持っている人はいますか?
私のシステムで問題を再現する最小限の例を次に示します。
コンテンツを含むファイル enchanttest1.c がある場合
#include <stdio.h>
#include <enchant.h>
int main()
{
#ifdef ENCHANT_MODULE_EXPORT
printf("\nEnchant found\n");
#else
printf("\nEnchant not found\n");
#endif
return 0;
}
およびコンテンツを含むファイル enchanttest2.c
#include <stdio.h>
#include <enchant.h>
int main()
{
EnchantBroker *b = enchant_broker_init();
#ifdef ENCHANT_MODULE_EXPORT
printf("\nEnchant found\n");
#else
printf("\nEnchant not found\n");
#endif
return 0;
}
それから
gcc enchanttest1.c `pkg-config --cflags enchant` && ./a.exe
与えますEnchant found
が
gcc enchanttest2.c `pkg-config --cflags enchant` && ./a.exe
与える
C:\Users\JASONG~1\AppData\Local\Temp\ccyDLptc.o:testenchant.c:(.text+0xf): undefined reference to `_imp__enchant_broker_init'
collect2: ld returned 1 exit status